Course Test · University: upper level

Real analysis: 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.Limit of a sequenceAgrees
    Find lim⁡n→∞3n2+12n2−n\displaystyle\lim_{n\to\infty} \frac{3n^2 + 1}{2n^2 - n}.
    Independent answer
    Divide by n2n^2: 3+1/n22−1/n→32\dfrac{3 + 1/n^2}{2 - 1/n} \to \dfrac32.
    RatMath code
    analytic.sequence("(3n^2 + 1)/(2n^2 - n)").limit()
    Output
    3/2
  2. 2.An N for a given εAgrees
    Find the least NN such that 1n<0.01\dfrac1{\sqrt n} < 0.01 for every n≥Nn \ge N.
    Independent answer
    n>100  ⟺  n>10000\sqrt n > 100 \iff n > 10000: N=10001N = 10001.
    RatMath code
    const r = analytic.sequence("1/sqrt(n)").nFor("1/100");
    [r.N, r.least, analytic.verifyCertificate(r.certificate).valid]
    Output
    [10001, true, true]
    nFor proves the tail (the terms fall to the limit, so the distance never grows) and finds the least NN: 10000 fails because 1/100001/\sqrt{10000} equals ε\varepsilon. verifyCertificate rechecks the result by another route.
    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.Monotone sequences and the supremumAgrees
    Let an=1−1na_n = 1 - \tfrac1n. Is it monotone? Find sup⁡an\sup a_n and inf⁡an\inf a_n.
    Independent answer
    Increasing, since 1n\tfrac1n decreases. inf⁡=a1=0\inf = a_1 = 0 (attained); sup⁡=lim⁡an=1\sup = \lim a_n = 1 (not attained).
    RatMath code
    const a = analytic.sequence("1 - 1/n");
    const [s, i] = [a.supremum(), a.infimum()];
    [a.monotone().direction, s.value, s.attained, i.value, i.attained]
    Output
    ["increasing", 1, false, 0, true]
    supremum() and infimum() give the value and whether a term takes it, from the proven direction: an increasing sequence approaches its limit without reaching it, and its first term is its least.
    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
  4. 4.Telescoping seriesAgrees
    Sum ∑n=1∞1n(n+1)\displaystyle\sum_{n=1}^{\infty} \frac{1}{n(n+1)}.
    Independent answer
    1n(n+1)=1n−1n+1\dfrac1{n(n+1)} = \dfrac1n - \dfrac1{n+1}; partial sums 1−1N+1→11 - \dfrac1{N+1} \to 1.
    RatMath code
    symbolic.sum("1/(n*(n+1))", "n", 1, "inf").value
    Output
    1
  5. 5.Ratio testAgrees
    Does ∑n!nn\displaystyle\sum \frac{n!}{n^n} converge? Find the limit of the ratio of consecutive terms.
    Independent answer
    an+1an=(nn+1)n→1e<1\dfrac{a_{n+1}}{a_n} = \left(\dfrac{n}{n+1}\right)^n \to \dfrac1e < 1: converges.
    RatMath code
    [analytic.sum("n!/n^n").ratioTest().verdict, analytic.sequence("(n/(n+1))^n").limit()]
    Output
    ["convergent", 0.36787944117144232159:0.3678794411714423216]
    The ratio (n/(n+1))n(n/(n+1))^n is a power with a moving exponent; its limit 1/e1/e is now proven (as an enclosure), so ratioTest() concludes.
    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
  6. 6.Alternating series errorAgrees
    How many terms of ∑n≥1(−1)n+1n2\displaystyle\sum_{n\ge1} \frac{(-1)^{n+1}}{n^2} guarantee an error below 0.001?
    Independent answer
    The error after NN terms is below 1(N+1)2\dfrac1{(N+1)^2}; (N+1)2>1000(N + 1)^2 > 1000 needs N+1≥32N + 1 \ge 32, so N=31N = 31.
    RatMath code
    const r = analytic.sum("(-1)^(n+1)/n^2").termsForError("1/1000");
    [r.terms, r.bound]
    Output
    [31, 1/1024]
    termsForError proves the term sizes decrease, then finds the first NN with ∣aN+1∣≤0.001|a_{N+1}| \le 0.001; the bound is 1/3221/32^2.
    Fix: ratmath/analytic#19, termsForError, newton(..., { exact: true }), darboux, pde.classify, gradientDescent
  7. 7.Radius of convergenceAgrees
    Find the radius of convergence of ∑n23nxn\displaystyle\sum \frac{n^2}{3^n} x^n.
    Independent answer
    ∣cn+1cn∣=(n+1)23n2→13\left|\dfrac{c_{n+1}}{c_n}\right| = \dfrac{(n+1)^2}{3n^2} \to \dfrac13, so R=3R = 3.
    RatMath code
    analytic.powerSeries("n^2/3^n").radius().radius
    Output
    3
  8. 8.Limits of functionsAgrees
    Find lim⁡x→01−cos⁡xx2\displaystyle\lim_{x\to0}\frac{1 - \cos x}{x^2}.
    Independent answer
    1−cos⁡x=x22−x424+⋯1 - \cos x = \tfrac{x^2}{2} - \tfrac{x^4}{24} + \cdots, so the limit is 12\tfrac12.
    RatMath code
    symbolic.limit("(1 - cos(x))/x^2", "x", 0).value
    Output
    1/2
  9. 9.A δ for a given εAgrees
    For f(x)=x2f(x) = x^2 at a=2a = 2 and ε=0.01\varepsilon = 0.01, show δ=min⁡(1,ε/5)=0.002\delta = \min(1, \varepsilon/5) = 0.002 works.
    Independent answer
    If ∣x−2∣<δ≤1|x - 2| < \delta \le 1 then ∣x+2∣<5|x + 2| < 5, so ∣x2−4∣=∣x−2∣∣x+2∣<5δ≤ε|x^2 - 4| = |x - 2||x + 2| < 5\delta \le \varepsilon. Concretely the worst case is (2.002)2−4=0.008004<0.01(2.002)^2 - 4 = 0.008004 < 0.01.
    RatMath code
    const r = analytic.deltaFor("x^2", 2, "1/100", { delta: "0.002" });
    [r.holds, r.worst, analytic.verifyCertificate(r.certificate).valid, analytic.deltaFor("x^2", 2, "1/100").largest]
    Output
    [true, 2001/250000, true, 0.0024984394500785727[6:7]]
    deltaFor proves that δ=0.002\delta = 0.002 works (the worst case is at the end 2.0022.002, since x2x^2 is monotone on each side of 2), the certificate is rechecked by plain interval evaluation, and without a δ\delta it also gives the largest one, 4.01−2\sqrt{4.01} - 2.
    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
  10. 10.Mean value theoremAgrees
    Find the cc in (0,2)(0, 2) promised by the mean value theorem for f(x)=x3f(x) = x^3.
    Independent answer
    f(2)−f(0)2=4=3c2\dfrac{f(2) - f(0)}{2} = 4 = 3c^2, so c=23=233≈1.1547c = \dfrac{2}{\sqrt3} = \dfrac{2\sqrt3}{3} \approx 1.1547.
    RatMath code
    symbolic.solve("3x^2 = 4", "x", { assume: { x: "in (0, 2)" } })
    Output
    x = 2*sqrt(3)/3
    With the interval as an assumption only the root in (0,2)(0, 2) comes back; without it solve returns both ±23/3\pm 2\sqrt3/3.
  11. 11.Intermediate value theoremAgrees
    Show x3−x−1x^3 - x - 1 has a root in [1,2][1, 2] and find it to six decimals.
    Independent answer
    f(1)=−1<0<5=f(2)f(1) = -1 < 0 < 5 = f(2). Bisection or Newton gives x≈1.324718x \approx 1.324718 (the plastic number).
    RatMath code
    analytic.bisection("x^3 - x - 1", ["1", "2"]).root
    Output
    1.3247179572447460259[6:7]
  12. 12.Taylor's remainderAgrees
    Bound the error of the degree-4 Taylor polynomial of exe^x about 0 on [0,1][0, 1], and compare with the true error.
    Independent answer
    Lagrange: ∣R4∣≤e⋅155!=e120≈0.02265|R_4| \le \dfrac{e\cdot1^5}{5!} = \dfrac{e}{120} \approx 0.02265. The true maximum error, at x=1x = 1, is e−6524≈0.009948e - \tfrac{65}{24} \approx 0.009948.
    RatMath code
    const T = analytic.taylorRemainder("exp(x)", { order: 4, on: ["0", "1"] });
    [T.bound, T.actual]
    Output
    [0.022652348570492043628002…, 0.0099484951257119020[2:3]]
  13. 13.Darboux sumsAgrees
    Compute the lower and upper sums of f(x)=x2f(x) = x^2 on [0,1][0, 1] with four equal pieces.
    Independent answer
    ff is increasing: L=14(0+116+416+916)=732L = \tfrac14(0 + \tfrac1{16} + \tfrac4{16} + \tfrac9{16}) = \tfrac{7}{32}, U=14(116+416+916+1)=1532U = \tfrac14(\tfrac1{16} + \tfrac4{16} + \tfrac9{16} + 1) = \tfrac{15}{32}.
    RatMath code
    const d = analytic.darboux("x^2", { interval: [0, 1], n: 4 });
    [d.lower, d.upper, d.exact]
    Output
    [7/32, 15/32, true]
    darboux proves x2x^2 increasing on each piece, so the inf and sup are end values and the sums are exact.
    Fix: ratmath/analytic#19, termsForError, newton(..., { exact: true }), darboux, pde.classify, gradientDescent
  14. 14.An improper integralAgrees
    Evaluate ∫01ln⁡x dx\displaystyle\int_0^1 \ln x\,dx.
    Independent answer
    lim⁡a→0+[xln⁡x−x]a1=−1−lim⁡a→0+(aln⁡a−a)=−1\displaystyle\lim_{a\to0^+}\big[x\ln x - x\big]_a^1 = -1 - \lim_{a\to0^+}(a\ln a - a) = -1.
    RatMath code
    symbolic.integrate("ln(x)", "x", { from: 0, to: 1 }).value
    Output
    -1
    Used to return null: an endpoint where the antiderivative needs a limit was not handled. Now the value is the one-sided limits of the antiderivative, checked against analytic's certified improper integral.
    Fix: ratmath/symbolic#8, improper integrals: "inf" ends and integrands unbounded at an end
  15. 15.Pointwise limitAgrees
    Find the pointwise limit of fn(x)=xnf_n(x) = x^n on [0,1][0, 1].
    Independent answer
    00 for 0≤x<10 \le x < 1 and 11 at x=1x = 1: a discontinuous limit of continuous functions.
    RatMath code
    const F = analytic.functionSequence("x^n");
    [F.pointwise("1/2"), F.pointwise("1")]
    Output
    [0, 1]
    The two calls give 0 and 1. For every 0 ≤ x < 1, the powers tend to zero by geometric decay, and at x = 1 every term is one.
    Fix: ratmath/analytic#18, exact starting values, pointwise limits, sec/csc/cot, integrating factors with 1/∣x∣1/|x|, ODESolution exported
  16. 16.Uniform convergenceAgrees
    Does xn→0x^n \to 0 uniformly on [0,12][0, \tfrac12]? On [0,1)[0, 1)?
    Independent answer
    On [0,12][0, \tfrac12]: sup⁡∣xn∣=2−n→0\sup|x^n| = 2^{-n} \to 0, so yes. On [0,1)[0, 1): sup⁡=1\sup = 1 for every nn, so no.
    RatMath code
    const F = analytic.functionSequence("x^n");
    [F.uniform(["0", "1/2"]).verdict, F.uniform(["0", "1"]).verdict]
    Output
    ["uniform", "not uniform"]
    The code takes two closed intervals. For the half-open interval in the question, fix n ≥ 1. As x approaches 1 from below, xⁿ approaches 1, so its supremum is 1 even though it is never attained. This proves failure of uniform convergence to zero.
    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
  17. 17.Limits superior and inferiorAgrees
    Find lim sup⁡\limsup and lim inf⁡\liminf of an=(−1)n(1+1n)a_n = (-1)^n\left(1 + \tfrac1n\right).
    Independent answer
    Even terms 1+1n→11 + \tfrac1n \to 1; odd terms −(1+1n)→−1-(1 + \tfrac1n) \to -1. lim sup⁡=1\limsup = 1, lim inf⁡=−1\liminf = -1; no limit.
    RatMath code
    const a = analytic.sequence("(-1)^n*(1 + 1/n)");
    [a.limsup(), a.liminf(), a.accumulation().converges]
    Output
    [1, -1, false]
    The sequence is split into n=2mn = 2m and n=2m+1n = 2m + 1; the two limits are the only accumulation points. limit() now refuses with “the terms oscillate, with lim sup 1 and lim inf -1”.
    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
  18. 18.Series valueAgrees
    Find ∑n=1∞(−1)n+1n2\displaystyle\sum_{n=1}^{\infty} \frac{(-1)^{n+1}}{n^2}.
    Independent answer
    (1−2⋅14)ζ(2)=12⋅π26=π212\left(1 - 2\cdot\tfrac14\right)\zeta(2) = \tfrac12\cdot\tfrac{\pi^2}{6} = \tfrac{\pi^2}{12}.
    RatMath code
    symbolic.sum("(-1)^(n+1)/n^2", "n", 1, "inf").value
    Output
    pi^2/12
  19. 19.Contraction mappingAgrees
    Show g(x)=cos⁡xg(x) = \cos x is a contraction on [0,1][0, 1] and find its fixed point.
    Independent answer
    gg maps [0,1][0, 1] into [cos⁡1,1]⊂[0,1][\cos 1, 1] \subset [0, 1] and ∣g′(x)∣=∣sin⁡x∣≤sin⁡1<1|g'(x)| = |\sin x| \le \sin 1 < 1. The fixed point (the Dottie number) is 0.7390851332…0.7390851332\ldots.
    RatMath code
    // the two hypotheses, each from a certified range over [0, 1], then the fixed point
    const slope = analytic.fn("sin(x)").range(["0", "1"]).exact();   // g′ = −sin x
    const image = analytic.fn("cos(x)").range(["0", "1"]).exact();
    const one = new Rational(1n);
    // |g′| < 1 on [0, 1]; g ≥ 0 there, and cos ≤ 1 everywhere, so g maps [0, 1] into itself
    [slope.high.lessThan(one) && slope.low.greaterThan(one.negate()), image.low.greaterThan(new Rational(0n)), analytic.fixedPoint("cos(x)", "1").root]
    Output
    [true, true, 0.7390851332151606416[5:6]]
    Both hypotheses of the contraction mapping theorem are checked from certified ranges (sup⁡∣sin⁡x∣=sin⁡1≈0.84\sup|\sin x| = \sin 1 \approx 0.84 and cos⁡([0,1])=[cos⁡1,1]\cos([0, 1]) = [\cos 1, 1]), then the certified fixed point.
  20. 20.Euler's numberAgrees
    Find lim⁡n→∞(1+1n)n\displaystyle\lim_{n\to\infty}\left(1 + \frac1n\right)^n and show the sequence is increasing.
    Independent answer
    The limit is ee. By AM–GM on nn copies of 1+1n1 + \tfrac1n and one 1, an≤an+1a_n \le a_{n+1}.
    RatMath code
    const a = analytic.sequence("(1 + 1/n)^n");
    const m = a.monotone();
    [a.limit(), m.direction, m.proven]
    Output
    [2.7182818284590452353[6:7], "increasing", "for every n ≥ 1"]
    The limit is enclosed, and monotone() now proves the direction through the derivative of the logarithm, log⁡(1+1/n)−1/(n+1)\log(1 + 1/n) - 1/(n + 1), which tends to 0 while decreasing and so is positive.
    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