## 20 Reputation

1 years, 201 days

## how to print out multiple results...

Maple

my code is
for i from 1 to 20 do:

print("new variable" + i)

end do;

It gives the result new vaiable + 1,

how can I print out new variable 1 instead of new variable + 1

## How you create the animation for sin(x)...

Maple

How to make an animation that secant lines of f(x) = sin(x) through x = 1 approach the
tangent line

## recursion assignment...

Notice that it takes a lot longer to create the list of 30 because every time it calls the
procedure Fib, Maple âforgetsâ that it probably has calculated one of those numbers before.
For example, say we want to find Fib(5). Then Fib calls itself to find Fib(3) and Fib(4),
but Fib(4) calls itself to find Fib(3) and Fib(2). So our procedure just called itself
twice to find Fib(3), and even more times to find Fib(2)!
We can help Maple along by using a command that lets it ârememberâ that it already
figured out Fib(3) and so it doesnât need to recursively compute it again. Add a line
directly after your first line of the procedure Fib that says:

option remember;.

Then create your list of the first 30 Fibonacci numbers again. What a difference it makes!

Note: The main chunk of code here is just your code from part (a) with one line added.
Then create the list of 30 Fibonacci numbers in (c).
Then see how long it took, as you did in (d).

## Riemann sum approximation ...

Maple

Write a procedure approxInt that takes in a function f, a number of intervals
N, a left endpoint a, and a right endpoint b. Given these data, the procedure should split the
interval [a, b] into N subintervals and use the function f to estimate the area under the curve
using
(a) Left endpoints,
(b) Right endpoints,
(c) Midpoints, and
(d) Trapezoids.

Write another procedure called compareApproxInt that does the following:
(a) Takes as inputs the function f, the endpoints a and b, and the number of subintervals N.
(b) Calls the procedure approxInt in order to estimate the area under the curve of f(x) with
N subintervals, with the four different approximations methods.
(c) Returns four sentences:
Using        , the approximate area under f is        . This method has a margin of error of         .

Test compareApproxInt with the functions
f1(x) = x
f2(x) = x^2 ,
f3(x) = x^3 - 4 Â· x^2 , and
f4(x) = e^x ,
each on the interval [-1, 1], with 10 subintervals.

 Page 1 of 1
﻿