Curves and regions

Eliminating a parameter, reversing an integral

Two changes of description. eliminate turns a parametrised curve into an equation in the coordinates. reverseOrder describes the region of an iterated integral with the other variable outside. Both find the new description by a method and then check it against the old one.

Using it

import { eliminate, reverseOrder } from "@ratmath/symbolic";

const e = eliminate({ x: "2*cos(t)", y: "3*sin(t)" }, "t");
e.equation;      // "9*x^2 + 4*y^2 = 36"
e.standard;      // "x^2/4 + y^2/9 = 1"
e.verified;      // "proven": the parametrisation was put back in

const r = reverseOrder("exp(y^2)", { outer: ["x", 0, 1], inner: ["y", "x", 1] });
r.text;                    // "∫ from 0 to 1 ∫ from 0 to y exp(y^2) dx dy"
String(r.reversed.value);  // "e/2 - 1/2"
r.agree;                   // "checked": certified values of both orders overlap

Eliminating a parameter

If x=p(t)/q(t)x = p(t)/q(t) and y=u(t)/w(t)y = u(t)/w(t) are rational functions, clearing denominators gives two polynomial equations in tt,

q(t) x−p(t)=0,w(t) y−u(t)=0. q(t)\,x - p(t) = 0, \qquad w(t)\,y - u(t) = 0 .

A point (x,y)(x, y) is on the curve when these have a common root tt. The resultant of two polynomials in tt is a polynomial in their coefficients that vanishes exactly when they have a common root (or both leading coefficients vanish), so the resultant with respect to tt is an equation in xx and yy alone that every point of the curve satisfies.

Sines and cosines are handled by making them unknowns. With s=sin⁡ts = \sin t and c=cos⁡tc = \cos t, multiples such as sin⁡2t=2sc\sin 2t = 2sc are polynomials in ss and cc, and the one relation between them is s2+c2=1s^2 + c^2 = 1. For the ellipse the equations are x−2c=0x - 2c = 0, y−3s=0y - 3s = 0, s2+c2−1=0s^2 + c^2 - 1 = 0; removing ss and then cc by resultants leaves 9x2+4y2−369x^2 + 4y^2 - 36. Exponentials ekte^{kt} are powers of one unknown w=etw = e^t in the same way, which covers cosh⁡\cosh and sinh⁡\sinh.

Extra factors. A resultant can vanish for reasons other than a common root, and a chain of resultants can square a factor or add one. So the result is factored, and each irreducible factor is tested by substituting the parametrisation: the fractions are put in and the numerator is reduced with s2+c2=1s^2 + c^2 = 1. Only factors that reduce to 0 are kept, and those dropped are listed in dropped. That substitution is a proof and does not depend on how the candidate was found, which is why verified can say "proven".

What the answer does not say. The curve lies on the equation; it may be only part of its solutions. x=t2x = t^2, y=t4y = t^4 gives y=x2y = x^2, but only the half with x≥0x \ge 0 is traced. And a curve such as the cycloid x=t−sin⁡tx = t - \sin t, y=1−cos⁡ty = 1 - \cos t, where tt appears both alone and inside a sine, satisfies no polynomial equation at all: eliminate refuses and says so.

With three or more coordinates one equation is not enough (a space curve is cut out by at least two), and the elimination is done with a Gröbner basis; equations lists them all.

Reversing the order of integration

∫ab ⁣∫g1(x)g2(x)f dy dx\int_a^b\!\int_{g_1(x)}^{g_2(x)} f\,dy\,dx is an integral over the region a≤x≤ba \le x \le b, g1(x)≤y≤g2(x)g_1(x) \le y \le g_2(x). To put yy outside, the same region has to be described by cross-sections in xx at each height yy.

  • The description can only change at the heights of the corners and of the turning points of g1g_1 and g2g_2. These cut the yy-axis into strips.
  • On a strip, the ends of a cross-section are among x=ax = a, x=bx = b and the solutions of g1(x)=yg_1(x) = y, g2(x)=yg_2(x) = y. At one height inside the strip these candidates are put in order and a point between each neighbouring pair is tested for membership in the region. That decides the limits for the whole strip, since nothing changes within it.
  • Strips with the same limits are joined. A region may still need several pieces: ∫02 ⁣∫x/2x\int_0^2\!\int_{x/2}^{x} becomes ∫01 ⁣∫y2y+∫12 ⁣∫y2\int_0^1\!\int_y^{2y} + \int_1^2\!\int_y^2.

Then both iterated integrals are computed. If both have closed forms and they are equal, agree is "proven". Often the point of reversing is that one order has no closed form, as with ey2e^{y^2}; then both orders are computed as certified enclosures over the region by @ratmath/analytic, and agree is "checked" when the enclosures overlap and the closed form found lies with them. A disagreement gives false, and no comparison gives null with a note.

ExportReturns
eliminate(curve, parameter = "t"){ equation, standard, polynomial, equations, dropped, method, verified, steps, note }
reverseOrder(f, { outer: [x, a, b], inner: [y, g1, g2] }){ region, pieces, text, original, reversed, value, agree, notes }
Try itEdit the code and run it with @ratmath/symbolic and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.
Ctrl/⌘ + Enter runs