13 // evaluate 1st arg to get function F
19 // evaluate 2nd arg and then...
21 // example result of 2nd arg what to do
23 // integral(f) nil guess X, N = nil
24 // integral(f,2) 2 guess X, N = 2
25 // integral(f,x) x X = x, N = nil
26 // integral(f,x,2) x X = x, N = 2
27 // integral(f,x,y) x X = x, N = y
34 if (p2
== symbol(NIL
)) {
37 } else if (isnum(p2
)) {
53 // N might be a symbol instead of a number
58 if (n
== (int) 0x80000000)
59 stop("nth integral: check n");
66 for (i
= 0; i
< n
; i
++) {
72 for (i
= 0; i
< n
; i
++) {
80 // if N is nil then arglist is exhausted
90 // number number N = arg1, continue
91 // number symbol X = arg1, N = arg2, continue
93 // symbol nil X = N, N = nil, continue
94 // symbol number X = N, N = arg1, continue
95 // symbol symbol X = N, N = arg1, continue
102 if (N
== symbol(NIL
))
103 break; // arglist exhausted
111 N
= pop(); // N = arg2
118 N
= pop(); // N = arg1
122 push(F
); // final result
131 if (car(p1
) == symbol(ADD
))
133 else if (car(p1
) == symbol(MULTIPLY
))
134 integral_of_product();
138 if (find(p1
, symbol(INTEGRAL
)))
139 stop("integral: sorry, could not find a solution");
141 simplify(); // polish the result
142 eval(); // normalize the result
147 integral_of_sum(void)
164 integral_of_product(void)
169 p1
= pop(); // pop variable part
171 multiply(); // multiply constant part
177 integral_of_form(void)
183 if (p3
== symbol(NIL
)) {
184 push_symbol(INTEGRAL
);