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

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

[Maple Math]

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

[Maple Math]

[Maple Math]

> y1:=subs(Line1, GeneralFormula);

[Maple Math]

> y2:= subs(Line2, GeneralFormula);

[Maple Math]

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

[Maple Plot]

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

[Maple Math]

> evalf(solution);

[Maple Math]

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
[Maple Math] .

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

[Maple Math]

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

[Maple Math]

[Maple Math]

[Maple Math]

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

[Maple Math]

[Maple Math]

[Maple Math]

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

[Maple Math]

> ans:=subs(line1, Generalformula);

[Maple Math]

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

[Maple Plot]

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

Problem 3.

Problem 3: Given the functions below

[Maple Math] [Maple Math] .

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

[Maple Math]

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

[Maple Math]

>

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

[Maple Plot]

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

[Maple Math]

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

[Maple Math]

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

[Maple Math]

> allvalues(ans);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

>

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.

[Maple Math] [Maple Math]

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;

[Maple Math]

[Maple Math]

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

[Maple Plot]

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

[Maple Math]

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

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

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

[Maple Math]

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

[Maple Math]

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

[Maple Math]

[Maple Math]

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

[Maple Math]

>

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

[Maple Math]

>

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

[Maple Math]

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

[Maple Math]

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

[Maple Math]

>

>

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;

[Maple Math]

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

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

[Maple Math]

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

[Maple Plot]

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