- Introduction
- Entering an expression
- Entering a function
- Evaluating functions and expressions
- Solving a function or an expression algebraically
- Solving a function or an expression numerically
- Some more strange output
- Rectangular Approximations
- Exercises

> expr := x^3+3*x^2-x+1;

> f := x-> x^2+2*x-6;Below is how

> f(x) := x^2+2*x-6;The difference between expressions and functions are first the obvious, that expressions do not have to satisfy the definition of a function in the sense that for each input , there is a unique value . A function may be defined as an expression, but not all expressions can be defined as functions. The differences in Maple are numerous as you will see below when we evaluate the expression or function for a given value as well as when using the

> subs(x=2,expr); > eval(expr,x=2); > r:=sin(theta) + 8*theta^2; > subs(theta=Pi/2,r);In the

>g:=2*x/3; >subs(x=4,g); >eval(g,x=1/2); >subs(x=4.0,g);The

> f(2);

> g := 9*x^2-14; > h:=-x^2; > plot([g,h],x=-2..2); > solve(g=h,x);The plot shows that there are two intersection points and the

> ip:=solve(g=h,x);Since there are two values called , use [ ] to call up the one you want.

> eval(g,x=ip[1]); > eval(h,x=ip[2]);Therefore the two intersection points are and . This seems like the answer shown on the graph.

> j:=x->2*x^3-15*x^2-2*x+5; > k:=x->-50; > plot([j(x),k(x)],x=-3..8);The graph shows there should be three answers.

> solve(j(x)=k(x),x);That is some scary output! So instead of using the algebraic

> fsolve(j(x)=k(x),x);

> f:=theta->-1/2*theta+sin(theta); > plot(f(theta),theta=-8*Pi..8*Pi); > solve(f(theta)=0,theta);Wow, what is that?!?! We know from the graph that there should be three answers and

> fsolve(f(theta)=0,theta);Where are the other two answers!? This is actually how

> a:=fsolve(f(theta)=0,theta=-5..-1); > b:=fsolve(f(theta)=0,theta=-1..1); > c:=fsolve(f(theta)=0,theta=1..5);To find the values just plug in the names of the values.

> f(a); > f(b); > f(c);(Of course the y-values are zero!)

Suppose is a non-negative, continuous function defined on some interval . Then by the area under the curve between and we mean the area of the region bounded above by the graph of , below by the -axis, on the left by the vertical line , and on the right by the vertical line . All of the numerical methods in this lab depend on subdividing the interval into subintervals of uniform length.

In these simple rectangular approximation methods, the area above each subinterval is approximated by the area of a rectangle, with the height of the rectangle being chosen according to some rule. In particular, we will consider the left, right and midpoint rules.

The Maple `student` package has commands for visualizing these
three rectangular area approximations. To use them, you first must
load the package via the with command. Then try the three commands
given below to help you understand the differences between the
three different rectangular approximations. Note that
the different rules choose rectangles which in
each case will either underestimate or overestimate the area.

> with(student): > rightbox(x^2,x=0..4,8); > leftbox(x^2,x=0..4,8); > middlebox(x^2,x=0..4,8);To commands below show how to approximate the area under the curve using the left-endpoint rule in Maple

> f:=x->x^2; > h:=(4-0)/8; > h*(f(0)+f(0.5)+f(1)+f(1.5)+f(2)+f(2.5)+f(3)+f(3.5))

- Given the expression
,
- A)
- Plot the expression and in text state how many roots it has. That is, how many times the it crosses the x-axis.(Experiment with domain values until you find values that show the crossing points clearly.)
- B)
- Compare outputs from the Maple
`solve`and`fsolve`command to find the values of where it crosses the x-axis. State the real roots in text. - C)
- Use the Maple
`eval`command to verify at least one of the roots to show it is zero.

- Given the functions
and
- A)
- Plot the functions. Again experiment with domain values until the intersection points are clear. Then state in text how many intersection points you see.
- B)
- Compare outputs from the Maple
`solve`and`fsolve`command to find all values where the two functions intersect. Label the values with a variable in front of the`solve`or`fsolve`command. - C)
- Find all corresponding values and state the intersection points in text.(When writing your text sentence use 3 significant figures for the answer. Be sure to round properly!)

- Plot and calculate the approximate area under over the interval using right-endpoint and midpoint rules with 6 rectangles.

2016-09-05