Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: math480-2016
Views: 779

Math 480 - Homework 4: Due 6pm on April 29, 2016

There are several problems and all have equal weights.

Solve each problem using Sage unless otherwise indicated. In particular, if there is some calculus question, which you could easily do by hand or in your head, you should still show exactly how to solve it using Sage if possible. Of course, do think with your brain!

For any part that asks for a symbolic result, use show(...), so the output is easier for us to read.

Problem 1 -- defining and evaluating a function:

  1. Define in Sage f(x)=sinh(x2+x1)+eπx+arcsin(x)+1x3xef(x) = \sinh(x^2+\sqrt{x-1}) + e^{\pi x} + \arcsin(x) + \frac{1}{x^3-x-e}.

  2. Compute f(1/2)f(1/2) symbolically (exactly).

  3. Compute f(1/2)f(1/2) numerically (so a decimal expansion).

  4. Plot f(x)f(x) from 1-1 to 11.

f(x) = sinh(x^2 + (x-1)) + e^(pi*x) + asin(x) + 1/(x^2 - x- e) f(0.5) N(f(0.5)) plot(f, (x, -1, 1))
1/6*pi - 1.00000000000000/(1.00000000000000*e + 0.250000000000000) + e^(0.500000000000000*pi) - 0.252612316808168 4.74456860615189

Problem 2 -- finding zeros numerically:

Let f(x)=x2+sin(x)f(x) = \displaystyle x^2 + \sin(x)

  1. Draw a plot of ff on the interval [2,2][-2,2].

  2. Differentiate ff

  3. Integrate ff

  4. Find all the zeros of f(x)f(x) numerically.

f(x) = x^2 + sin(x) plot(f, -2,2) f.find_root(-2,-1/2) f.find_root(-1/2,1/2) # (use brain) no other zeros because $x^2$ is big.
-0.8767262153950622 5.78218635220173e-23

Problem 3 -- The Cauchy Distribution

Let  f(x; x0, γ)=1πγ[γ2(xx0)2+γ2]\displaystyle\space f(x;\space x_0,\space\gamma) = \frac{1}{\pi\gamma}\left[\frac{\gamma^2}{(x - x_0)^2 + \gamma^2}\right]

  1. Plot and find the area under the curve of f([2,2])f([-2, 2]) for the following values of x0x_0 and γ\gamma on the interval x=[4,4]x = [-4,4]

  • x0=0,γ=1x_0 = 0,\hspace{3mm} \gamma = 1

  • x0=2,γ=2x_0 = 2,\hspace{3mm} \gamma = 2

  • x0=0,γ=0.5x_0 = 0,\hspace{3mm} \gamma = 0.5

  1. Integrate ff from -\infty to xx using the dummy variable tt as in f(t; x0, γ)f(t;\space x_0,\space\gamma).

  2. Plot the resulting function from 3 for x0=0,γ=0.5x_0 = 0,\hspace{3mm} \gamma = 0.5.

# 1a. gamma = 1 x_0 = 0 f(x) = 1/(pi*gamma) * (gamma^2/((x - x_0)^2 + gamma^2)) p = plot(f, -2, 2, fill=True) + plot(f, -4, 4) show(p) show(integral(f, x, -2, 2))
2*arctan(2)/pi
# 1b. gamma = 2 x_0 = 2 f(x) = 1/(pi*gamma) * (gamma^2/((x - x_0)^2 + gamma^2)) p = plot(f, -2, 2, fill=True) + plot(f, -4, 4) show(p) show(integral(f, x, -2, 2))
arctan(2)π\displaystyle \frac{\arctan\left(2\right)}{\pi}
# 1c. gamma =0.5 x_0 = 0 f(x) = 1/(pi*gamma) * (gamma^2/((x - x_0)^2 + gamma^2)) p = plot(f, -2, 2, fill=True) + plot(f, -4, 4) show(p) show(integral(f, x, -2, 2))
2.0arctan(4)π\displaystyle \frac{2.0 \, \arctan\left(4\right)}{\pi}
var('gamma', 'x_0') f(t) = 1/(pi*gamma) * (gamma^2/((t - x_0)^2 + gamma^2)) show(integral(f(t), t, -oo, x))
(gamma, x_0)
γ(πγ2arctan(xx0γ)γ)2π\displaystyle \frac{\gamma {\left(\frac{\pi}{\gamma} - \frac{2 \, \arctan\left(-\frac{x - x_{0}}{\gamma}\right)}{\gamma}\right)}}{2 \, \pi}
# 2. & 3. f(t) = 1/(pi*gamma) * (gamma^2/((t - x_0)^2 + gamma^2)) F(x) = integral(f(t), t, -oo, x) show(F) print "" plot(F,-4, 4)
x  0.5(π+2arctan(2x))π\displaystyle x \ {\mapsto}\ \frac{0.5 \, {\left(\pi + 2 \, \arctan\left(2 \, x\right)\right)}}{\pi}

Problem 4 -- a function with no elementary antiderivative:

Let f(x)=sin(x2)+exp(1/x)f(x) = \sin(x^2) + \exp(1/x)

  1. Draw a plot of ff on the interval [1/2,4][1/2, 4].

  2. Differentiate ff

  3. Integrate ff

Problem 5: Limits

  1. Compute limx0sin(x)/x\lim_{x\to 0} \sin(x)/x

  2. Use Sage to verify that strange and amazing fact limx0(cosx)1/x2=1e\lim_{x\to 0} (\cos x)^{1/x^2} = \frac{1}{\sqrt{e}}.

# Solution
limit(sin(x)/x, x=0) limit(cos(x)^(1/x^2), x=0)
1 e^(-1/2)

Problem 6: Taylor Series

Let f(x)=sin(x2)f(x) = \sin(x^2)

  1. Find the 3rd degree taylor series, p3(x)p_3(x), of ff where x0=2πx_0 = 2\pi

  2. Plot the 10th degree taylor series p10(x)p_{10}(x) where x0=2πx_0 = 2\pi alongside ff

  • Plot on the interval $x=[\pi, 3\pi

# 1 f(x) = sin(x^2) p_3(x) = taylor(f(x), x, 2*pi, 3) show(p_3)
x  43(2πx)3(8π3cos(4π2)+3πsin(4π2))(2πx)2(8π2sin(4π2)cos(4π2))4π(2πx)cos(4π2)+sin(4π2)\displaystyle x \ {\mapsto}\ \frac{4}{3} \, {\left(2 \, \pi - x\right)}^{3} {\left(8 \, \pi^{3} \cos\left(4 \, \pi^{2}\right) + 3 \, \pi \sin\left(4 \, \pi^{2}\right)\right)} - {\left(2 \, \pi - x\right)}^{2} {\left(8 \, \pi^{2} \sin\left(4 \, \pi^{2}\right) - \cos\left(4 \, \pi^{2}\right)\right)} - 4 \, \pi {\left(2 \, \pi - x\right)} \cos\left(4 \, \pi^{2}\right) + \sin\left(4 \, \pi^{2}\right)
# 2 f(x) = sin(x^2) p_10(x) = taylor(f(x), x, 2*pi, 10) P1 = plot(p_10(x), pi, 3*pi, ymax=2, ymin=-2) P2 = plot(f(x), pi, 3*pi, linestyle='--') show(P1 + P2)

Problem 7 - Gradient Vector Field:

  1. Compute the gradient of f(x,y)=3sin(x)2cos(2y)xyf(x,y) = 3\sin(x) - 2\cos(2y) - x - y.

  2. Plot the 2-dimensiona vector field defined by the gradient of ff in the rectangle 2x,y2-2 \leq x,y \leq 2.

f(x,y) = 3*sin(x) - 2*cos(2*y) - x- y plot_vector_field(f.gradient(), (x,-2,2), (y,-2,2))

Problem 8 - Symbolic Sums:

  1. Compute n=1(1)nn\sum_{n=1}^{\infty} \frac{(-1)^n}{n}.

  2. Compute n=11n2\sum_{n=1}^{\infty} \frac{1}{n^2}.

  3. Compute n=11n3\sum_{n=1}^{\infty} \frac{1}{n^3} both symbolically (in terms of the Riemann Zeta function) and numerically.

  4. Compute n=11n4\sum_{n=1}^{\infty} \frac{1}{n^4}.

  5. Compute n=1ksin(n)\sum_{n=1}^k \sin(n).

# Solution
%var n show(sum((-1)^n/n, n, 1, oo))
log(2)\displaystyle -\log\left(2\right)
%var n show(sum(1/n^2, n, 1, oo))
16π2\displaystyle \frac{1}{6} \, \pi^{2}
%var n show(sum(1/n^3, n, 1, oo)) N(sum(1/n^3, n, 1, oo))
ζ(3)\displaystyle \zeta(3)
1.20205690315959
%var n show(sum(1/n^4, n, 1, oo))
190π4\displaystyle \frac{1}{90} \, \pi^{4}

Problem 9 -- Unit Conversion:

Use Sage's units functionality (written by a UW undergrad -- David Ackerman!)

  1. Convert 68 degrees Fahrenheit to Celcius. Hint: use 68*units.temperature.fahrenheit to define fahrenheit.

  2. Convert 15 milliseconds to hours.

  3. Convert 2016 degrees kelvins to degrees Fahrenheit.

  4. Convert 9.8 meters per second squared to feet per second squared.

# Solution:
a = 68*units.temperature.fahrenheit a.convert(units.temperature.celsius)
20*celsius

Problem 10 - 3d Plotting:

  1. Draw a 3d plot of a torus.

  2. Draw a single 3d plot the has the five regular polytopes in it: tetrahedron, cube, octahedron, dodecahedron, icosahedron. All five must be visible.

  3. Draw a 3d plot of the "Mexican hat function" (see, e.g., https://en.wikipedia.org/wiki/Mexican_hat_wavelet). [Hint: you have to make a choice of parameter σ\sigma so that it looks like Mexican hat.]

# Solution:
u, v = var('u,v') f1 = (4+(3+cos(v))*sin(u), 4+(3+cos(v))*cos(u), 4+sin(v)) parametric_plot3d(f1, (u,0,2*pi), (v,0,2*pi), texture="red", mesh=2)
3D rendering not yet implemented
tetrahedron() + cube().translate((1,0,0)) + octahedron().translate((2,0,0)) + dodecahedron().translate((3,0,0)) + icosahedron().translate((4,0,0))
3D rendering not yet implemented
sigma = -1/2 f(x,y) = 1/(pi*sigma^4) * (1-((x^2+y^2)/(2*sigma^2)))*exp(-(x^2+y^2)/(2*sigma^2)) plot3d(f, (x,-2,2), (y,-2,2))
3D rendering not yet implemented