Maple Introduction, Part 3:

**Lists, sets, **
**subs****, **
**solve, fsolve, ****problem-solving**

Integrated, First-Year Curriculum in Science, Engineering, and Mathematics

Based on a worksheet by Claude Anderson

Extensively revised by Kurt Bryan and David Mutchler

**Introduction**

**Review and summary of the homework**

**New ideas**

**In-class exercises and homework**

Begin these in class if you have time; finish them for homework.

**Problem 1.**

*Problem 1:*
(NOTE: This problem is very similar to the example from The "New ideas" section of this worksheet, in the subsection called "Applying these ideas---finding the line through two given points". You should be able to copy and paste code from that example and change the numbers so that you do not have to do a lot of typing.)

Line A passes through the points (4,5) and (6,7). Line B passes through (2,4) and (3,-2). Find the equations of the lines. Then use the
*solve*
function to find the point where the lines intersect. Then plot the graphs of both, so you can see the intersection.

`> `
**restart;**

`> `
**GeneralFormula := y =a*x + b;
point1 := [4,5]; point2:= [6,7]; point3:=[2,4]; point4:=[3,-2];
eq1 := subs( {x = point1[1], y = point1[2]}, GeneralFormula );
eq2 := subs( {x = point2[1], y = point2[2]}, GeneralFormula );
eq3 := subs( {x = point3[1], y = point3[2]}, GeneralFormula );
eq4 := subs( {x = point4[1], y = point4[2]}, GeneralFormula );
**

`> `
**Line1:= solve ( {eq1,eq2}, {a,b} );
Line2:= solve ( {eq3,eq4}, {a,b} );
**

`> `
**y1:=subs(Line1, GeneralFormula);**

`> `
**y2:= subs(Line2, GeneralFormula);**

`> `
**plot({rhs(y1),rhs(y2)},x=-2..3);**

`> `
**solution:=solve({y1, y2}, {x, y});**

`> `
**evalf(solution);**

**Problem 2.**

*Problem 2: *
(NOTE: This problem is also similar to the example from the subsection called "Applying these ideas---finding the line through two given points". The goal is to be able to understand what was done there so that you can apply it here.)

The general equation for a parabola with a vertical axis of symmetry is
.

(a) Find the equation of such a parabola that passes through the points (0,5), (4,6), and (5,10).

(b) Estimate (by plotting) the
*y*
-value of the lowest point on the graph of this parabola.

`> `
**restart;**

`> `
**Generalformula:=y=a*x^2+b*x+c;**

`> `
**point1:=[0,5]; point2:=[4,6]; point3:=[5,10];**

`> `
**eq1 := subs( {x = point1[1], y = point1[2]}, Generalformula );
eq2 := subs( {x = point2[1], y = point2[2]}, Generalformula );
eq3 := subs( {x = point3[1], y = point3[2]}, Generalformula );
**

`> `
**line1:=solve({eq1,eq2,eq3}, {a,b,c});**

`> `
**ans:=subs(line1, Generalformula);**

`> `
**plot(rhs(ans), x=0..4);**

**The lowest point by estimation is (1.82,2.49).**

**Problem 3.**

*Problem 3: *
Given the functions below

.

`> `
**fx:=y=x^4+5*x^3+10*x^2-2;**

`> `
**gx:=y=-x^2+6*x+10;**

`> `

a. Define Maple expressions for the above functions.

b. Prepare a plot of the two functions showing all intersections.

c. Use
*fsolve*
to find
__floating point approximations__
to the real (non-complex) values of
*x*
for which f(x) = g(x). (This equation has solutions in the complex number system. If you don't know what that means, don't worry about it,
*fsolve*
looks only for the "real" (non-complex) solutions, left to itself.)

d. Use
*solve*
and
*allvalues*
to find
__exact__
values for the real (non-complex) values of
*x*
for which f(x) = g(x). The answer will be a hairy monster, that's OK! See if you can decipher the answer, but if you can't, that's OK, we'll discuss it together in our next session. (Just for funs, can you spot the two imaginary (non-real) solutions that
*allvalues*
reports?)

`> `
**plot({rhs(fx),rhs(gx)},x=-4..10,y=-10..20);**

`> `
**fsolve(rhs(fx)=rhs(gx),x=-1.5..0);**

`> `
**fsolve(rhs(fx)=rhs(gx),x=0..2);**

`> `
**ans:=solve(rhs(fx)=rhs(gx),x);**

`> `
**allvalues(ans);**

`> `

**Problem 4.**

*Problem 4: *
The graphs of the functions below are parabolas that intersect in two points. A unique line
*L*
connects those two points. Use
*solve*
and
*subs*
to find an equation for
*L*
, and plot the graphs of the two parabolas and
*L*
on one graph. Then use
*solve*
to find the point where
*L*
crosses the
*x*
-axis.

When you do this, use assignments (:=) and
*subs*
rather than simply typing in (or using Copy and Paste) to include information from a previous computation. Suppose that we wanted to do the same calculations for another pair of parabolas. It would be nice to simply change the coefficients in our first computation, then re-evaluate the same sequence of commands. Did you do this problem in such a way that this is possible?

When solving a problem via computer, it is often worth a little bit of extra time to make your solution more general so that it can be re-used easily the next time you have to solve a similar problem.

`> `
**restart;**

`> `
**fx:=3*x^2 - x+1;
gx:=3*x-x^2+6;**

`> `
**plot({fx,gx},x=-3..4,y=-5..10);**

`> `
**intersects:=solve(fx=gx,x);**

`> `
**x1:=1/2+1/2*sqrt(6):**

`> `
**x2:=1/2-1/2*sqrt(6):**

`> `
**y1:=subs(x=x1,fx);**

`> `
**y2:=subs(x=x2,fx);**

`> `
**point1:=[x1,y1]; point2:=[x2,y2];**

`> `
**genform:=y=m*x+b;**

`> `

`> `
**m1 := eval((y1-y2)/(x1-x2));**

`> `

`> `
**b1 := solve(y1=m1*x1+b,b);**

`> `
**soln := y=m1*x+b1;**

`> `
**ans := solve(rhs(soln)=0,x);**

`> `

`> `

**Problem 5.**

*Problem 5: *
An open rectangular box (no top) is to be made from a sheet of metal 10 cm wide and 14 cm long by cutting a square from each corner, bending up the sides, and welding the edges.

Express the volume
*V*
of the box in terms of the length
*A*
of a side of the square cut from each corner.

a. Work on the problem without the computer. Make a physical model if necessary.

b. Define a Maple expression for
*V*
in terms of
*A*
.

c. Plot
*V*
for
*A*
from 0 to [the biggest meaningful value of
*A*
].

d. Using only plotting and equation-solving commands (no calculus), estimate (accurate to at least two decimal places) the value of
*A*
which maximizes the volume
*V*
.

`> `
**restart;**

`> `
**volume := l*w*h;**

`> `
**SideA := 14-2*a:
SideB := 10-2*a:
SideC := a:**

`> `
**V := (SideA * SideB * SideC);**

`> `
**plot(V,a=1.915..1.925);**

**The estimated maximum volume of the box is 120.16cm^3 if you cut out 1.92cm from the corners. **

`> `

**Problem 6.**

*Problem 6:*
(Nothing to turn in, but perhaps the most important problem). Go back over this worksheet and be sure that you understand everything, If there are things that you do not understand, get help from somebody, and do it soon!

**Pair processing**