[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: fsolve test failure
From: |
Jaroslav Hajek |
Subject: |
Re: fsolve test failure |
Date: |
Tue, 27 Jan 2009 20:57:34 +0100 |
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'm not sure, but it looks like this line
>
> ## Replace fun with a guarded version.
> fun = @(x) guarded_eval (fun, x);
>
> should be
>
> ## Replace fun with a guarded version.
> fcn = @(x) guarded_eval (fcn, x);
>
> as fun is not defined before this point, or used after it.
>
OK, of course.
> Also, in the default settings section
>
> x = optimset ("MaxIter", 400, "MaxFunEvals", Inf, \
> "Jacobian", "off", "TolX", 1e-7, "TolF", 1e-7,
> "OutputFcn", [], "Updating", "on", "FunValCheck", "off");
> return;
>
> wouldn't it be better to set the default tolerances based on something
> like sqrt (eps (class (x))? Or, if fsolve should still work when
> passed integer matrices, maybe something like
>
> if (isa (x, "single"))
> tol = sqrt (eps, "single");
> else
> tol = sqrt (eps);
> endif
>
Originally, I used default settings exactly like this. However, I was
not sure how to reflect this in the default options, so I changed it
to fixed tolerances. If you have a better idea...
cheers
--
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz
- fsolve test failure, John W. Eaton, 2009/01/27
- Re: fsolve test failure,
Jaroslav Hajek <=
- Re: fsolve test failure, Ben Abbott, 2009/01/27
- Re: fsolve test failure, Jaroslav Hajek, 2009/01/27
- Re: fsolve test failure, John W. Eaton, 2009/01/27
- Message not available
- Re: fsolve test failure, John W. Eaton, 2009/01/29
- Re: fsolve test failure, Jaroslav Hajek, 2009/01/29
- Re: fsolve test failure, John W. Eaton, 2009/01/29
- Re: fsolve test failure, Jaroslav Hajek, 2009/01/29
- Re: fsolve test failure, John W. Eaton, 2009/01/29
- Re: fsolve test failure, Jaroslav Hajek, 2009/01/29
- Re: fsolve test failure, John W. Eaton, 2009/01/29