20 Reputation

One Badge

1 years, 201 days

MaplePrimes Activity

These are questions asked by MapleUser09

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 to make an animation that secant lines of f(x) = sin(x) through x = 1 approach the
tangent line 


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).

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
(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