File: submac.dem

package info (click to toggle)
maxima 5.21.1-2squeeze
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 94,928 kB
  • ctags: 43,849
  • sloc: lisp: 298,974; fortran: 14,666; perl: 14,325; tcl: 10,494; sh: 4,052; makefile: 2,975; ansic: 471; awk: 24; sed: 7
file content (20 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* Demo of macsyma substitution macros. */

if get('submac,'version)=false
then load('submac)$

/* define a macro to compute a numerical integration. 
   We want it to take an expression, a variable, and upper and
   lower limits. The expression will be evaluated for values
   of the variable between the upper and lower limits. */

rect_rule('exp,'x,a,b,dx)=>
 (modedeclare([a,b,dx],float),
  block([%_sum:0.0],modedeclare(%_sum,float),
        for x:a thru b step dx do %_sum:%_sum+exp,
	dx*%_sum))$

grind(rect_rule);

define(g(a),macroexpand(rect_rule(x^2,x,0.0,a,0.1)))$
grind(g);