[Maple 14] rightbox in a procedure?

  • Maple
  • Thread starter iFargle
  • Start date
  • Tags
    Procedure
In summary, the conversation discusses the use of the Integral procedure to calculate the integral of a function over an interval. It also mentions the use of the rightbox command to plot the Riemann Sum for a specific number of sub-intervals. The question is how to integrate the rightbox command into the Integral procedure to output the integral, Riemann Sum, and error, as well as the accompanying graph.
  • #1
iFargle
7
0
Here's what I have
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.​
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
Bump?
 

1. What is the purpose of the rightbox in a procedure in Maple 14?

The rightbox in a procedure in Maple 14 is used to specify the output format for the results of the procedure. It allows the user to customize the appearance of the output, such as the font, size, and alignment.

2. How do I use the rightbox in a procedure in Maple 14?

To use the rightbox in a procedure, you can simply add it as a parameter in the procedure definition. For example, you can use the syntax "procedureName(parameters, rightbox)" to specify the rightbox format for the output.

3. Can I change the rightbox format after the procedure has been defined?

Yes, you can change the rightbox format for a procedure after it has been defined. You can use the "setrightbox" command to change the rightbox format for a specific procedure or you can use the "setrightbox" command with the "allprocs" option to change the format for all procedures in your Maple 14 session.

4. What are the options for customizing the rightbox in Maple 14?

There are several options available for customizing the rightbox format in Maple 14. Some of the options include changing the font, font size, alignment, line spacing, and background color. You can also use mathematical expressions and variables in the rightbox format.

5. Is the rightbox feature available in all versions of Maple?

No, the rightbox feature is only available in Maple 14 and later versions. If you are using an earlier version of Maple, you will not have access to the rightbox feature.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
221
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
996
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
261
Replies
16
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
991
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
Back
Top