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