[Maple 14] rightbox in a procedure?

  • Context: Maple 
  • Thread starter Thread starter iFargle
  • Start date Start date
  • Tags Tags
    Procedure
Click For Summary
SUMMARY

The discussion centers around integrating the rightbox command into a Maple 14 procedure for calculating Riemann sums. The user has defined a procedure named Integral that computes the exact integral, the right sum, and the associated error for a function over the interval [0, 1]. The challenge lies in incorporating the rightbox command to generate a graphical representation of the Riemann sum alongside the numerical outputs. The user seeks assistance in modifying their existing procedure to achieve this integration effectively.

PREREQUISITES
  • Familiarity with Maple 14 programming syntax
  • Understanding of Riemann sums and their applications
  • Knowledge of plotting functions in Maple
  • Basic calculus concepts, specifically integration
NEXT STEPS
  • Research how to modify Maple procedures to include graphical outputs
  • Learn about the rightbox command and its parameters in Maple 14
  • Explore examples of combining numerical and graphical outputs in Maple
  • Investigate debugging techniques for Maple procedures to resolve output issues
USEFUL FOR

Mathematicians, educators, and students who are using Maple 14 for calculus and numerical analysis, particularly those interested in visualizing Riemann sums and integrating graphical outputs into their procedures.

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

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
1
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 1 ·
Replies
1
Views
7K
  • · Replies 10 ·
Replies
10
Views
3K