newbie, solving an equation numerically



On Thu, Nov 30, 2006 at 09:42:17PM +0100, Hugo Coolens wrote:
> Is find_root a separate package? Where can I find it?
> 
> I'll try it out on my system and tell you what the result is

find_root is standard as of fairly recently. It used to be called
"interpolate" but that was deemed confusing so it was renamed about a
year ago I think. It's in the docs. It does a binary search followed
by newton's method when it gets close enough.

However, it seems to have a bug of sorts. Does anyone else see the
behavior that I see? I confirmed it at home on linux as well as on
windows at work.

-----Transcript------

Maxima 5.10.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)


(%i1) h1(s):=1/(1+tau[1]*s);
h2(s):=1/(1+tau[2]*s);
x(s):=1/s;
tau[1]:33e-6;
tau[2]:33e-6;
eqn:first(solve(ilt(h1(s)*h2(s)*x(s),s,t)=0.1,t));
					   1
(%o1) 			      h1(s) := ----------
				       1 + tau  s
					      1
(%i2) 					   1
(%o2) 			      h2(s) := ----------
				       1 + tau  s
					      2
(%i3) 					   1
(%o3) 				   x(s) := -
					   s
(%i4) (%o4) 			     3.2999999999999996E-5
(%i5) (%o5) 			     3.2999999999999996E-5
(%i6) 
`rat' replaced 3.2999999999999996E-5 by 33//1000000 = 3.3000000000000003E-5

`rat' replaced 0.9 by 9//10 = 0.9
				     1000000 t
				     ---------
					33
			       297 %e	       - 330
(%o6) 			   t = ---------------------
				     10000000
(%i7) find_root(%,t,0,2);

Maxima encountered a Lisp error:

 Error in MACSYMA-TOP-LEVEL [or a callee]: ((MEQUAL SIMP) $T
                                            ((MTIMES SIMP)
                                             ((RAT SIMP) 1 10000000)
                                             ((MPLUS SIMP) -330
                                              ((MTIMES SIMP) 297
                                               ((MEXPT SIMP) $%E
                                                ((MTIMES SIMP)
                                                 ((RAT SIMP) 1000000
                                                  33)
                                                 $T)))))) is not of type (OR
                                                                          RATIONAL
                                                                          LISP:FLOAT).

Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i8) 

-- 
Daniel Lakeland
dlakelan at street-artists.org
http://www.street-artists.org/~dlakelan