- #1
iFargle
- 7
- 0
Here's what I have
This outputs to something like this
Okay, that's all fine and dandy. But what I want to do in addition to this is add a plot of the summations for i intervals for the function f. This, normally, can be achieved by using this: rightbox(f,x=0..1,i) over the interval x=0 to x=1 for the function f with i intervals. This will output something that looks like this:
This specific picture graphs the line 3x^2 as well as the Riemann Sum from 0 to 1 using four sub-intervals and the right endpoints of the graph.
Code:
[COLOR="red"]>Integral:=proc(f,i)
local JExact,S,R,E;
JExact:=int(f,x=0..1);
S:=rightsum(f,x=0..1,i);
R:=evalf(%);
E:=evalf(abs(JExact-R));
RETURN(
[Integral]=JExact,
[Right_Sum]=S,
[Right_Sum_Eval]=R,
[Error]=E
);
end;[/COLOR]
[COLOR="#4169e1"]Integral := proc (f, i) local JExact, S, R, E, pl; JExact := int(f, x = 0 .. 1); S := rightsum(f, x = 0 .. 1, i); R := evalf(%); E := evalf(abs(JExact-R)); rightbox(f, x = 0 .. 1, i); RETURN([Integral] = JExact, [Right_Sum] = S, [Right_Sum_Eval] = R, [Error] = E) end proc[/COLOR]
This outputs to something like this
Code:
[COLOR="red"]>Integral(3*x^2,4);[/COLOR]
[COLOR="#4169e1"][Integral] = 1, [Right_Sum] = (1/4)*(Sum((3/16)*j^2, j = 1 .. 4)), [Right_Sum_Eval] = 1.406250000, [Error] = .406250000[/COLOR]
Okay, that's all fine and dandy. But what I want to do in addition to this is add a plot of the summations for i intervals for the function f. This, normally, can be achieved by using this: rightbox(f,x=0..1,i) over the interval x=0 to x=1 for the function f with i intervals. This will output something that looks like this:
This specific picture graphs the line 3x^2 as well as the Riemann Sum from 0 to 1 using four sub-intervals and the right endpoints of the graph.
[PLAIN]http://dl.dropbox.com/u/6723871/rightbox.png[/CENTER]
Now my question is.. How would I integrate this rightbox command into my Integral procedure? I've tried just about every combination I can think of, and the help files that came with Maple aren't any help. All it does is spit out a list of ordered pairs. I'm hoping someone here might know what to do. Thanks for any assistance.
To further clarify, I want it to output the integral of the expression, the Riemann Sum for i sub intervals, and the error associated with the number of sub-intervals and the actual integral over the interval [0,1] as well as the graph generated by the rightbox command.
Now my question is.. How would I integrate this rightbox command into my Integral procedure? I've tried just about every combination I can think of, and the help files that came with Maple aren't any help. All it does is spit out a list of ordered pairs. I'm hoping someone here might know what to do. Thanks for any assistance.
To further clarify, I want it to output the integral of the expression, the Riemann Sum for i sub intervals, and the error associated with the number of sub-intervals and the actual integral over the interval [0,1] as well as the graph generated by the rightbox command.
Last edited by a moderator: