Docsity

Mathematica Notebook: Solving Mathematical Problems using Symbolic Computation - Prof. Kev, Study Guides, Projects, Research of Mathematics

Toggle sidebar
bg1
Math 3350 Project #1 Solutions
Fall 2008
Prof. Kevin Long
Problem 1
Defining functions
Define an expression for
fHxL=I6 x2-18 x+2M e-x2 cos 5 x
. Pay careful attention to the use of square brackets, the underscore
after the argument on the LHS, and the capitalization of the names Exp and Cos.
f@x_D=H6 x^ 2 -18 x+12L Exp@-x2DCos@5 xD
ã-x2I6x2-18 x+12McosH5xL
The Factor function factors
I6 x2-18 x+12M
to
6Hx-2L Hx-1L
within
Factor@f@xDD
6ã-x2Hx-2LHx-1LcosH5xL
The Expand function multiplies out all terms
Expand@f@xDD
6ã-x2cosH5xLx2-18 ã-x2cosH5xLx+12 ã-x2cosH5xL
Simplify can make an expression more readable
Simplify@f@xDD
6ã-x2Ix2-3x+2McosH5xL
FullSimplify tries to reduce the number of operations
FullSimplify@f@xDD
6ã-x2HHx-3Lx+2LcosH5xL
Differentiation
Compute the derivative of
df@x_D=D@f@xD, xD
ã-x2H12 x-18LcosH5xL- 
1
2ã-x2I6x2-18 x+12McosH5xL-5ã-x2I6x2-18 x+12MsinH5xL
Run Simplify, Together, Expand, FullSimplify, and Factor on df, in order to see how these operations work on a more complicated
expression.
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Mathematica Notebook: Solving Mathematical Problems using Symbolic Computation - Prof. Kev and more Study Guides, Projects, Research Mathematics in PDF only on Docsity!

Math 3350 Project #1 Solutions

Fall 2008

Prof. Kevin Long

Problem 1

ü Defining functions

Define an expression for f H x L = I 6 x^2 - 18 x + 2 M e - x ê^2 cos 5 x. Pay careful attention to the use of square brackets, the underscore

after the argument on the LHS, and the capitalization of the names Exp and Cos.

f@x_D = H6 x ^ 2 - 18 x + 12 L Exp@-x ê 2 D Cos@5 xD „- x ê^2 I 6 x^2 - 18 x + 12 M cosH 5 x L

The Factor function factors I 6 x^2 - 18 x + 12 M to 6 H x - 2 L H x - 1 L within f H x L

Factor@f@xDD 6 „- x ê^2 H x - 2 L H x - 1 L cosH 5 x L

The Expand function multiplies out all terms

Expand@f@xDD 6 „- x ê^2 cosH 5 x L x^2 - 18 „- x ê^2 cosH 5 x L x + 12 „- x ê^2 cosH 5 x L

Simplify can make an expression more readable

Simplify@f@xDD 6 „- x ê^2 I x^2 - 3 x + 2 M cosH 5 x L

FullSimplify tries to reduce the number of operations

FullSimplify@f@xDD 6 „- x ê^2 HH x - 3 L x + 2 L cosH 5 x L

ü Differentiation

Compute the derivative of f H x L

df@x_D = D@f@xD, xD

„- x ê^2 H 12 x - 18 L cosH 5 x L - ÄÄÄÄÄ

„- x ê^2 I 6 x^2 - 18 x + 12 M cosH 5 x L - 5 „- x ê^2 I 6 x^2 - 18 x + 12 M sinH 5 x L

Run Simplify, Together, Expand, FullSimplify, and Factor on df, in order to see how these operations work on a more complicated

expression.

Simplify@df@xDD

  • 3 „- x ê^2 II x^2 - 7 x + 8 M cosH 5 x L + 10 I x^2 - 3 x + 2 M sinH 5 x LM Together@df@xDD
  • 3 „- x ê^2 IcosH 5 x L x^2 + 10 sinH 5 x L x^2 - 7 cosH 5 x L x - 30 sinH 5 x L x + 8 cosH 5 x L + 20 sinH 5 x LM Expand@df@xDD
  • 3 „- x ê^2 cosH 5 x L x^2 - 30 „- x ê^2 sinH 5 x L x^2 + 21 „- x ê^2 cosH 5 x L x + 90 „- x ê^2 sinH 5 x L x - 24 „- x ê^2 cosH 5 x L - 60 „- x ê^2 sinH 5 x L FullSimplify@df@xDD
  • 3 „- x ê^2 HHH x - 7 L x + 8 L cosH 5 x L + 10 HH x - 3 L x + 2 L sinH 5 x LL Factor@df@xDD
  • 3 „- x ê^2 IcosH 5 x L x^2 + 10 sinH 5 x L x^2 - 7 cosH 5 x L x - 30 sinH 5 x L x + 8 cosH 5 x L + 20 sinH 5 x LM

ü Plotting functions

Plot@8f@xD, df@xD<, 8 x, - 1, 1 <, PlotRange Æ All, Frame Æ True, PlotLabel Æ "Math 3350 Project 1, solutions: Problem 1"D

  • 1.0 - 0.5 0.0 0.5 1.
  • 300
  • 200
  • 100

0

100

Math 3350 Project 1, solutions: Problem 1

ü Integration

Compute g H x L = Ÿ f H x L dx

g@x_D = Integrate@f@xD, xD

ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

6 „- x ê^2 I 20 I10 201 x^2 - 29 795 x + 18 414M sinH 5 x L - 2 I10 201 x^2 - 70 599 x + 78 004M cosH 5 x LM

To check, differentiate g H x L. The result should be f H x L = I 6 x^2 - 18 x + 12 M e - x ê^2 cos 5 x.

Plot@y@xD, 8 x, - 8, 8 <, Frame Æ True, PlotLabel Æ "Math 3350 Project 1 solutions, Problem 2"D

  • 5 0 5

Math 3350 Project 1 solutions, Problem 2

Problem 3

ClearAll@algSoln, yD

Solve logJ ÄÄÄÄÄÄÄÄÄÄÄÄ^ y

2

1 - y^2 N^ =^ x^ for^ y H x L

algSoln = Solve@Log@y ^ 2 ê H 1 - y ^ 2LD ä x, yD

:: y Æ - ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ „ x ê^2 è!!!!!!!!!!!!!!!! 1 + „ x!^ >,^ : y^ Æ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

„ x ê^2 è!!!!!!!!!!!!!!!! 1 + „ x!^ >>

There are two solutions, one positive, one negative. The positive solution is the second entry in the list, so

posSoln = algSoln@@ 2 DD

: y Æ ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

„ x ê^2 è!!!!!!!!!!!!!!!! 1 + „ x!^ > y@x_D = y ê. posSoln

ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ „ x ê^2 è!!!!!!!!!!!!!!!! 1 + „ x!

Plot@y@xD, 8 x, - 8, 8 <, Frame Æ True, PlotLabel Æ "Math 3350 Project 1 solutions, Problem 3"D

  • 5 0 5

Math 3350 Project 1 solutions, Problem 3

Problem 4

Solve y ’ = ÄÄÄÄÄÄÄÄÄÄ 32 yx 2 with y H 1 L = 2.

This is a separable equation y ’ = ÄÄÄÄÄÄÄÄÄÄ^ g h HH xy LL.

Define Mathematica functions for g H x L and h H y L

ClearAll@h, g, H, G, algEqn, solnD g@x_D = 2 x 2 x

and h H y L.

h@y_D = 3 y ^ 2 3 y^2

Compute the indefinite integrals of h H x L and g H x L.

G@x_D = Integrate@g@xD, xD x^2 H@y_D = Integrate@h@yD, yD y^3

The method of separation of variables gives us

H H y L = G H x L + C ,

or alternatively,

H H y L - H H y 0 L = G H x L - G H x 0 L

where the initial condition is y H x 0 L = y 0. With the initial conditions for this problem, x 0 = 0 and y 0 = 1.

This last equation is an algebraic equation for y H x L. We can write it in Mathematica as

ü Plot the solution

Plot@soln@xD, 8 x, - 4, 4 <, Frame Æ True, PlotLabel Æ "Math 3350, Project 1 solutions, Problem 4"D

  • 4 - 2 0 2 4

Math 3350, Project 1 solutions, Problem 4

Problem 5

Solve ÄÄÄÄÄÄ^ dydx = ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ^ x +cos 5 y 3 x.

ClearAll@g, h, G, H, algEqn, solnD g@x_D = x + Cos@5 xD x + cosH 5 x L h@y_D = y ^ 3 y^3 x0 = 0 0 y0 = 1 1

Compute G H x L = Ÿ g H x L dx and H H y L = Ÿ h H y L dy.

G@x_D = Integrate@g@xD, xD

ÄÄÄÄÄÄÄÄ x^2 2

+ ÄÄÄÄÄ

sinH 5 x L

H@y_D = Integrate@h@yD, yD

ÄÄÄÄÄÄÄÄ y^4 4

The method of separation of variables gives the algebraic equation H H y L - H H y 0 L = G H x L - G H x 0 L for y H x L

algEqn = H@yD - H@y0D ä G@xD - G@x0D

ÄÄÄÄÄÄÄÄ y^4 4

- ÄÄÄÄÄ

á ÄÄÄÄÄÄÄÄ x^2 2

+ ÄÄÄÄÄ

sinH 5 x L

Solve the algebraic equation

algSoln = Solve@algEqn, yD

:: y Æ -"##### 2 &''''''''''''''''''''''''''''''''''''''''''''''''ÄÄÄÄÄÄÄÄ x^2 2

+ ÄÄÄÄÄ

sinH 5 x L + ÄÄÄÄÄ

(^4) >, : y Æ -‰ "##### 2 &''''''''''''''''''''''''''''''''''''''''''''''''ÄÄÄÄÄÄÄÄ^ x

2 2

+ ÄÄÄÄÄ

sinH 5 x L + ÄÄÄÄÄ

: y Æ ‰ "##### 2 &''''''''''''''''''''''''''''''''''''''''''''''''ÄÄÄÄÄÄÄÄ

x^2 2

+ ÄÄÄÄÄ

sinH 5 x L + ÄÄÄÄÄ

(^4) >, : y Æ "##### 2 &''''''''''''''''''''''''''''''''''''''''''''''''ÄÄÄÄÄÄÄÄ x^2 2

+ ÄÄÄÄÄ

sinH 5 x L + ÄÄÄÄÄ

Of the four solutions, only the last is consistent with the initial conditions

soln@x_D = y ê. algSoln@@ 4 DD

"##### 2 &''''''''''''''''''''''''''''''''''''''''''''''''ÄÄÄÄÄÄÄÄ^ x^2 2

+ ÄÄÄÄÄ

sinH 5 x L + ÄÄÄÄÄ

4

ü Check the solution

Plug into the equation

LHS = D@soln@xD, xD

ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ x + cosH 5 x L 2 è!!!!! 2 J ÄÄÄÄÄÄ^ x 22 + ÄÄÄ^15 sinH 5 x L + ÄÄÄ^14 N

3 ê 4

RHS = g@xD ê h@soln@xDD

ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

x + cosH 5 x L 2 è!!!!! 2 J ÄÄÄÄÄÄ^ x 22 + ÄÄÄ^15 sinH 5 x L + ÄÄÄ^14 N

3 ê 4

FullSimplify@LHSD ä FullSimplify@RHSD True

The solution satisfies the differential equation. Next check the initial conditions

soln@ 0 D ä 1 True

The solution satisfies the initial conditions and the DE, so the solution checks.

Solve using the formula y H x L = ÄÄÄÄÄÄÄÄÄÄ Μ^1 H x L JΜH x 0 L y 0 + Ÿ x^ x 0 ΜH x L q H x L ‚ x N.

y@x_D = 1 ê mu@xD Hmu@x0D y0 + Integrate@mu@xD q@xD, 8 x, x0, x<DL

ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

ÄÄÄÄÄÄ^ x 44 + ÄÄÄ^34 x^2

ü Check the solution

Plug y H x L into the LHS, y ’ + p H x L y

LHS = D@y@xD, xD + p@xD y@xD x

and compare to the RHS

RHS = q@xD x FullSimplify@LHSD ä FullSimplify@RHSD True

Check that the solution obeys the initial conditions

y@x0D ä y True

The solution obeys the DE and the IC, so it checks.

ü Plot the solution

Plot@y@xD, 8 x, 1, 4 <, Frame Æ True, PlotLabel Æ "Math 3350, Project 1 solutions, problem 6"D

1.0 1.5 2.0 2.5 3.0 3.5 4.

Math 3350, Project 1 solutions, problem 6

Problem 7

Solve ÄÄÄÄÄÄ^ dydx + J 3 + ÄÄÄÄÄÄÄÄÄÄ 1 +^2 x N y = x cos 3 x + 7 x^3 e - x^ sin 2 x + cos x + x^2 e - x ê^2

Clear variables, and then define p , q , x 0 , y 0.

ClearAll@p, q, mu, y, x0, y0D p@x_D = 3 + 2 ê H 1 + xL

3 + ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

x + 1 q@x_D = x Cos@3 xD + 7 x ^ 3 Exp@-xD Sin@2 xD + Cos@xD + x ^ 2 Exp@-x ê 2 D 7 „- x^ sinH 2 x L x^3 + „- x ê^2 x^2 + cosH 3 x L x + cosH x L x0 = 0 0

y0 = 1 1

Compute the integrating factor

mu@x_D = Exp@Integrate@p@xD, xDD „^3 x^ H x + 1 L^2

Compute y H x L using the standard formula for first-order linear equations

y@x_D = 1 ê mu@xD Hmu@x0D y0 + Integrate@mu@xD q@xD, 8 x, 0, x<DL

ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

H x + 1 L^2

„-^3 x^

i k

jjjj jjj ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ

2 „^5 x ë^2 H 625 x^4 + 250 x^3 + 325 x^2 - 260 x + 104 L 3125 + ÄÄÄÄÄÄÄÄÄÄÄÄÄ

3 x (^) I 75 x (^2) + 110 x + 44 M cosH x L -

ÄÄÄÄÄÄÄÄÄ

2 x (^) I 16 x (^5) - 8 x (^4) - 8 x (^3) + 24 x (^2) - 18 x + 3 M cosH 2 x L + ÄÄÄÄÄÄÄÄÄ^1 54 „

3 x (^) I 9 x (^3) + 18 x (^2) + 6 x - 1 M cosH 3 x L + ÄÄÄÄÄÄÄÄÄÄÄÄÄ^1 250 „

3 x (^) I 25 x (^2) + 20 x + 8 M

sinH x L + ÄÄÄÄÄÄÄÄÄ

2 x (^) I 8 x (^5) + 16 x (^4) - 12 x (^3) + 6 x (^2) + 3 x - 3 M sinH 2 x L + ÄÄÄÄÄÄÄÄÄ^1 54 „

3 x (^) I 9 x (^3) + 9 x (^2) - 1 M sinH 3 x L + ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ^ 5 962 051 5 400 000

y {

zzzz zzz

ü Check the solution

LHS = Simplify@ D@y@xD, xD + p@xD y@xD D cosH x L + x IcosH 3 x L + „- x^ x I 7 x sinH 2 x L + „ x ê^2 MM RHS = q@xD 7 „- x^ sinH 2 x L x^3 + „- x ê^2 x^2 + cosH 3 x L x + cosH x L