Course Test · University: first two years
Calculus II: 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.Integration by partsAgreesIndependent answer.RatMath code
symbolic.integrate("x*exp(x)", "x").resultOutputx*exp(x) - exp(x)
- 2.Parts with a logarithmAgreesIndependent answer.RatMath code
symbolic.integrate("x^2*log(x)", "x").resultOutput-x^3/9 + x^3*log(x)/3
- 3.Trigonometric integralAgreesIndependent answer.RatMath code
const F = symbolic.integrate("sin(x)^3", "x"); PRINT(F); symbolic.equal(String(F.result), "-cos(x) + cos(x)^3/3")Outputequal (normal form, after the rules the assumptions allow)
- 4.Arctangent formAgreesIndependent answer.RatMath code
symbolic.integrate("1/(x^2 + 4)", "x").resultOutputatan(x/2)/2
- 5.Trigonometric substitutionAgreesIndependent answer.RatMath code
symbolic.integrate("1/sqrt(9 - x^2)", "x").resultOutputasin(x/3)
- 6.Partial fractionsAgreesIndependent answer: .RatMath code
[symbolic.apart("(3x + 5)/((x + 1)(x + 2))", "x"), symbolic.integrate("(3x + 5)/((x + 1)(x + 2))", "x").result]Output[2/(x + 1) + 1/(x + 2), 2*log(abs(1 + x)) + log(abs(2 + x))]
- 7.Improper integral, infinite intervalAgreesIndependent answer.RatMath code
symbolic.integrate("1/x^2", "x", { from: 1, to: "inf" }).valueOutput1
Bug:to: "inf"was read as a letter named inf, so the value came back as(inf - 1)/inf.Fix: ratmath/symbolic#8, improper integrals:"inf"ends and integrands unbounded at an end - 8.Improper integral, unbounded integrandAgreesIndependent answer.RatMath code
symbolic.integrate("1/sqrt(x)", "x", { from: 0, to: 1 }).valueOutput2
symbolic finds but declines the definite integral (valuenull: the integrand cannot be bounded on the interval). That is honest, but the improper integral converges and the antiderivative has a limit at 0.Fix: ratmath/symbolic#8, improper integrals:"inf"ends and integrands unbounded at an end - 9.Volume of revolutionAgreesThe region under , , is turned about the -axis. Find the volume.Independent answer.RatMath code
symbolic.integrate("pi*sqrt(x)^2", "x", { from: 0, to: 4 }).valueOutput8*pi
- 10.Arc lengthAgreesFind the length of from to .Independent answer.RatMath code
const dy = symbolic.sym("2/3*x^(3/2)").diff("x"); symbolic.integrate(`sqrt(1 + (${dy})^2)`, "x", { from: 0, to: 3 }).valueOutput14/3
- 11.Simpson's ruleAgreesUse Simpson's rule with to estimate . Compare with the exact value.Independent answer; exact .RatMath code
const f = (x) => R`1/(1 + ${x}^2)`, h = R`1/4`; const S = h.divide(R`3`).multiply(f(0).add(R`4`.multiply(f(h))).add(R`2`.multiply(f(R`1/2`))).add(R`4`.multiply(f(R`3/4`))).add(f(1))); [S, symbolic.integrate("1/(1 + x^2)", "x", { from: 0, to: 1 }).value]Output[8011/10200, pi/4]
- 12.Limit of a sequenceAgreesIndependent answer.RatMath code
symbolic.limit("(1 + 2/n)^n", "n", "inf").valueOutpute^2
- 13.p-seriesAgreesDoes converge? What is its sum?Independent answerYes (a -series with ); the sum is .RatMath code
[analytic.sum("1/k^2", { variable: "k" }).convergence().convergence, symbolic.sum("1/k^2", "k", 1, "inf").value]Output["absolutely convergent", pi^2/6]
- 14.Ratio testAgreesShow converges and find its sum.Independent answerRatio . Using at : sum 6.RatMath code
[analytic.sum("k^2/2^k", { variable: "k" }).ratioTest().conclusion ?? analytic.sum("k^2/2^k", { variable: "k" }).convergence().convergence, symbolic.sum("k^2/2^k", "k", 1, "inf").value]Output["absolutely convergent", 6]
- 15.Alternating seriesAgreesDoes converge absolutely, conditionally, or not at all? What is the sum?Independent answerConditionally (the harmonic series diverges; the alternating series test applies). Sum .RatMath code
[analytic.sum("(-1)^(k+1)/k", { variable: "k" }).convergence().convergence, symbolic.sum("(-1)^(k+1)/k", "k", 1, "inf").value]Output["conditionally convergent", log(2)]
- 16.Interval of convergenceAgreesFind the interval of convergence of .Independent answer. At : harmonic, diverges; at : alternating harmonic, converges. .RatMath code
analytic.powerSeries("1/(n*2^n)", { index: "n", from: 1, centre: 3 }).interval().textOutput[1, 5)
- 17.Taylor polynomialAgreesFind the degree-4 Taylor polynomial of at 0.Independent answer.RatMath code
symbolic.taylor("cos(x)", "x", 0, 4)Output1 - 1/2*x^2 + 1/24*x^4 + …
- 18.Taylor series about a pointAgreesExpand about up to .Independent answer.RatMath code
symbolic.taylor("exp(x)", "x", 1, 3)Outpute + e*(x - 1) + e/2*(x - 1)^2 + e/6*(x - 1)^3 + …
- 19.Remainder boundAgreesApproximate by its degree-2 Maclaurin polynomial and bound the error.Independent answer. . (True error .)RatMath code
const T = symbolic.taylor("exp(x)", "x", 0, 2); const r = analytic.taylorRemainder("exp(x)", { about: 0, order: 2, on: [0, "0.1"] }); [String(T.polynomial), T.polynomial.evaluate({ x: "0.1" }).low.toDecimal(), r.bound.lessThan(R`0.0002`), r.actual.high.toDecimal(6)]Output["1 + x + 1/2*x^2", "1.105", true, "0.000170"]
taylorRemainder gives Lagrange's bound (below 0.0002) and an enclosure of the true maximum error. - 20.Polar areaAgreesFind the area inside .Independent answer(a circle of radius 1).RatMath code
symbolic.integrate("1/2*(2cos(t))^2", "t", { from: "-pi/2", to: "pi/2" }).valueOutputpi