Skip to content

Conversation

eagleoflqj
Copy link
Member

@eagleoflqj eagleoflqj commented May 21, 2022

References to other Issues or PRs

Fixes #23485
Fixes #11742

Brief description of what is fixed or changed

The rule of this kind of integrals is
$\int\sqrt{a+bx+cx^2}\mathrm{d}x$
$=x\sqrt{a+bx+cx^2}-\int x\mathrm{d}\sqrt{a+bx+cx^2}$
$=x\sqrt{a+bx+cx^2}-\int\frac{x(b+2cx)}{2\sqrt{a+bx+cx^2}}\mathrm{d}x$
$=x\sqrt{a+bx+cx^2}-\int\frac{2(a+bx+cx^2)-2a-bx}{2\sqrt{a+bx+cx^2}}\mathrm{d}x$
$=x\sqrt{a+bx+cx^2}-\int\sqrt{a+bx+cx^2}\mathrm{d}x+\frac{1}{2}\int\frac{2a+bx}{\sqrt{a+bx+cx^2}}\mathrm{d}x$
$=\frac{1}{2}x\sqrt{a+bx+cx^2}+\frac{1}{4}\int\frac{2a+bx}{\sqrt{a+bx+cx^2}}\mathrm{d}x$
This rule doesn't seem represent-able by existing rules, so I define a new rule for it.
Detailed steps should be provided in SymPy Beta after SymPy 1.11 is released.

Other comments

Release Notes

  • integrals
    • Support integrate(sqrt(a+bx+cx**2))

@sympy-bot
Copy link

sympy-bot commented May 21, 2022

Hi, I am the SymPy bot (v167). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.11.

Click here to see the pull request description that was parsed.
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

Fixes #23485
Fixes #11742
#### Brief description of what is fixed or changed
The rule of this kind of integrals is
$\int\sqrt{a+bx+cx^2}\mathrm{d}x$
$=x\sqrt{a+bx+cx^2}-\int x\mathrm{d}\sqrt{a+bx+cx^2}$
$=x\sqrt{a+bx+cx^2}-\int\frac{x(b+2cx)}{2\sqrt{a+bx+cx^2}}\mathrm{d}x$
$=x\sqrt{a+bx+cx^2}-\int\frac{2(a+bx+cx^2)-2a-bx}{2\sqrt{a+bx+cx^2}}\mathrm{d}x$
$=x\sqrt{a+bx+cx^2}-\int\sqrt{a+bx+cx^2}\mathrm{d}x+\frac{1}{2}\int\frac{2a+bx}{\sqrt{a+bx+cx^2}}\mathrm{d}x$
$=\frac{1}{2}x\sqrt{a+bx+cx^2}+\frac{1}{4}\int\frac{2a+bx}{\sqrt{a+bx+cx^2}}\mathrm{d}x$
This rule doesn't seem represent-able by existing rules, so I define a new rule for it.
Detailed steps should be provided in SymPy Beta after SymPy 1.11 is released. 
#### Other comments


#### Release Notes

<!-- Write the release notes for this release below between the BEGIN and END
statements. The basic format is a bulleted list with the name of the subpackage
and the release note for this PR. For example:

* solvers
  * Added a new solver for logarithmic equations.

* functions
  * Fixed a bug with log of integers.

or if no release note(s) should be included use:

NO ENTRY

See https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more
information on how to write release notes. The bot will check your release
notes automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* integrals
  * Support integrate(sqrt(a+bx+cx**2))

<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@eagleoflqj eagleoflqj marked this pull request as draft May 21, 2022 04:08
@eagleoflqj eagleoflqj force-pushed the integrate_sqrt_quadratic branch from 19c5f87 to 309a3a3 Compare May 21, 2022 17:29
@github-actions
Copy link

Benchmark results from GitHub Actions

Lower numbers are good, higher numbers are bad. A ratio less than 1
means a speed up and greater than 1 means a slowdown. Green lines
beginning with + are slowdowns (the PR is slower then master or
master is slower than the previous release). Red lines beginning
with - are speedups.

Significantly changed benchmark results (PR vs master)

Significantly changed benchmark results (master vs previous release)

       before           after         ratio
     [77f1d79c]       [832c24fe]
     <sympy-1.10.1^0>                 
+         130±3ms          237±7ms     1.83  sum.TimeSum.time_doit

Full benchmark results can be found as artifacts in GitHub Actions
(click on checks at the top of the PR).

@eagleoflqj eagleoflqj marked this pull request as ready for review May 21, 2022 20:00
@ThePauliPrinciple
Copy link
Contributor

ThePauliPrinciple commented May 22, 2022

Wolfram alpha gives a result without any integral https://www.wolframalpha.com/input?i=integrate+sqrt%28a%2Bb*x%2Bc*x**2%29+dx

Other than that, the presented derivation seems correct to me and the changes in the code make sense, although I am not too familiar with manualintegrate`.

x*sqrt(53225*x**2 - 66732*x + 23013)/2 - 16683*sqrt(53225*x**2 - 66732*x + 23013)/53225 + \
111576969*sqrt(2129)*asinh(53225*x/10563 - S(11122)/3521)/1133160250
assert integrate(sqrt(a+b*x+c*x**2), x) == b*sqrt(a + b*x + c*x**2)/(4*c) + x*sqrt(a + b*x + c*x**2)/2 + \
(2*a - b**2/(2*c))*log(b + 2*sqrt(c)*sqrt(a + b*x + c*x**2) + 2*c*x)/(4*sqrt(c))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ThePauliPrinciple
The context is, I supported $\int\frac{2a+bx}{\sqrt{a+bx+cx^2}}\mathrm{d}x$ at #23511, so you can see the result here equals to Wolfram Alpha.

@eagleoflqj eagleoflqj merged commit 109ea40 into sympy:master May 27, 2022
@eagleoflqj eagleoflqj deleted the integrate_sqrt_quadratic branch May 27, 2022 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

integrate(sqrt(53225*t**2 - 66732*t + 23013), t) fails to integrate integrate cannot solve integral, but Meijer int can
3 participants