Course Test · University: upper level

Partial differential equations: RatMath answers

The same twenty exercises, answered with RatMath Core and the Shelf libraries only. The code below was run when this page was built; its output is shown as printed, and compared with the independent answer.

Agrees 20

Libraries used here: core, analytic, symbolic. In this code each library is in scope under its own name (linalg.det, stats.tTest), and Core's names (R, Rational, …) are in scope directly.

  1. 1.ClassificationAgrees
    Classify uxx+4uxy+3uyy=0u_{xx} + 4u_{xy} + 3u_{yy} = 0 as elliptic, parabolic or hyperbolic.
    Independent answer
    B2−4AC=16−12=4>0B^2 - 4AC = 16 - 12 = 4 > 0: hyperbolic.
    RatMath code
    const c = analytic.pde.classify({ A: 1, B: 4, C: 3 });
    [c.discriminant, c.type]
    Output
    ["4", "hyperbolic"]
    pde.classify takes the sign of B2−4ACB^2 - 4AC; with coefficients in xx and yy it returns the region of each type.
    Fix: ratmath/analytic#19, termsForError, newton(..., { exact: true }), darboux, pde.classify, gradientDescent
  2. 2.CharacteristicsAgrees
    Solve ut+2ux=0u_t + 2u_x = 0 with u(x,0)=e−x2u(x, 0) = e^{-x^2}, and find u(1,12)u(1, \tfrac12).
    Independent answer
    uu is constant on the lines x−2t=constx - 2t = \text{const}, so u=e−(x−2t)2u = e^{-(x - 2t)^2} and u(1,12)=e0=1u(1, \tfrac12) = e^0 = 1.
    RatMath code
    const u = analytic.pde.transport({ speed: 2, initial: "exp(-x^2)" });
    [u.formula, u.characteristics, u.at(1, "1/2").value]
    Output
    ["exp(-(x - 2*t)^2)", "x - 2*t = const", 1]
    pde.transport solves along characteristics: here a closed formula, and the value at the point is exactly 1 because the foot of the characteristic is x=0x = 0. With a speed that depends on uu it reports the breaking time and refuses past it.
    Fix: ratmath/analytic#20, nFor, deltaFor and verifyCertificate; supremum, limsup, liminf; limits of f(n)g(n)f(n)^{g(n)}; uniform convergence decided both ways; pde.transport; exact finite-mode Laplace solutions
  3. 3.Heat equation, fixed endsAgrees
    A rod 0≤x≤10 \le x \le 1 with ut=uxxu_t = u_{xx}, ends held at 0, starts at u(x,0)=x(1−x)u(x, 0) = x(1 - x). Find u(12,110)u(\tfrac12, \tfrac1{10}).
    Independent answer
    bn=8/(nπ)3b_n = 8/(n\pi)^3 for odd nn, so u=∑n odd8n3π3e−n2π2tsin⁡nπxu = \sum_{n \text{ odd}} \frac{8}{n^3\pi^3} e^{-n^2\pi^2 t}\sin n\pi x; at the point, 0.09616190.0961619.
    RatMath code
    analytic.heat({ k: 1, length: 1, initial: "x*(1 - x)", terms: 8 }).at("1/2", "1/10").value
    Output
    0.0961618714341978422:0.09616187143494386749
  4. 4.Fourier sine coefficientsAgrees
    For the same rod, what is the first coefficient b1b_1 of the sine series?
    Independent answer
    b1=2∫01x(1−x)sin⁡πx dx=8/π3≈0.258012b_1 = 2\int_0^1 x(1 - x)\sin \pi x\,dx = 8/\pi^3 \approx 0.258012.
    RatMath code
    analytic.heat({ k: 1, length: 1, initial: "x*(1 - x)" }).modes[0].coefficient
    Output
    0.2580122754652123854:0.25801227546718121957
  5. 5.Decay ratesAgrees
    For ut=2uxxu_t = 2u_{xx} on 0<x<30 < x < 3 with fixed ends, at what rate does the slowest mode decay?
    Independent answer
    k(π/L)2=2π2/9≈2.19325k(\pi/L)^2 = 2\pi^2/9 \approx 2.19325.
    RatMath code
    analytic.heat({ k: 2, length: 3, initial: "x*(3 - x)" }).modes[0].rate
    Output
    2*(pi/3)^2
  6. 6.Heat equation, insulated endsAgrees
    A rod 0≤x≤10 \le x \le 1 with insulated ends starts at u(x,0)=xu(x, 0) = x. Find u(0,1)u(0, 1), and the temperature it tends to.
    Independent answer
    Cosine series: u=12−∑n odd4n2π2e−n2π2tcos⁡nπxu = \tfrac12 - \sum_{n\text{ odd}} \frac{4}{n^2\pi^2} e^{-n^2\pi^2 t}\cos n\pi x. So u(0,1)≈0.4999790u(0, 1) \approx 0.4999790, tending to the mean, 12\tfrac12.
    RatMath code
    analytic.heat({ length: 1, initial: "x", ends: "insulated" }).at(0, 1).value
    Output
    0.4999790373822083[0213:2744]
  7. 7.Wave equation, d'AlembertAgrees
    A string 0≤x≤10 \le x \le 1 with c=1c = 1 starts at rest in the shape sin⁡πx\sin \pi x. Find u(14,13)u(\tfrac14, \tfrac13).
    Independent answer
    u=sin⁡πxcos⁡πtu = \sin \pi x \cos \pi t, so u=sin⁡π4cos⁡π3=24≈0.353553u = \sin\tfrac\pi4\cos\tfrac\pi3 = \tfrac{\sqrt2}{4} \approx 0.353553.
    RatMath code
    analytic.wave({ c: 1, length: 1, position: "sin(pi*x)" }).at("1/4", "1/3")
    Output
    0.3535533905932737622:0.35355339059327376221
  8. 8.Periodicity of a stringAgrees
    A plucked string 0≤x≤10 \le x \le 1, c=1c = 1, starts at rest as x(1−x)x(1 - x). Compare u(13,2)u(\tfrac13, 2) with u(13,0)u(\tfrac13, 0).
    Independent answer
    The motion has period 2L/c=22L/c = 2, so both are 13⋅23=29\tfrac13 \cdot \tfrac23 = \tfrac29.
    RatMath code
    const s = analytic.wave({ c: 1, length: 1, position: "x*(1 - x)" });
    [s.at("1/3", 2), s.at("1/3", 0)]
    Output
    [2/9, 2/9]
  9. 9.Waves on a lineAgrees
    On the whole line, utt=uxxu_{tt} = u_{xx} with u(x,0)=e−x2u(x, 0) = e^{-x^2} and ut(x,0)=0u_t(x, 0) = 0. Find u(3,3)u(3, 3).
    Independent answer
    u=12(e−(x−t)2+e−(x+t)2)u = \tfrac12\bigl(e^{-(x-t)^2} + e^{-(x+t)^2}\bigr), so u(3,3)=12(1+e−36)≈0.5u(3, 3) = \tfrac12(1 + e^{-36}) \approx 0.5.
    RatMath code
    analytic.wave({ c: 1, position: "exp(-x^2)" }).at(3, 3)
    Output
    0.5000000000000001159[7:8]
  10. 10.Initial velocityAgrees
    On the whole line, utt=uxxu_{tt} = u_{xx} with u(x,0)=0u(x, 0) = 0 and ut(x,0)=1/(1+x2)u_t(x, 0) = 1/(1 + x^2). Find u(0,1)u(0, 1).
    Independent answer
    u=12∫x−tx+tds1+s2u = \tfrac12\int_{x-t}^{x+t}\frac{ds}{1 + s^2}, so u(0,1)=arctan⁡1=π/4≈0.785398u(0, 1) = \arctan 1 = \pi/4 \approx 0.785398.
    RatMath code
    analytic.wave({ c: 1, position: "0", velocity: "1/(1 + x^2)" }).at(0, 1)
    Output
    0.785398163397[10379986:79262657]
  11. 11.Laplace on a rectangleAgrees
    Solve Δu=0\Delta u = 0 on the unit square with u=sin⁡πxu = \sin \pi x on the top edge and 0 on the other three. Find u(12,12)u(\tfrac12, \tfrac12).
    Independent answer
    u=sinh⁡πysinh⁡πsin⁡πxu = \frac{\sinh \pi y}{\sinh \pi}\sin \pi x, so u=sinh⁡(π/2)/sinh⁡π≈0.199268u = \sinh(\pi/2)/\sinh \pi \approx 0.199268.
    RatMath code
    analytic.laplaceRectangle({ top: "sin(pi*x)", terms: 16 }).at("1/2", "1/2").value
    Output
    0.1992684076691933402[1:2]
    The tail bound does not know that only one mode is present, so 16 terms are needed for a tight enclosure: with 4 terms it is about 0.002 wide.
  12. 12.Mean value propertyAgrees
    A disc of radius 1 has its rim held at cos⁡2θ\cos^2\theta. What is the steady temperature at the centre?
    Independent answer
    The mean of the boundary values: 12π∫02πcos⁡2θ dθ=12\tfrac1{2\pi}\int_0^{2\pi}\cos^2\theta\,d\theta = \tfrac12.
    RatMath code
    analytic.laplaceDisc({ boundary: "cos(theta)^2", terms: 4 }).mean
    Output
    1/2
  13. 13.Laplace on a discAgrees
    For the same disc, find uu at r=12r = \tfrac12, θ=0\theta = 0.
    Independent answer
    cos⁡2θ=12+12cos⁡2θ\cos^2\theta = \tfrac12 + \tfrac12\cos 2\theta, so u=12+12r2cos⁡2θu = \tfrac12 + \tfrac12 r^2\cos 2\theta and u=12+18=58u = \tfrac12 + \tfrac18 = \tfrac58.
    RatMath code
    analytic.laplaceDisc({ boundary: "cos(theta)^2", terms: 32 }).at("1/2", 0).value
    Output
    5/8
    The answer is exact after two terms, but the tail bound shrinks only like rnr^n: with 4 terms the enclosure is [0.375,0.875][0.375, 0.875], with 32 it is within 10−910^{-9}. The partial field holds the kept terms alone.
  14. 14.Sturm–Liouville eigenvaluesAgrees
    Find the first two eigenvalues of −y′′=λy-y'' = \lambda y, y(0)=y(1)=0y(0) = y(1) = 0.
    Independent answer
    λn=n2π2\lambda_n = n^2\pi^2: π2≈9.869604\pi^2 \approx 9.869604 and 4π2≈39.4784184\pi^2 \approx 39.478418.
    RatMath code
    analytic.sturmLiouville({ interval: [0, 1], count: 2 }).map((e) => e.eigenvalue)
    Output
    [9869603901/1000000000:9869604901/1000000000, 2467401069/62500000:4934802263/125000000]
  15. 15.Eigenvalues on a longer intervalAgrees
    Find the lowest eigenvalue of −y′′=λy-y'' = \lambda y, y(0)=y(2)=0y(0) = y(2) = 0.
    Independent answer
    λ1=(π/2)2=π2/4≈2.467401\lambda_1 = (\pi/2)^2 = \pi^2/4 \approx 2.467401.
    RatMath code
    analytic.sturmLiouville({ interval: [0, 2], count: 1 })[0].eigenvalue
    Output
    12337003/5000000:771063/312500
  16. 16.Heat on a lineAgrees
    On the whole line, ut=uxxu_t = u_{xx} with u(x,0)=e−x2u(x, 0) = e^{-x^2}. Find u(1,12)u(1, \tfrac12).
    Independent answer
    u=11+4te−x2/(1+4t)u = \frac{1}{\sqrt{1 + 4t}}e^{-x^2/(1 + 4t)}, so u(1,12)=e−1/3/3≈0.413690u(1, \tfrac12) = e^{-1/3}/\sqrt3 \approx 0.413690.
    RatMath code
    analytic.heatLine({ initial: "exp(-x^2)" }).at(1, "1/2")
    Output
    0.4136895450425679529:0.41368954504257877051
  17. 17.Conservation of heatAgrees
    For the same problem, show that the total heat ∫u dx\int u\,dx does not change, and find it.
    Independent answer
    ddt∫u dx=∫uxx dx=0\frac{d}{dt}\int u\,dx = \int u_{xx}\,dx = 0, so it stays ∫e−x2 dx=π≈1.772454\int e^{-x^2}\,dx = \sqrt\pi \approx 1.772454.
    RatMath code
    analytic.heatLine({ initial: "exp(-x^2)" }).heat()
    Output
    1.77245385090551[432259:858168]
  18. 18.Steady state with a sourceAgrees
    Find the steady temperature of a rod with a uniform heat source, u′′=−1u'' = -1, u(0)=u(1)=0u(0) = u(1) = 0, at the midpoint.
    Independent answer
    u=12x(1−x)u = \tfrac12 x(1 - x), so u(12)=18u(\tfrac12) = \tfrac18.
    RatMath code
    analytic.bvp({ f: "-1", interval: [0, 1], left: { y: 0 }, right: { y: 0 }, digits: 15 }).exact().at("1/2")
    Output
    0.12[49999999999475:50000000000475]
  19. 19.Expanding a constantAgrees
    A rod at temperature 1 has its ends plunged into ice. What is the first coefficient of its sine series on [0,1][0, 1]?
    Independent answer
    bn=2∫01sin⁡nπx dx=2(1−(−1)n)nπb_n = 2\int_0^1\sin n\pi x\,dx = \frac{2(1 - (-1)^n)}{n\pi}, so b1=4/π≈1.273240b_1 = 4/\pi \approx 1.273240.
    RatMath code
    analytic.heat({ initial: "1" }).modes[0].coefficient
    Output
    1.273239544735[14738003:25132866]
  20. 20.Checking a separated solutionAgrees
    Show that u=e−tsin⁡xu = e^{-t}\sin x solves ut=uxxu_t = u_{xx}.
    Independent answer
    ut=−e−tsin⁡xu_t = -e^{-t}\sin x and uxx=−e−tsin⁡xu_{xx} = -e^{-t}\sin x, so ut−uxx=0u_t - u_{xx} = 0.
    RatMath code
    const u = "exp(-t)*sin(x)";
    const D = (e, v) => symbolic.format(symbolic.differentiate(symbolic.parse(e), v));
    const ut = D(u, "t"), uxx = D(D(u, "x"), "x");
    PRINT("u_t =", ut, "  u_xx =", uxx);
    String(symbolic.simplify(`(${ut}) - (${uxx})`))
    Output
    0