Repository navigation
A fractional power, and the tangent, are substitutions (#233) - #1146
Merged
Merged
Conversation
Two substitutions, in one change because neither reaches `sqrt(tan(x))` without the other. That integral is the last of the five #233 lists, and the one it calls "very painful, requires different solvers", which it is: int sqrt(tan(x)) dx u = tan(x), dx = du/(1 + u^2) -> int sqrt(u)/(1 + u^2) du t = sqrt(u), a fractional power -> int 2t^2/(1 + t^4) dt 1 + t^4 factored over the reals -> logarithms and arctangents Take any one of the three away and it comes back unevaluated. The third landed in #1145. The fractional power. A power substitution rewrites the other powers of the variable into powers of itself: for `u = x^r` the identity is `x^n = u^(n/r)`, applied wherever `n/r` is whole. A whole `r` reaches only the powers it divides, which is all this did before; an `r` of `1/2` reaches every one of them, the bare `x` included, which a whole `r` never can. So `int sqrt(x)/(1 + x^2)` becomes `int 2u^2/(1 + u^4) du`, and `1/(1 + sqrt(x))`, `1/(sqrt(x) * (1 + x))`, `1/(sqrt(x) * (1 + x^2))` and `1/(sqrt(x) + x)` come with it. The rewrite takes two passes, written powers first and a leftover bare `x` second, because the tree is rewritten from the leaves up: in one pass the `x` inside `sqrt(x)` is reached before the `sqrt(x)` node is, and `u = sqrt(x)` turns it into `sqrt(u^2)` rather than `u` -- an integrand free of `x` and no more integrable than it started. The tangent. An integrand that is a function of `tan(x)` and of nothing else becomes a rational function under `u = tan(x)`, with `dx` as `du/(1 + u^2)`. The test is the rewrite itself: replace every `tan(x)` and see whether an `x` survives. It is a step of its own rather than a candidate for the general substitution. The general one divides by `du/dx` and asks what is left, which works while the substitution survives the division; here it does not, since `sqrt(tan(x))` over the derivative of `sqrt(tan(x))` is `2 tan(x) cos(x)^2`, which is `sin(2x)` and is simplified to it -- a correct answer to a question that has stopped being about the tangent. The corpus gate now reads 40 solved of 40. Its one unsolved problem was `int:hard`, which is `sqrt(tan(x))`, chosen for that list as the standing example of an integral out of reach; the gate reached the verdict by differentiating the answer back rather than by comparing it with anything. Baseline refreshed as its message directs. What is still declined is recorded in the tests rather than left to be inferred: `cotan` is its own node and not a reciprocal of the tangent, so `sqrt(cotan(x))` never starts; `tan(x)^2` and `tan(x)^3` become improper fractions, which the rational integrator does not divide out; `1/(1 + tan(x)^2)` becomes a repeated irreducible quadratic; and `sqrt(x)/(1 + x^4)` becomes a degree-eight denominator that is neither factorable over the rationals nor a biquadratic. All five integrals the issue lists are now solved. Not closing it: its title asks for more integral solvers generally, and that is broader than the five. Part of #233. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012sonx8iAspMiwRwokT1Ura
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two substitutions, in one PR because neither reaches
sqrt(tan(x))without the other.That integral is the last of the five #233 lists, and the one it calls "very painful,
requires different solvers" — which it is. Three capabilities in a row:
Take any one away and it comes back unevaluated. The third landed in #1145; the first two
are here.
The corpus reached 40 of 40
The gate's one unsolved problem was
int:hard— andint:hardissqrt(tan(x)),chosen for that list as the standing example of an integral out of reach:
It now solves. The gate reached that verdict independently of anything I wrote, by
differentiating the answer back. Baseline refreshed the way its own failure message
directs;
Corpus.csandcorpus-baseline.tsvare both in the diff.The fractional power
A power substitution rewrites the other powers of the variable into powers of itself: for
u = x^rthe identity isx^n = u^(n/r), applied wherevern/ris a whole number. Awhole
rreaches only the powers it divides, which is all this did before. Anrof1/2reaches every one of them — including the barex, which a wholernever can— so
int sqrt(x)/(1 + x^2)becomesint 2u^2/(1 + u^4) du.New with it:
1/(1 + sqrt(x)),1/(sqrt(x) * (1 + x)),1/(sqrt(x) * (1 + x^2)),1/(sqrt(x) + x).The rewrite takes two passes, and that is not tidiness. The tree is rewritten from the
leaves up, so in one pass the
xinsidesqrt(x)is reached before thesqrt(x)node is— and with
u = sqrt(x)that turns it intosqrt(u^2)rather thanu, leaving anintegrand free of
xand no more integrable than it started. Written powers first, aleftover bare
xsecond.The tangent
An integrand that is a function of
tan(x)and of nothing else becomes a rational functionunder
u = tan(x), withdxasdu/(1 + u^2). The test is the rewrite itself: replaceevery
tan(x)and see whether anxsurvives.tan(x) + xkeeps one and is declined —correctly; it is answered, but by linearity over the sum.
Why it is a step of its own rather than a candidate for the general substitution. The
general one divides the integrand by
du/dxand asks what is left, which works while thesubstitution survives the division. Here it does not:
sqrt(tan(x))over the derivative ofsqrt(tan(x))is2 tan(x) cos(x)^2, which issin(2x)and is simplified to it — acorrect answer to a question that has stopped being about the tangent. Rewriting asks a
different question and does not lose the shape.
The rule for the tangent itself is reached first and still wins:
int tan(x)is-ln(cos(x)) + C, not the longer thing this would produce. Pinned by a test.What is still declined, and why
Recorded in the tests rather than left to be inferred from an absence. Each is declined by
what the rewrite hands on, not by the rewrite:
sqrt(cotan(x))cotanis its own node, not a reciprocal of the tangent, so this never startstan(x)^2,tan(x)^3u^2/(1+u^2),u^3/(1+u^2)1/(1 + tan(x)^2)1/(1+u^2)^2sqrt(x)/(1 + x^4)2u^2/(1+u^8)Qnor biquadraticsqrt(x)/(x + 1)2u^2/(1+u^2)The improper-fraction row covers three of those and is the obvious next piece of work —
int tan(x)^2istan(x) - x, and it looking out of reach whilesqrt(tan(x))works isthe wrong way round.
Verification
Full suite 9341 passed, 0 failed, 14 skipped. Corpus 40 solved of 40.
Every new answer is checked by differentiating it back and comparing at sampled points,
through helpers that first assert the antiderivative contains no
integral(— without thatguard the check passes vacuously, since
d/dxof an unevaluatedintegral(f, x)isf.Points for the tangent cases stay inside one branch, on
(0, pi/2), wheresqrt(tan(x))is real.
BREAKING-CHANGES.mdcarries the entry, and the #1145 entry is corrected in place where itsaid
sqrt(tan(x))was not answered.On closing #233
All five integrals the issue lists are now solved. I have not written a closing keyword:
its title asks for more integral solvers generally, which is broader than the five, so that
is the maintainer's call rather than a merge side effect.
Part of #233.