derivative

How to derive with respect to a Matrix element with Sympy

风格不统一 提交于 2019-12-10 14:10:28
问题 Given the product of a matrix and a vector A.v with A of shape (m,n) and v of dim n, where m and n are symbols, I need to calculate the Derivative with respect to the matrix elements. I haven't found the way to use a proper vector, so I started with 2 MatrixSymbol : n, m = symbols('n m') j = tensor.Idx('j') i = tensor.Idx('i') l = tensor.Idx('l') h = tensor.Idx('h') A = MatrixSymbol('A', n,m) B = MatrixSymbol('B', m,1) C=A*B Now, if I try to derive with respect to one of A's elements with the

Compute the Jacobian matrix in Python

[亡魂溺海] 提交于 2019-12-09 04:57:28
问题 import numpy as np a = np.array([[1,2,3], [4,5,6], [7,8,9]]) b = np.array([[1,2,3]]).T c = a.dot(b) #function jacobian = a # as partial derivative of c w.r.t to b is a. I am reading about jacobian Matrix, trying to build one and from what I have read so far, this python code should be considered as jacobian. Am I understanding this right? 回答1: You can use the Harvard autograd library (link), where grad and jacobian take a function as their argument: import autograd.numpy as np from autograd

derivative of a function

徘徊边缘 提交于 2019-12-09 04:03:50
问题 I am using D to get derivatives of a function. However, R does not simplify the expression when returning the derivative. I need to figure out if a function has a derivative that can be expressed generically. Is there some way in R to simplify the expression? > D(expression(sqrt(1 - x^2)), 'x') -(0.5 * (2 * x * (1 - x^2)^-0.5)) > D(D(expression(sqrt(1 - x^2)), 'x'), 'x') -(0.5 * (2 * (1 - x^2)^-0.5 - 2 * x * (-0.5 * (2 * x * (1 - x^2)^-1.5)))) Secondly, is there a way in R to do numerical

How to smooth rectangular signal with high order rate-limiter in Simulink?

吃可爱长大的小学妹 提交于 2019-12-08 06:33:48
问题 Imagine I have a rectangular reference value for the position/displacement x and I need to smooth it. The math for translatoric movements is quite simple: speed: v = x' acceleration: a = v' = x'' jerk. j = a' = v'' = x''' I need to limit all these values. So I thought about using rate limiters in Simulink: This approach works perfect for ramp signals, as you can see in the following output: BUT, my reference signals for x are no ramps, they are rectangles/steps. Hence the rate limiters are

How to get a vector field that maps the slopes of an equation

爱⌒轻易说出口 提交于 2019-12-08 04:00:09
问题 Hey so I'm reading this article by Chris Hecker where he has an image of a Parabola surrounded by the a vector field of it's derivative: However he never mentions how exactly he got the vector field equation, and never even states it. He does say he overlayed the vector field of the slopes in Figure 1, by drawing the solution to the slope equation, dy/dx = 2x, as a short vector at each coordinate on the grid. How do you create a vector field of the slopes of an equation in the vector field

Implicit differentiation with Scilab?

别说谁变了你拦得住时间么 提交于 2019-12-08 03:17:13
问题 Can somebody tell me how to implicitly differentiate equations in Scilab ? Example: x^2+y^2=25 (a circle equation) The derivative is: dy/dx=−x/y How can we accomplish this implicit differentiation in Scilab? May be with diff or dassl or another function of Scilab? 回答1: Scilab is oriented to numerical computations. You can go to http://www.wolframalpha.com and type "differentiate x^2 + y^2 = 25 in x" into the input box. 来源: https://stackoverflow.com/questions/34560820/implicit-differentiation

R Hessian Matrix

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 02:04:38
问题 I need to create the Hessian matrix of a function given as: func <- expression(sin(x+y)+cos(x-y)) vars <- c("x", "y") I need the second order derivatives as expressions too, and I need to evaluate them lot of times, so I made a list of first order derivatives, and a list of list of second order derivatives. funcD <- lapply(vars, function(v) D(func, v)) funcDD <- list(); for (i in 1:length(vars)) funcDD[[i]] <- lapply(vars, function(v) D(funcD[[i]], v)) So far, it works. > funcDD [[1]] [[1]][

Derivative of a conjugate in sympy

我怕爱的太早我们不能终老 提交于 2019-12-07 18:58:13
问题 When I try to differentiate a symbol with SymPy I get the following In : x=Symbol('x') In : diff(x,x) Out: 1 When I differentiate the symbol respect to its conjugate the result is In [55]: diff(x,x.conjugate()) Out[55]: 0 However, when I try to differentiate the conjugate of the symbol SymPy doesn't do it In : diff(x.conjugate(),x) Out: Derivative(conjugate(x), x) This is still correct, but the result should be zero. How can I make SimPy perform the derivative of a conjugate? 回答1: I'm not

Explicit formula versus symbolic derivatives in R

我的未来我决定 提交于 2019-12-07 13:04:37
问题 I would like to evaluate higher order derivatives of some function f in R . Two possibilities are available to me. Either I determine a general expression for f (k) , the k -th derivative of f (which I can do in my particular case), and then I evaluate it; Or I take advantage of the capacities of R to perform symbolic derivative (function D() ). What are the advantages of 1 over 2? Let us say that f (k) is not a recursive formula. What if f (k) is recursive? Any hint will be appreciated. 回答1:

How to get a vector field that maps the slopes of an equation

落花浮王杯 提交于 2019-12-06 16:06:23
Hey so I'm reading this article by Chris Hecker where he has an image of a Parabola surrounded by the a vector field of it's derivative: However he never mentions how exactly he got the vector field equation, and never even states it. He does say he overlayed the vector field of the slopes in Figure 1, by drawing the solution to the slope equation, dy/dx = 2x, as a short vector at each coordinate on the grid. How do you create a vector field of the slopes of an equation in the vector field syntax of V = xi + yj The Figure title would be clearer if it read: The curve y = x^2 , and the vector