File: submac.dem

package info (click to toggle)
maxima 5.9.1-9
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 32,272 kB
  • ctags: 14,123
  • sloc: lisp: 145,126; fortran: 14,031; tcl: 10,052; sh: 3,313; perl: 1,766; makefile: 1,748; ansic: 471; awk: 7
file content (20 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (2)
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);