-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Added hyperbolic function in undetermined coefficients #18410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
✅ Hi, I am the SymPy bot (v149). 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.6. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. Click here to see the pull request description that was parsed.
Update The release notes on the wiki have been updated. |
Codecov Report
@@ Coverage Diff @@
## master #18410 +/- ##
=============================================
+ Coverage 75.284% 75.302% +0.017%
=============================================
Files 633 633
Lines 166951 166951
Branches 39397 39397
=============================================
+ Hits 125688 125718 +30
+ Misses 35729 35693 -36
- Partials 5534 5540 +6 |
|
@oscarbenjamin can you review this? |
|
What happens if the rhs includes both a hyperbolic function and exp(x)? Does it get confused? We should add a test for this. |
sympy/solvers/tests/test_ode.py
Outdated
|
|
||
| eq = f(x).diff(x, 2) - 49*f(x) - sinh(3*x) | ||
| sol = Eq(f(x), C1*exp(-7*x) + C2*exp(7*x) - sinh(3*x)/40) | ||
| assert sol == dsolve(eq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since these ODEs can already be solved on master these tests should specify the hint as in hint='nth_..._undetermined_coefficients'.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if the rhs includes both a hyperbolic function and exp(x)? Does it get confused? We should add a test for this.
It treats them seperately and i have added test for this .
|
|
||
| def test_issue_18408(): | ||
| eq = f(x).diff(x, 3) - f(x).diff(x) - sinh(x) | ||
| sol = Eq(f(x), C1 + C2*exp(-x) + C3*exp(x) + x*sinh(x)/2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have a solution in terms of sinh and cosh in this case, but that might not be straightforward to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've often thought the same about exp(I*x) in some cases that would be preferred rather than cos/sin e.g.:
In [15]: dsolve(f(x).diff(x, 2) + f(x) - exp(I*x))
Out[15]:
ⅈ⋅x
ⅈ⋅x⋅ℯ
f(x) = C₁⋅sin(x) + C₂⋅cos(x) - ────────
2 Maybe there should be a parameter to dsolve to influence which type of solutions it generates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it could at least be smarter based on what sorts of functions are present in the ODE itself. But this can be done in a future PR.
|
@oscarbenjamin does this look good? |
|
Yes, looks good. |
References to other Issues or PRs
Fixes #18408
Brief description of what is fixed or changed
Earlier the ode involving hyperbolic function were not classified by
nth_linear_constant_coeff_undetermined_coefficientsnot it is fixedOther comments
Release Notes
dsolvecan solve linear non-homogeneous ODEs involving hyperbolic functions when using the method of undetermined coefficients.