Skip to content

SageMath integrate sqrt of symbolic functions returns Infinity but also invalid expressions #41246

@Insta-gram1

Description

@Insta-gram1

Problem

When using integrate with the sqrt function on symbolic functions in SageMath, the result is sometimes Infinity, but in some cases, the return of an expression that is not valid.

Examples:

Using python and SageMath 10.4 in the cocalc environment, print statements were used to generate the following output (text of the generating expression followed by that expression's output) after using
f1 = function('f1')(x)
assume(f1 > 0);

f1.is_real True
f1.is_positive True
integrate(f1,x) = integrate(f1(x), x)
sqrt(f1) = sqrt(f1(x))
integrate(sqrt(f1),x) = +Infinity
integrate(f1**(1/2),x) = +Infinity
integrate(((1/f1)(-1/2))(-1),x) = +Infinity (Added comment - missing ** as exponential operators - edit doesn't work)
integrate(f1**(-1/2),x) = integrate(1/sqrt(f1(x)), x)
integrate((1/f1)(-1/2),x) = integrate(1/sqrt(f1(x)), x) (Two ** are not showing up before -1/2)
integrate((f1
(-1))**(-1/2),x) = integrate(1/sqrt(f1(x)), x) (Two ** are not showing up before -1)

The following was generated by AI as a template:

Expected Behavior

  • The integrate function should return a mathematically valid antiderivative, not Infinity, unless the integral genuinely diverges.
  • If integration cannot be performed, a meaningful error or symbolic representation should be given, not an invalid expression.

Actual Behavior

  • Inconsistent results for integrate(sqrt(x), x) and similar integrals:
    • Sometimes yields Infinity
    • Sometimes yields expressions that are not valid

End AI generated comments.

Besides the returns of infinity, the last 2 of the examples return invalid equivalents of the equations fed to the the integrate function. The returns are the same as the equation just above them.

This problem has been reported before for the infinity result but there has so far been only a suggested fix to use an alternative algorithm for the integration:
#36222
https://ask.sagemath.org/question/73205/sqrt-integral-not-working/

Unfortunately, using an alternative algorithm with SageManifolds in the cocalc environment appears to lead back to an infinity result for the integration during the Manifold computations, so doesn't appear to be a workaround for me.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions