File: submac.dem

package info (click to toggle)
maxima 5.49.0%2Bdsfg-2
  • links: PTS
  • area: main
  • in suites: forky
  • size: 128,932 kB
  • sloc: lisp: 437,845; fortran: 14,665; tcl: 10,143; sh: 4,598; makefile: 2,206; ansic: 447; java: 374; python: 262; perl: 201; xml: 60; awk: 28; sed: 15; javascript: 2
file content (20 lines) | stat: -rw-r--r-- 587 bytes parent folder | download | duplicates (17)
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);