1 /* Demo of macsyma substitution macros. */
3 eval_when([translate,batch,demo],
4 if get('sharem,'version) = false
5 then loadfile(autolo,fasl,dsk,sharem))$
7 /* define a macro to compute a numerical integration.
8 We want it to take an expression, a variable, and upper and
9 lower limits. The expression will be evaluated for values
10 of the variable between the upper and lower limits. */
12 rect_rule('exp,'x,a,b,dx)=>
13 (modedeclare([a,b,dx],float),
14 block([%_sum:0.0],modedeclare(%_sum,float),
15 for x:a thru b step dx do %_sum:%_sum+exp,
20 define(g(a),macroexpand(rect_rule(x^2,x,0.0,a,0.1)))$