Check your Homework

by
K. D.  Stroyan
University of Iowa

copyright 1997 by Academic Press, Inc. - All rights reserved.

Special Mathematica Functions

Needs["Graphics`Colors`"];

Notebook Overview

Mathematica can be used to check your homework.  We'll use the prime notation for derivatives of functions in this NoteBook.

A Common Typing Error

When entering a function definition like the mathematical

"f[x] is defined to be  3 (x^2) - x"

we type

\(Clear[f, x, a, u]; 
f[x_]\  = \ 3\ x\^2 - x; 
f[x]\)f[a]f[u]\(u\  = \ a\ x\  + \ 3; 
f[u]\)

This has derivative given by entering the command:

f'[x]f'[a]f'[u]

But notice that the following command does NOT define the function above:

\(Clear[f, x, a, u]; 
f[x]\  = \ 3\ x\^2 - x; 
f[x]\)f[a]f[u]\(u\  = \ a\ x\  + \ 3; 
f[u]\)f'[x]f'[a]f'[u]

You MUST tell Mathematica when you are defining a function that the input unknown is "x"  and you tell it this by typing the underscore after the variable," x_".

Another Error

Space means multiply, but a missing space means the variable has a different name.  Here's an example.

\(Clear[x, y, z, a, b]; 
y[x_]\  = \ a\  + \ b\ x\)y'[x]z[x_]  =  a  +  bxz'[x]

The variable x does not appear in the function z[x], rather only the single variable bx (NOT b*x).  It is safest to type multiplications explicitly:

\(Clear[x, y, z, a, b]; 
y[x_]\  = \ a\  + \ b*x\)y'[x]

Step-by-step Differentiation with WalkD[.,.]

Check your work step-by-step

Mathematica has a step-by-step differentiation package in its demos.  If you wish to see all the steps needed in a differentiation, you can load that package

to check your work:

1)  Open Help in Mathematica (upper right of toolbar).

2)  Click Getting Started/Demos and continue selecting inside this as follows
	Demos
		Notebook Demos
			Step-by-step Differentiation (it's way down the list)
			
Run the first example in there and say "yes" to "Evaluate Initialization?"  This loads the WalkD[y,x] function so it's ready to use to check your work.

A Step-by-step Example

WalkD[((x^3) - x + 6) Cos[(x^2)], x];

Exercises

Exercise 6.1.2 (b)

Enter the following:

a

\(Clear[x, f]; 
f[x_] = 1\/x\^5\)f'[x]

b

\(Clear[x, f]; 
f[x_] = \ \@x\%5\)f'[x]

c

\(Clear[x, f]; 
f[x_] = \ 1\/\@\(x\^2\)\%3\)f'[x]

d

\(Clear[x, f]; 
f[x_] = \ x\^2\ \@x\)f'[x]

Exercise 6.1.3

Enter the following:

a

\(Clear[x, f]; 
f[x_] = x\^2\)f'[x]

b

\(Clear[u, v]; 
u[v_] = 1\/v\^2\)u'[v]

Exercise 6.2.1

Enter the following:

g

\(Clear[x, f]; 
f[x_] = 7 \@ x\%5\  - 3\ 1\/x\^4\)f'[x]

i

\(Clear[x, f]; 
f[x_] = 7  E\^x\  - 3\ Log[x]\)f'[x]

k

\(Clear[x, f]; 
f[x_] = E\ \@x\%5\  - π\ 1\/x\^4\)f'[x]

n

\(Clear[x, f]; 
f[x_] = 7  Cos[x]\  - \ 3\ Sin[x]\)f'[x]

Exercise 6.2.3

Enter the following:

a

\(Clear[u, v]; 
v[u_] = u\^2 + 2\ u + 2\)v'[u]

b

\(Clear[u, v]; 
u[v_]\  = \ 4 \@ v - \ π\ 1\/v\^2\)

Problem 6.2

This problem should be done using the DiffRules program.  We will give final answers usinf the D[.] operator, but not explain here which rules were used in finding the answer.

a

\(Clear[x, y, m, b]; 
y\  = \ m\ x\  + \ b\)D[y, x]D[y, m]D[y, b]

b & c

\(Clear[y, u, v, w]; 
y\  = \ u\ v\  + \ w\)D[y, v]D[y, u]D[y, w]

e +

\(Clear[f, x, a, b, c, m]; 

    f[x_]\  = \ a\  + \ b*x + c*x\^2 + m*x\^3\)f'[x]D[f[x], c]

Exercise 6.3.1

Enter the following:

g

\(Clear[z, y, x]; 
y[x_]\  = \ Log[x]\/\@x\%5\)y'[x]z[x_]  =  Log[x] (x^((-1/5)))z'[x]

h

\(Clear[y, x]; 

    y[x_]\  = \ \((E\^x\  - \ 3)\)\ x\^\((\(-4\))\)\)y'[x]Together[y'[x]]

(((E^x) - 3)/(x^4)) ==  
      ((E^x)  -  3) (x^((-4)))

i

\(Clear[y, x]; 
y[x_] = x\^2\ E\^x\)y'[x]Factor[y'[x]]

j

\(Clear[f, x]; 
f[x_] = 7\ E\^x\ Cos[x]\)f'[x]

Exercise 6.3.5

Enter the following

b

\(Clear[v, u]; 

    v[u_]\  = \ \((u\^3 + \ 3\ u\  + \ 3)\) \((Sin[u]\  + \ Cos[u])\)\)v'[u]Coefficient[v'[u], Cos[u]] Cos[u]  +  
      Coefficient[v'[u], Sin[u]] Sin[u]

c

\(Clear[u, v]; 

    u[v_]\  = \ 
      \((4 \@ v + π\ 1\/v\^2)\) \((v\^\(1/4\) - \ 1\/v\^\(1/3\))\)\)\(	\(u'\)[v]\)Together[u'[v]]

Exercise 6.4.1

a + fun

\(Clear[y, x]; 
y[x_]\  = \ \((1 + x)\)\^33\)y'[x]Expand[y[x]]Expand[y'[x]]

a with a function chain

\(Clear[f, g, h, x, u]; 
g[x_]\  = \ 1\  + \ x\)g'[x]f[u_]  =  u^33f'[u]h[x_]  =  f[g[x]]f'[g[x]] g'[x]h'[x]

b

Clear[y, x, a, b]y[x_]  =  (((a + b*x))^33)y'[x]

b with a function chain

\(Clear[f, g, h, x, u, a, b]; 
g[x_]\  = \ a\  + \ b*x\)g'[x]f[u_]  =  u^33f'[u]h[x_]  =  f[g[x]]f'[g[x]] g'[x]h'[x]

c

Clear[y, x, a, b, c]y[x_]  =  (((a + b*x))^c)y'[x]

h

\(Clear[x, y, a, b]; 

    y[x_]\  = \ E\^\(Sin[a*x]\  + \ b\)\)y'[x]

h with a function chain

\(Clear[f, g, y, x, u, a, b]; 
g[x_]\  = \ Sin[a*x]\  + \ b\)g'[x]f[u_]  =  E^uf'[u]y[x_]  =  f[g[x]]f'[g[x]] g'[x]y'[x]

Exercise 6.5.1

Evaluate the following:

a

\(Clear[y, t]; 
y[t_] = 3\^t\)y'[t]

(3^t) == (E^(t Log[3]))

d

\(Clear[y, t]; 
y[t_] = t\^t\)y'[t]

(t^t) == (E^(t Log[t]))

Exercise 6.6.1

Evaluate the following:

a vs 6.6.2

\(Clear[y, z, t]; 
y[t_]\  = \ \((Log[t])\)\^3\)y'[t]z[t_]  =  Log[(t^3)]z'[t]

b

\(Clear[z, y, x, t]; 
y[t_]\  = \ Log[Cos[x]]\)D[y[t], t]z[x_]  =  Log[Cos[x]]z'[x]D[z[x[t]], t]

d

\(Clear[z, y, x, t]; 
y[t_]\  = \ Log[Log[x]]\)D[y[t], t]z[x_]  =  Log[Log[x]]D[z[x[t]], t]

f

\(Clear[z, y, x]; 
y[t_]\  = \ Log[\ t\^2\  + \ 2  x]\)D[y[t], t]z[t_, x_]  =  Log[(t^2)  +  2  x]D[z[t, x[t]], t]

Exercise 6.7.1

Evaluate the following:

a

\(Clear[y, x]; 
y[x_] = 1\/\(2\ x - 1\)\)y'[x]

b

\(Clear[y, x, a, b]; 
y[x_] = 1\/\(a\ x + \ b\)\)y'[x]

c

\(Clear[y, x, f, g, u]; 
y[x_] = Cos[x\^2]\)y'[x]

g[x_] = (x^2)g'[x]f[u_]  =  Cos[u]f'[u]f[g[x]]f'[g[x]] g'[x]

d

\(Clear[y, x, f, g, u]; 
y[x_] = \((Cos[x])\)\^2\)y'[x]

g[x_] = Cos[x]g'[x]f[u_]  =  (u^2)f'[u]f[g[x]]f'[g[x]] g'[x]

Example 6.21

\(Clear[f, g, y, u, x]; 
y\  = \ u^3; 
u\  = \ f[x]*g[x]; 
y\)D[y, x]

Exercise 6.7.3

\(Clear[f, g, h, k, x]; 
k[x_]\  = \ f[x]*g[x]*h[x]; 
\(k'\)[x]\)D[f[x]*g[x]*h[x], x]

Exercise 6.7.6 & 7

\(Clear[y, x]; 
RelDiff[y_, x_]\  := \ D[y, x]/y; \)

\(Clear[f, x]; 
RelDiff[f[x], x]\)

\(f = \ x^6; 
RelDiff[f, x]\)

\(Clear[f, r, x]; 
f = \ E\^\(r\ x\); 
RelDiff[f, x]\)

\(Clear[f, g, x]; 
RelDiff[f[x]*g[x], x]\)Apart[RelDiff[f[x]*g[x], x]]

Exercise 6.8.3

\(Clear[f, x]; 
f[x_]\  = \ \@x\%3\)f'[x]\(x\  = \ 10^15; 
df\  = \ \(f'\)[x]\ dx\)\(dx\  = \ 2; 

    Print[\*""((1, 000, 000, 000, 000, 002)^(1/3))- ((1, 000, 000, 000, 000, 000)^(1/3))≈"", df, " ≈ ", 
      N[df]]; 
N[\@1000000000000002\%3 - \ \@1000000000000000\%3, 20]\)N[(1000000000000002^(1/3)) -  (1000000000000000^(1/3))]N[(1000000000000002^(1/3))]\(	N[\ \@1000000000000000\%3]\)

Problem 6.11.

\(Clear[d, r, T, t]; 
r[t_]\  = \ d/\((t/3600)\)\)r'[t]\(d\  = \ 1; 
t\  = \ 60; 
dr\  = \ \(r'\)[t]\ dt\)Plot[{r[t + dt], dr + 60}, {dt, -10, 10}, 
      AxesLabel -> {"dt", "dr"}, 
      PlotStyle -> {{Thickness[0.01], Red}, Blue}];