Robert Dodier a écrit :
> 2009/5/6 moky <[email protected]>:
>
>   
>> (%i1) load(mnewton);
>> (%o1)         /usr/share/maxima/5.13.0/share/contrib/mnewton.mac
>> (%i2) mnewton([6*cos(2*x)-2*sin(2*x)],[x],[0.0]);
>>     
>
> Since there is just one variable, you can try find_root instead of mnewton:
>
> find_root (6*cos(2*x)-2*sin(2*x), x, 3, 4);
>  => 3.76611553978892
>
>   
Yep, I was thinking about that, but I need to furnish to Maxima two 
bound values where I'm sure that f(x) have different signs.
That constraint does not fit my problem.
My situation is to use Maxima as background of a script in Python which 
produces pstricks figures for documents LaTeX. I need to know what are 
the max and min values of a function over an interval (among others, to 
compute the bounding box), but I don't know the function _a priori_. The 
one I'm giving here is an example.

What I'm doing is to solve f'(x)=0 using mnewton.
Roughly :

for x0 in range(Xmin,Xmas) by step of 0.1 :
   mnewton( [f(x)],[x],[x0] )

Any other way to get a list of max/min of a function are much welcome.

>> Load failed for
>> /usr/share/maxima/5.13.0/share/linearalgebra/load-linearalgebra-lisp-files.lisp
>>     
>
> To get more information you can try:
>
> :lisp (load 
> "/usr/share/maxima/5.13.0/share/linearalgebra/load-linearalgebra-lisp-files.lisp")
>
> which should print a more specific error message.
>   
I'm not sure that it is more specific :

%i1) debugmode(true);
(%o1)                                true
(%i2) load(mnewton);
(%o2)         /usr/share/maxima/5.13.0/share/contrib/mnewton.mac
(%i3) :lisp (load 
"/usr/share/maxima/5.13.0/share/linearalgebra/load-linearalgebra-lisp-files.lisp");

Bad file spec: ?\/usr\/share\/maxima\/5\.13\.0\/share\/lbfgs\/\#\#\#\.lisp
 -- an error.  Entering the Maxima Debugger dbm
Enter `:h' for help
(dbm:1)


At that point, I just ask to exit the debug mode, and the mnewton works :

(%i3) mnewton([6*cos(2*x)-2*sin(2*x)],[x],[0.0]);
(%o3)                      [[x = 3.76611553978892]]

In fact, the error is not that deep : I just have to re-ask the same 
computation in order to have the result :

(%i1) load(mnewton);
(%o1)         /usr/share/maxima/5.13.0/share/contrib/mnewton.mac
(%i2) mnewton([6*cos(2*x)-2*sin(2*x)],[x],[0.0]);

Load failed for 
/usr/share/maxima/5.13.0/share/linearalgebra/load-linearalgebra-lisp-files.lisp
#0: 
solve_by_lu(eqs=[6.0-4.0*h[1]],vars=[h[1]],field=complexfield)(linearalgebra.mac
 
line 35)
#1: 
mnewton(funclist=[6*cos(2*x)-2*sin(2*x)],varlist=[x],guesslist=[0.0])(mnewton.mac
 
line 106)
 -- an error.  To debug this try debugmode(true);
(%i3) mnewton([6*cos(2*x)-2*sin(2*x)],[x],[0.0]);
(%o3)                      [[x = 3.76611553978892]]


In wxMaxima :
(%i4) load(mnewton);
(%o4) /usr/share/maxima/5.13.0/share/contrib/mnewton.mac
(%i5) mnewton([6*cos(2*x)-2*sin(2*x)],[x],[0.0]);
Maxima encountered a Lisp error: Error in PROGN [or a callee]: Couldn't 
protectAutomatically continuing.To reenable the Lisp debugger set 
*debugger-hook* to nil.
(%i6) mnewton([6*cos(2*x)-2*sin(2*x)],[x],[0.0]);
(%o6) [[x=3.76611553978892]]


The problem is not really in mnewton, but it seems that Maxima wants to 
first argue my authority, and then submit :'(


> Sorry for writing in English, I can't write in French. Hope this helps!
>   
You're welcome :)



Have a good afternoon
Laurent


------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image 
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Maxima-lang-fr mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-lang-fr

Répondre à