evaluate jacobian using fsolve
7 views (last 30 days)
Show older comments
my function and corresponding jacobian are:
function [F,J] = myfun(x)
global m mxm Dvec gamma_0 tau_0
Ft = zeros(5,5);
n = 5;
for ki = 1:12
Fi = ((abs(m(ki,:)*x)/tau_0)^(n-1))*mxm(:,:,ki);
Ft = Ft+Fi;
end
F = (gamma_0/tau_0)*Ft*x-Dvec;
J = n*(gamma_0/tau_0)*Ft;
end
in which m is a 5x1x12 vector list, mxm is a 5x5x12 matrix list, input x is a 5x1 vector. the returned function F is a 5x1 vector and J is the 5x5 jacobian of F.
Interestingly, when I use fsolve to evaluate the function, I can get the desired results. However, when I increase the exponent,n, to larger than 5, the fsolve returns the DerivativeCheck fail information: Maximum relative difference between supplied and finite-difference derivatives = 0.0115267.
I wonder how matlab handle this evaluation. Is there a way to write the jacobian more effectively for a function like this?
thank you,
0 Comments
Answers (0)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!