Any suggestion for programming?



Hi all,

I want to use maxima to make a program, since I'd like
the code (what I input) can be saved, modified and
reutilized. What I have done is that: edit a file
"foo.mac", then batch("foo.mac"); in maxima
environment. The syntax in my file is very easy. The
following is a part of one of my code:

      c        : 3.0D10$
      e        : 4.803242D-10$
      m_e      : 9.109534D-28$
      m_p      : 1.6726485D-24$
      pi       : 3.14159265358979D0$
      \\sigma_T  : 6.652448D-25$

      A        : 3.D34*A_\{\*\,\-1\}$
      D        : 1.0D28*D_\{28\}$
      \\Delta_0  : 1.D12*\\Delta_\{0\,12\}$
      E_0      : 1.0D53*E_\{53\}$ 
      \\epsilon_B: 0.1D0*\\epsilon_\{B\,\-1\}$
      \\epsilon_e:
(10.D0^(-0.5D0))*\\epsilon_\{e\,\-0\.5\}$
      \\eta      : (10.D0^2.5D0)*\\eta_\{2\.5\}$
      \\gamma_4  : \\eta$ /*\\eta+1.D0$*/
      k        : 2.D0$
      p        : 2.5D0$
      \\nu       : 4.D14$
assume(A_\{\*\,\-1\}>0, D_\{28\}>0,
\\Delta_\{0\,12\}>0, E_\{53\}>0,
\\epsilon_\{B\,\-1\}>0, \\epsilon_\{e\,\-0\.5\}>0,
\\eta_\{2\.5\}>0,t_\{\\oplus\}>0,\\zeta_\{1\/3\}>0,p>0)$

/* approximation */
f        : E_0/(4*pi*m_p*c*c*\\eta*\\eta*\\Delta_0*A);
\\gamma_3  : sqrt(0.5)*sqrt(\\gamma_4)*sqrt(sqrt(f));
\\gamma_2  : \\gamma_3;
\\gamma_\{34\} : sqrt(0.5)*sqrt(\\gamma_4)/f^(1/4);
Sedov_L  : E_0/(4*pi*A*m_p*c*c);
r_\\Delta  : 0.5*sqrt(Sedov_L*\\Delta_0);
t_\\Delta  : r_\\Delta/(2*\\gamma_3^2*c);
t_num    : ev(RATCOEFF (t_\\Delta,
sqrt(\\Delta_\{0\,12\})*sqrt(E_\{53\})/sqrt
(A_\{\*\,\-1\})/\\eta_\{2\.5\}^2, 1),float);

system("rm f_early_RRS.tex ; echo
'\\documentclass{article}' >  f_early_RRS.tex; echo
'\\begin{document}' >> f_early_RRS.tex"); /*remove the
file 'f_early_RRS.tex' first.*/

...

print("3. slow cooling, \\nu_m < \\nu_c < \\nu_a");
f2s31 :
f_\{\\nu\,\\max\,2\}*(\\nu_c/\\nu_\{m\,2\})^(-(p-1)/2)
*(\\nu_\{a\,2s3\}/\\nu_c)^(-p/2)*\\nu_\{m\,2\}^(1/2)*
\\nu_\{a\,2s3\}^(-5/2)*\\nu^(2)$ radcan(%)$ float(%);
tex(%,"f_early_RRS.tex");
f2s32 : f_\{\\nu\,\\max\,2\}*(\\nu_c/\\nu_\{m\,2\})
^(-(p-1)/2)*(\\nu_\{a\,2s3\}/\\nu_c)^(-p/2)*
\\nu_\{a\,2s3\}^(-5/2)*\\nu^(5/2)$ radcan(%)$ 
float(%); tex(%,"f_early_RRS.tex");
f2s33 : f_\{\\nu\,\\max\,2\}*(\\nu_c/\\nu_\{m\,2\})
^(-(p-1)/2)*(\\nu_\{a\,2s3\}/\\nu_c)^(-p/2)*
\\nu_\{a\,2s3\}^(p/2)*\\nu^(-p/2)$ radcan(%)$ 
float(%); tex(%,"f_early_RRS.tex");

...

system("echo '\\end{document}' >> f_early_RRS.tex");

OVER

I also want maxima output a tex file, which I can read
easily. So there are many '\\' in the code.

My dear friend, are there any better way to do that? 

In fact, the upper sentences in the code are very
simple. What should do, if the syntax is a little
complicated, like 'loop', 'if'? 

e.g. How to deal with a case in fortran like:

do ...
...
enddo

if(...)then
...
elseif(...)then 
...
endif
. 
And many things should to be done in the '...'.

BTW, I think one 'block' or 'ev' should not contain
too many commands.

Best Regards,

Zou Yuan-Chuan

_________________________________________________________
Do You Yahoo!?
150ÍòÇúMP3·è¿ñËÑ£¬´øÄú´³ÈëÒôÀÖµîÌÃ
http://music.yisou.com/
ÃÀÅ®Ã÷ÐÇÓ¦Óо¡ÓУ¬ËѱéÃÀͼ¡¢ÑÞͼºÍ¿áͼ
http://image.yisou.com
1G¾ÍÊÇ1000Õ×£¬ÑÅ»¢µçÓÊ×ÔÖúÀ©ÈÝ£¡
http://cn.rd.yahoo.com/mail_cn/tag/1g/*http://cn.mail.yahoo.com/event/mail_1g/