Tuesday, September 11, 2012

Solving Equations with Maple

Solving Equations with Maple

[Keep scrolling.  To get JPG images on blog required going from Maple to Word to Paint to JPG to MAC to blog.  Lots of unintended space.  Is there a better way?]

Open the Maple worksheet.  From the toolbar, select Text to type a comment.

Select Math to type executable commands which appear in italics.

Place the cursor on the command and press [Enter] to execute the command.

Algebraic Operations
To add, use the plus sign, +.
3+2
5
To subtract, use the dash, -.
3 - 2
1
Use the asterisk, *, to multiply.  It appears as a raised dot in Maple input.  The symbol can also be selected from the Expression template.
3∙2
6
Use the forward slash, /, to divide.  Use the right arrow key to exit the denominator.
3
2

3
2

evalf(%)
1.500000000
The evalf command converts a rational number to decimal (floating point) format.
If a decimal point is placed in any number in an expression, Maple gives a decimal answer.
If all entries are integers, Maple gives the exact answer.
The % sign refers to the last answer calculated.

To raise a value to a power, use the caret, ^.  Use the right arrow key to exit the exponent.

3^2
9
There is no implicit multiplication in Maple.  The multiplication symbol, *, must be used for all multiplication.  In Math input it appears as a raised dot.
3 ∙ (2 ∙ x ∙ y – 7)

6 x y - 21
The solve command will solve equations and inequalities.
solve(3∙x – 7 = 5, x)

4
solve({3∙x – 7 = 5},{ x})

{x=4}
x = solve(3∙x – 7 = 5, x)

x = 4
Write in slope-intercept form the equation of the line that passes through (-2,3) and has slope of 3/4.

y = solve(y – 3 = ¾*(x+2),y)

Braces, {}, are used for sets.  Parentheses are used as grouping symbols.
Brackets, [], are used for lists and matrices.

Now let’s use math.
One day in 1978 at New Braunfels, Texas, almost a foot of rain fell in one hour.  Let’s design a drainage ditch to remove that water from a 10-acre parking lot in one hour.  Assume the slope of the ditch is three inches per hundred feet.  Let the ditch be trapezoidal with sides sloping 45 degrees from horizontal and let the depth of flow be equal to the width of the bottom.  The bottom and sides are unfinished concrete.
Caveat:  The example is for teaching purposes only and not to be used as an actual design.
We’ll use Manning’s formula for flow in an open channel.

in which Q is the flow in cubic feet per second, A is the cross sectional area of flow, R is the hydraulic radius which is the area divided by the wetted perimeter, S is the slope in feet per foot, and n is the roughness coefficient.
We have ten acres one foot deep in water to remove in 3600 seconds.  To solve, place the cursor on the equation and press [Enter].

Let b = width of the bottom and d = the depth of flow.
Then the cross-sectional area of flow A is

Manning’s roughness coefficient for unfinished concrete is 0.014.

We have a set of seven equations in seven unknowns.  Add one more for average velocity of flow.  In Maple, sets are enclosed in braces.  Because we are interested in only real, positive answers, we use the fsolve command instead of the solve command.  Place the equations in braces, separated by commas and the unknowns in braces, also separated by commas.

The bottom of the ditch is almost three feet wide.  The depth of flow is almost three feet.  The velocity of flow is just over seven feet per second.  The width of the top of the ditch is almost nine feet.
All we needed was geometry, the Pythagorean Theorem, and a Google search for flow in open channels.
Manning’s equation is valid for only US Customary units.  It won’t work with metric units.