evaluate jacobian using fsolve

2 次查看(过去 30 天)
DS
DS 2018-3-28
编辑: DS 2018-3-28
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 个)

类别

Help CenterFile Exchange 中查找有关 RF Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by