Q: compiling causes problems in evaluating functions?



Robert,

I cannot reproduce this problem using either the current development version
on Linux, or 5.9.2 on Windows:


(%i1) A_N:1e+21;
(%o1)                               1.0E+21
(%i2) B_N:30;
(%o2)                                 30
(%i3) T_C:264;
(%o3)                                 264
(%i4) eq4_7_(T, _p) :=  (A_N / sqrt(2.0 * %pi * B_N * B_N)) *
                   exp(-0.5 * ((T - T_C) / B_N)^2 );
                                  A_N                       T - T_C 2
(%o4)   eq4_7_(T, _p) := --------------------- exp((- 0.5) (-------) )
                         sqrt(2.0 %pi B_N B_N)                B_N
(%i5) eq4_7_(xx,yy);
                                                                    2
                                  - 5.5555555555555556E-4 (xx - 264)
         2.3570226039551582E+19 %e
(%o5)    ------------------------------------------------------------
                                  sqrt(%pi)
(%i6) compile(eq4_7_);

Warning-> A_N is an undefined global variable.
Warning-> B_N is an undefined global variable.
Warning-> T_C is an undefined global variable.
Compiling gazonk0.lsp.
End of Pass 1.  
End of Pass 2.  
OPTIMIZE levels: Safety=2, Space=3, Speed=3
Finished compiling gazonk0.lsp.
(%o6)                              [eq4_7_]
(%i7) eq4_7_(xx,yy);
                                                                    2
                                  - 5.5555555555555556E-4 (xx - 264)
         2.3570226039551582E+19 %e
(%o7)    ------------------------------------------------------------
                                  sqrt(%pi)





Viktor



-----Original Message-----
From: maxima-bounces at math.utexas.edu [mailto:maxima-bounces at math.utexas.edu]
On Behalf Of Robert Gloeckner
Sent: Sunday, April 22, 2007 6:54 PM
To: maxima at math.utexas.edu
Subject: Q: compiling causes problems in evaluating functions?

Hello,

I really hope this is my fault...
[maxima 5.9.10 on Linux]

my code:
--------------------------------
A_N:1e+21;
B_N:30;
T_C:264;
eq4_7_(T, _p) :=  (A_N / sqrt(2.0 * %pi * B_N * B_N)) *
                   exp(-0.5 * ((T - T_C) / B_N)^2 );
---------------------------------


(%i95) eq4_7_(T, _p)      :=  (A_N / sqrt( 2.0 * %pi * B_N * B_N)) *
exp(-0.5 * ((T - T_C) / B_N)^2 );

				  A_N			    T - T_C 2
(%o95)  eq4_7_(T, _p) := --------------------- exp((- 0.5) (-------) )
			 sqrt(2.0 %pi B_N B_N)		      B_N
(%i96) eq4_7_(xx,yy);

								   2
				  - 5.555555555555556E-4 (xx - 264)
	  2.357022603955158E+19 %e
(%o96) 	  ----------------------------------------------------------
				  sqrt(%pi)
(%i97) compile(eq4_7_);

Compiling gazonk0.lsp.
End of Pass 1.
End of Pass 2.
OPTIMIZE levels: Safety=2, Space=3, Speed=2
Finished compiling gazonk0.lsp.
(%o97) 				   [eq4_7_]
(%i98) eq4_7_(xx,yy);

(%o98)
	
2
			  - 5.555555555555556E-4 (xx -
2.121995921398603E-314)
  2.357022603955158E+19 %e

----------------------------------------------------------------------------
-
				    sqrt(%pi)
(%i99)


How can that be? I need to use compile, because otherwise evaluation
functions (numerical integration) take much too long. What is the
problem in this case?
Can somebody verify this behaviour?
If it is a bug - is this fixed in more recent versions of maxima?

Thanks
Robert
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima