octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fsolve test failure


From: Ben Abbott
Subject: Re: fsolve test failure
Date: Tue, 27 Jan 2009 16:31:50 -0500

On Tuesday, January 27, 2009, at 03:18PM, "Jaroslav Hajek" <address@hidden> 
wrote:
>On Tue, Jan 27, 2009 at 9:10 PM, Ben Abbott <address@hidden> wrote:
>>
>> On Tuesday, January 27, 2009, at 02:57PM, "Jaroslav Hajek" <address@hidden> 
>> wrote:
>>>On Tue, Jan 27, 2009 at 5:31 PM, John W. Eaton <address@hidden> wrote:
>>>> After updating and rebuilding today, the following test is failing for
>>>> me:
>>>>
>>>>  function retval = f (p)
>>>>    x = p(1);
>>>>    y = p(2);
>>>>    z = p(3);
>>>>    w = p(4);
>>>>    retval = zeros (4, 1);
>>>>    retval(1) = 3*x + 4*y + exp (z + w) - 1.007;
>>>>    retval(2) = 6*x - 4*y + exp (3*z + w) - 11;
>>>>    retval(3) = x^4 - 4*y^2 + 6*z - 8*w - 20;
>>>>    retval(4) = x^2 + 2*y^3 + z - w - 4;
>>>>  endfunction
>>>>
>>>>  test
>>>>   x_opt = [ -0.767297326653401, 0.590671081117440, 1.47190018629642, 
>>>> -1.52719341133957 ];
>>>>   tol = 1.0e-5;
>>>>   [x, fval, info] = fsolve (@f, [-1, 1, 2, -1]);
>>>>   assert (info > 0);
>>>>   assert (norm (x - x_opt, Inf) < tol);
>>>>   assert (norm (fval) < tol);
>>>>
>>>>  octave> info
>>>>  info =  1
>>>>  octave> norm (x - x_opt, Inf), tol
>>>>  ans =  1.6079e-05
>>>>  tol =  1.0000e-05
>>>>  octave> norm (fval), tol
>>>>  ans =  1.0665e-04
>>>>  tol =  1.0000e-05
>>>>
>>>
>>>That's weird, because I get something different:
>>>octave:5> info
>>>info =  1
>>>octave:6> norm(x-x_opt, Inf)
>>>ans =  4.1002e-07
>>>octave:7> norm (fval)
>>>ans =  3.4606e-06
>>>
>>>Do you have qrupdate linked to Octave? That could maybe explain the
>>>differences...
>>>otherwise, we can check per line where the numbers start diverting.
>>
>> I do not have qrupdate, but get something slightly smaller than did jwe.
>>
>> octave> norm (x - x_opt, Inf)
>> ans = 1.5482e-4
>>
>> Would it be helpful for me to deeper to determine why the optimization 
>> terminated?
>>
>> Ben
>>
>
>Definitely. First of all, I suggest you try running with
>optimset("Updating", "off").
>In fact, I realize that for such small systems qrupdate is not even
>used, so I don't understand where the differences come from. Perhaps
>displaying the sequence of x could shed some light here...
>
>cheers

Ok, I created a f.m file and copied the test function f() to it. I then placed 
the following in test_fsolve.m. I also modified fsolve to display niter, 
maxiter, nfev, naxfev, and info when the outer loop terminates.

optimset ("Updating", "off");
x_opt = [ -0.767297326653401, 0.590671081117440, 1.47190018629642, 
-1.52719341133957 ];
tol = 1.0e-5;
[x, fval, info, output, fjac] = fsolve (@f, [-1, 1, 2, -1]);
assert (info > 0);
assert (norm (fval), 0, tol);
assert (norm (x - x_opt, Inf), 0, tol);

When I run it I get the result below.

octave:7> test_fsolve
niter =  44
maxiter =  400
nfev =  96
maxfev = Inf
info =  1
x =

  -0.76726   0.59064   1.47190  -1.52720

fval =

   1.3495e-07
  -2.5856e-06
   9.9090e-05
  -1.1893e-04

info =  1
output =
{
  iterations =  44
  funcCount =  96
}

fjac =

    3.00172    3.99956    0.93820    0.94125
    6.12890   -4.04019   55.04481   18.56031
   -2.37122   -5.88633   -6.65752  -14.65200
   -2.29959    3.16654    9.20376    4.21261

error: assert (norm (fval),0,tol) expected
0
but got
 1.5482e-04
maximum absolute error 0.000154825 exceeds tolerance 1e-05

Comparing against the outer loop

while (niter < maxiter && nfev < maxfev && ! info)

... I have no idea why the loop terminated.

Ben





reply via email to

[Prev in Thread] Current Thread [Next in Thread]