error with find_root when functions containing more than one built-in constant like %pi
Subject: error with find_root when functions containing more than one built-in constant like %pi
From: Bob Jerrard
Date: Thu, 25 Jan 2007 09:31:14 -0700
Hello, I tried find_root with a function containing %e and %pi and it
produced only an error. Replacing the constants with approximate
numerical values allows a solution:
Maxima 5.10.0 http://maxima.sourceforge.net
Using Lisp GNU Common Lisp (GCL) GCL 2.6.7 (aka GCL)
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) f(x):=-(log((4+%e)/(2*%pi)))*(((4+%e)/(2*%pi))^x);
4 + %e 4 + %e x
(%o1) f(x) := (- log(------)) (------)
2 %pi 2 %pi
(%i2) find_root(2*x=f(x),x,-1.0,0.0);
Maxima encountered a Lisp error:
Error in MACSYMA-TOP-LEVEL [or a callee]: ((MPLUS SIMP) -2.0
((MTIMES SIMP)
6.2831853071795862
((MEXPT SIMP)
((MPLUS SIMP) 4 $%E)
-1.0)
((%LOG SIMP)
((MTIMES SIMP)
0.15915494309189535
((MPLUS SIMP) 4 $%E)))))
is not of type (OR
RATIONAL
LISP:FLOAT).
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i3) f(x):=-(log((4+2.71828)/(2*3.14159)))*(((4
+2.71828)/(2*3.14159))^x);
4 + 2.71828 4 + 2.71828 x
(%o3) f(x) := (- log(-----------)) (-----------)
2 3.14159 2 3.14159
(%i4) find_root(2*x=f(x),x,-1.0,0.0);
(%o4) - 0.033403182605785
(%i5) g(x):=sin(%pi*x);
(%o5) g(x) := sin(%pi x)
(%i6) find_root(2*x=g(x),x,0.0,1.0);
(%o6) 0.0
(%i7) g(x):=cos(%pi*x);
(%o7) g(x) := cos(%pi x)
(%i8) find_root(2*x=g(x),x,0.0,1.0);
(%o8) 0.29730582202842
(%i9)g(x):=cos((%e+%pi)*x);
(%o9) g(x) := cos((%e + %pi) x)
(%i10) find_root(2*x=g(x),x,0.0,1.0);
Maxima encountered a Lisp error:
Error in MACSYMA-TOP-LEVEL [or a callee]: ((MPLUS SIMP) 2.0
((MTIMES SIMP) -1
((%COS SIMP)
((MTIMES SIMP) 1.0
((MPLUS SIMP)
3.1415926535897931 $%
E))))) is not of type (OR
RATIONAL
LISP:FLOAT).
Automatically continuing.
To reenable the Lisp debugger set *debugger-hook* to nil.
(%i11) g(x):=cos(%e*x);
(%o11) g(x) := cos(%e x)
(%i12) find_root(2*x=g(x),x,0.0,1.0);
(%o12) 0.32121095788978
(%i13)
Any ideas why it does not work for functions with more than one
constant?
Thanks for any help.
--
Dr. Robert J. Jerrard, Professor of Mathematics,
Concordia University College of Alberta,
7128 Ada Blvd., Edmonton, Alberta, T5B 4E4, Canada.
Phone: (780) 479-9291, Fax: (780) 474-1933.