Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
fsolve with Jacobian problem

Subject: fsolve with Jacobian problem

From: Anna

Date: 10 Feb, 2014 08:48:07

Message: 1 of 2

Hi,
i am solving the system of equations with fsolve and i wanted to see if passing the Jacobian in the parameters would speed up the calculation or give me better precision. However when i pass Jacobian solver gets stuck, function value doesnt get updated and solver finds no solution.

The following output without passing Jacobian
options.Algorithm = 'trust-region-reflective';
options.Jacobian = 'off';
                                         Norm of First-order
 Iteration Func-count f(x) step optimality CG-iterations
     0 4 0.163213 0.0728
     1 8 0.163213 10 0.0728 0
     2 12 0.138438 2.5 0.014 0
     3 16 0.0566581 5 0.231 0
     4 20 0.0167072 5.80274 0.158 0
     5 24 0.000309366 2.19373 0.0191 0
     6 28 3.74928e-07 0.474266 0.000655 0
     7 32 5.99238e-13 0.0168359 8.27e-07 0

Equation solved.


The following output is when i pass Jacobian to fsolve
options.Algorithm = 'trust-region-reflective';
options.Jacobian = 'on';


                                         Norm of First-order
 Iteration Func-count f(x) step optimality CG-iterations
     0 1 0.163213 0.0728
     1 2 0.163213 10 0.0728 0
     2 3 0.163213 2.5 0.0728 0
     3 4 0.163213 0.625 0.0728 0
     4 5 0.163213 0.15625 0.0728 0
     5 6 0.163213 0.0390625 0.0728 0
     6 7 0.163213 0.00976562 0.0728 0
     7 8 0.163213 0.00244141 0.0728 0
     8 9 0.163213 0.000610352 0.0728 0
     9 10 0.163213 0.000152588 0.0728 0
    10 11 0.163213 3.8147e-05 0.0728 0
    11 12 0.163213 9.53674e-06 0.0728 0
    12 13 0.163213 2.38419e-06 0.0728 0
    13 14 0.163213 5.96046e-07 0.0728 0

No solution found.

fsolve stopped because the size of the current step is less than the
selected value of the step size tolerance, but the vector of function values
is not near zero as measured by the selected value of the function tolerance.

Can you kindly suggest what could i be possibly be doing wrong?
Im confident that Jacobian function i pass is correct. Is it some setting that i missed out?
Thank you

Subject: fsolve with Jacobian problem

From: Torsten

Date: 10 Feb, 2014 09:26:08

Message: 2 of 2

"Anna" wrote in message <lda3o7$63h$1@newscl01ah.mathworks.com>...
> Hi,
> i am solving the system of equations with fsolve and i wanted to see if passing the Jacobian in the parameters would speed up the calculation or give me better precision. However when i pass Jacobian solver gets stuck, function value doesnt get updated and solver finds no solution.
>
> The following output without passing Jacobian
> options.Algorithm = 'trust-region-reflective';
> options.Jacobian = 'off';
> Norm of First-order
> Iteration Func-count f(x) step optimality CG-iterations
> 0 4 0.163213 0.0728
> 1 8 0.163213 10 0.0728 0
> 2 12 0.138438 2.5 0.014 0
> 3 16 0.0566581 5 0.231 0
> 4 20 0.0167072 5.80274 0.158 0
> 5 24 0.000309366 2.19373 0.0191 0
> 6 28 3.74928e-07 0.474266 0.000655 0
> 7 32 5.99238e-13 0.0168359 8.27e-07 0
>
> Equation solved.
>
>
> The following output is when i pass Jacobian to fsolve
> options.Algorithm = 'trust-region-reflective';
> options.Jacobian = 'on';
>
>
> Norm of First-order
> Iteration Func-count f(x) step optimality CG-iterations
> 0 1 0.163213 0.0728
> 1 2 0.163213 10 0.0728 0
> 2 3 0.163213 2.5 0.0728 0
> 3 4 0.163213 0.625 0.0728 0
> 4 5 0.163213 0.15625 0.0728 0
> 5 6 0.163213 0.0390625 0.0728 0
> 6 7 0.163213 0.00976562 0.0728 0
> 7 8 0.163213 0.00244141 0.0728 0
> 8 9 0.163213 0.000610352 0.0728 0
> 9 10 0.163213 0.000152588 0.0728 0
> 10 11 0.163213 3.8147e-05 0.0728 0
> 11 12 0.163213 9.53674e-06 0.0728 0
> 12 13 0.163213 2.38419e-06 0.0728 0
> 13 14 0.163213 5.96046e-07 0.0728 0
>
> No solution found.
>
> fsolve stopped because the size of the current step is less than the
> selected value of the step size tolerance, but the vector of function values
> is not near zero as measured by the selected value of the function tolerance.
>
> Can you kindly suggest what could i be possibly be doing wrong?
> Im confident that Jacobian function i pass is correct. Is it some setting that i missed out?
> Thank you

Did you try to switch on the DerivativeCheck ?

Best wishes
Torsten.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us