Maple [Maple 14] rightbox in a procedure?

  • Thread starter Thread starter iFargle
  • Start date Start date
  • Tags Tags
    Procedure
AI Thread Summary
The discussion revolves around integrating the rightbox command into a Maple procedure for calculating integrals and Riemann sums. The user has created a procedure that computes the exact integral, the right Riemann sum, and the associated error, but seeks to include a plot generated by the rightbox command. They express frustration with the output, which only returns a list of ordered pairs instead of the desired graphical representation. The goal is to have the procedure output the integral, Riemann sum, error, and a visual graph of the summation for a given function over specified intervals. Assistance is requested to achieve this integration effectively.
iFargle
Messages
7
Reaction score
0
Here's what I have
Code:
>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;

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

This outputs to something like this

Code:
>Integral(3*x^2,4);
[Integral] = 1, [Right_Sum] = (1/4)*(Sum((3/16)*j^2, j = 1 .. 4)), [Right_Sum_Eval] = 1.406250000, [Error] = .406250000

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.​
 
Last edited by a moderator:
Physics news on Phys.org
Bump?
 

Similar threads

Back
Top