How do I find the second and third derivative using ForwardDiff
I can find the first derivative 14.0 at x = 1.0 using the following
using ForwardDiff
f(x) = 7*x^2
result = ForwardDiff.derivative(f,1.0)
println( "first derivative is ",result )
How do I find the second and third derivative using ForwardDiff
I can find the first derivative 14.0 at x = 1.0 using the following
using ForwardDiff
f(x) = 7*x^2
result = ForwardDiff.derivative(f,1.0)
println( "first derivative is ",result )
ForwardDiff.derivative(x -> ForwardDiff.derivative(f, x), 1.0)
It works thank you.
using ForwardDiff
f(x) = 7*x^3
result = ForwardDiff.derivative(f,1.0)
println( "first derivative is ",result )
result2 = ForwardDiff.derivative(x -> ForwardDiff.derivative(f, x), 1.0)
println( "second derivative is ",result2 )
Output
Starting Julia...
_
_ _ _(_)_ | Documentation: https://docs.julialang.org
(_) | (_) (_) |
_ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
| | | | | | |/ _ | |
| | |_| | | | (_| | | Version 1.0.3 (2018-12-18)
_/ |\__ _|_|_|\__ _| | Official https://julialang.org/ release
|__/ |
first derivative is 21.0
second derivative is 42.0