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 and are rational functions, clearing denominators gives two polynomial equations in ,
A point is on the curve when these have a common root . The resultant of two polynomials in 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 is an equation in and alone that every point of the curve satisfies.
Sines and cosines are handled by making them unknowns. With and , multiples such as are polynomials in and , and the one relation between them is . For the ellipse the equations are , , ; removing and then by resultants leaves . Exponentials are powers of one unknown in the same way, which covers and .
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 . 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. , gives , but only the half with is traced. And a curve such as the cycloid , , where 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
is an integral over the region , . To put outside, the same region has to be described by cross-sections in at each height .
- The description can only change at the heights of the corners and of the turning points of and . These cut the -axis into strips.
- On a strip, the ends of a cross-section are among , and the solutions of , . 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: becomes .
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 ; 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.
| Export | Returns |
|---|---|
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 } |
@ratmath/symbolic and Core's Rational in scope. The last line's value is shown; PRINT(…) adds lines, TEX(…) typesets math.