octave-maintainers
[Top][All Lists]
Advanced

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

fsolve regression


From: John W. Eaton
Subject: fsolve regression
Date: Fri, 20 Feb 2009 13:18:08 -0500

The following script shows a problem with the new fsolve.  It doesn't
seem to terminate for me (I interrupted it after several minutes).
After looking closer at the values passed to the "inflate" function,
it appears to be cycling among a few input values.

The initial guess and expected result are

  z0 =

     0.133000000000000
     0.325115654084158

  z =

     0.134806285287651
     0.323387263653996


so the initial guess is fairly good.

jwe


load foo.dat

more off

global K1 K2 P ext0 Gval dels unk zlast

function retval = G (var)
  global K1 K2 P Gval ext0 unk
  w = ext0;
  w(unk) = var;
  x = w(1);
  y = w(2);
  z = 0.5 - x - y;
  p = 0.5 + z;
  if (x == 0)
    xlogx = 0;
  else
    xlogx = abs(x)*log(abs(x/p));
  endif
  if (y == 0)
    ylogy = 0;
  else
    ylogy = abs(y)*log(abs(y/p));
  endif
  if (z == 0)
    zlogz = 0;
  else
    zlogz = abs(z)*log(abs(z/p));
  endif
  retval = -Gval -(x*log(K1) + y*log(K2)) + p*log(P) + 2*zlogz + xlogx + ylogy;
endfunction

function retval = inflate (z)
  global zlast dels
  retval = [G(z); norm(z-zlast) - dels^2];
endfunction

[z, fval, info] = fsolve (@inflate, z0);

format long
z0
z

Attachment: foo.dat
Description: Binary data


reply via email to

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