How to do partial derivatives?


#1

I’m totally new in Julia. Now, I’m working on derivative. I found that ‘2nd derivatives’ (ex. function derivative_sec_fd(f,x)), but still couldn’t find how to do partial derivative…
Could you tell me which command should I use?


#2

Do you try to do numeric, automatic or symbolic differentiation?


#3

Related (maybe xref?): https://stackoverflow.com/questions/54277219/partial-derivatives-in-julia


#4

You could use automatic differentiation to calculate partial derivatives of a function

julia> using ForwardDiff

julia> f(x) = 2*x[2]^2+x[1]^2 # some function
f (generic function with 2 methods)

julia> g = x -> ForwardDiff.gradient(f, x); # g is now a function representing the gradient of f

julia> g([1,2]) # evaluate the partial derivatives (gradient) at some point x
2-element Array{Int64,1}:
 2
 8

#5

Thank you for all of replies. I’ll try to do it !!