Skip to content

A root of the cosine beside a half-odd power of a + a sec is integrated wrongly where the cosine is negative #1581

Closed

Description

@Rafael-SOWNet

sqrt(cos(c + d*x))/sqrt(a + a*sec(c + d*x)) is integrated wrongly where cos(c + d x) is negative.

Found by work/intbench on Rubi's 4.5.1.2 and 4.5.3.1, master a8a2b7e: seven problems come back wrong. All seven are a root of the cosine beside a half-odd power of a + a sec:

  • sqrt(cos(c+d*x))/sqrt(a+a*sec(c+d*x)) (4.5.1.2:489)
  • 1/(sqrt(cos(c+d*x))*sqrt(a+a*sec(c+d*x))) (4.5.1.2:490)
  • sqrt(cos(c+d*x))/(a+a*sec(c+d*x))^(3/2) (4.5.1.2:496)
  • sqrt(cos(c+d*x))/(a+a*sec(c+d*x))^(5/2) (4.5.1.2:502)
  • (A+B*sec(c+d*x))*sqrt(cos(c+d*x))/sqrt(a+a*sec(c+d*x)) (4.5.3.1:649)
  • (A+B*sec(c+d*x))*sqrt(cos(c+d*x))/(a+a*sec(c+d*x))^(3/2) (4.5.3.1:655)
  • (A+B*sec(c+d*x))*sqrt(cos(c+d*x))/(a+a*sec(c+d*x))^(5/2) (4.5.3.1:662)

Where the cosine is positive, all seven differentiate back (a = 1.3, c = 0.2, d = 1, A = 0.7, B = 1.1, at x = 0.3, 0.6, 0.9, 1.1). Where it is negative, the integrand is still real: sqrt(cos) and the root of a + a sec are both imaginary there. None of the seven differentiates back at x = 1.9, 2.2, 2.5, 2.9. By quadrature from 1.9 to 2.9, Simpson gives 3.6947 for the first, and master's answer gives F(2.9) - F(1.9) = -3.6947. The next three are also the exact negative of the quadrature there. The three with A + B sec(c + d x) differ from it by more than a sign.

The route, traced on master:

  1. SolveByTakingAConstantOutOfAFractionalPower takes sqrt(a) out.
  2. SolveBySubstitution takes u = c + d x.
  3. SolveByTheSignOfTheComplement writes the integrand in w = cos(u).
  4. SolveBySubstitution takes v = sqrt(w). For the first integrand, that leaves -2 v^2/(sqrt(1 + 1/v^2) sqrt(1 - v^4)).
  5. SolveByCombiningRadicals writes the product of roots as sqrt(v^4 - v^8 + v^2 - v^6)/v^2.

Step 5 is right for a real v, where sqrt(v^4) = v^2. Wherever the cosine is negative, v = sqrt(w) is imaginary, sqrt(v^4) = -v^2, and the answer comes back negated.

SolveBySubstitution already conditions the answer on the radicand after an even root, provided w >= 0, for this reason. Its comment names (1 + sec(x))^(5/2) sqrt(cos(x)). It does so only when the answer below read a sign or a modulus of v (if (asTheRoot != resultInU)). Here the rules below wrote v^2 for sqrt(v^4) and read neither.

Tested: with that condition attached to every answer through an even root (a probe, not a proposal), all seven come back conditioned on cos(c + d x) >= 0: the first says provided a > 0 and cos(c + d * x) >= 0, where master says provided a > 0. They still differentiate back where the cosine is positive, and claim nothing where it is negative. The probe also conditions answers that hold on both sides, which a fix would have to avoid.

Activity

  1. added this to the 2.7.0 milestone on Sep 29, 2026
  2. Rafael-SOWNet commented on Sep 29, 2026

    @Rafael-SOWNet
    MemberAuthor

    #1584 answers these seven by the half-angle tangent, conditioned on cos(c + d x) >= 0, before SolveBySubstitution is asked, so they will stop showing up in the corpus. The defect is still there for anything else that reaches the even-root step.

  3. modified the milestones: 2.7.0, 2.6.0 on Sep 29, 2026
  4. added a commit that references this issue on Sep 29, 2026
    f94da6c
  5. added a commit that references this issue on Sep 29, 2026
    02e2f3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions