From maintainers-request at octave dot org Mon Feb 7 03:18:53 2005 Subject: Re: fsolve Patch for Function Handles From: David Bateman To: Todd Neal Cc: maintainers at octave dot org Date: Mon, 07 Feb 2005 10:20:42 +0100 Todd Neal wrote: >I was looking at the following page http://www.mathworks.com/access/helpdesk/help/toolbox/optim/fsolve.html >and couldn't get this example to work in Octave: > > >octave:1> x0=2 >x0 = 2 >octave:2> x = fsolve( at (x)sin(x dot *x),x0) >error: value on right hand side of assignment is undefined >error: evaluating assignment expression near line 2, column 3 > > >I checked and fsolve was not handling parameters that were function >handles correctly, I modified it and it seems to work fine. > >octave:1> x0=2 >x0 = 2 >octave:2> x = fsolve( at (x)sin(x dot *x),x0) >x = 1.7725 > > >I haven't looked at the code to Octave much in depth so there may >be a better way to do this or other repercussions from this patch. > >Todd > > > Todd, The problem is that how do you treat the jacobian that can also be passed to fsolve. I have a patch to do exactly what you want that was against 2.1.57, and also treats the other functions that this concerning like daspk, etc. I can't remember the exact details, but the problem was something like the underlying code used a single function to return the function evaluationsand the jacobian. However the top-level interface defined in matlab separates these. The result is that you either take a factor of two speed penalty and calculate both values when you only need one, or you write a lot of ugly caching code.... In any case, I wasn't happy with the resulting patch, JWE wasn't happy with it and didn't accept it, and the patch has therefore just stayed in my todo pile for the last 8 months. The right way to treat this is the entriely rework the octave ODE code for scratch, probably dumping all of the existing fortran code on which it is currently based.. But who wants to do that... I'll send you my patch separately, so that you can look at it and see the amplitude of the problem. Who knows perhaps you can suggest a neater fix than the one I proposed.. regards D. -- David Bateman David dot Bateman at motorola dot com Motorola Labs - Paris +33 1 69 35 48 04 (Ph) Parc Les Algorithmes, Commune de St Aubin +33 1 69 35 77 01 (Fax) 91193 Gif-Sur-Yvette FRANCE The information contained in this communication has been classified as: [x] General Business Information [ ] Motorola Internal Use Only [ ] Motorola Confidential Proprietary