Skip to content

Conversation

@Mohitbalwani26
Copy link
Member

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_coefficients not it is fixed

Other comments

Release Notes

  • solvers
    • Now dsolve can solve linear non-homogeneous ODEs involving hyperbolic functions when using the method of undetermined coefficients.

@sympy-bot
Copy link

sympy-bot commented Jan 20, 2020

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:

  • solvers
    • Now dsolve can solve linear non-homogeneous ODEs involving hyperbolic functions when using the method of undetermined coefficients. (#18410 by @Mohitbalwani26)

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.

<!-- 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 #18408 

#### Brief description of what is fixed or changed
Earlier the ode involving hyperbolic function were not classified by `nth_linear_constant_coeff_undetermined_coefficients` not it is fixed

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. 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 -->
* solvers
  *  Now `dsolve` can solve linear non-homogeneous ODEs involving hyperbolic functions when using the method of undetermined coefficients.
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented Jan 20, 2020

Codecov Report

Merging #18410 into master will increase coverage by 0.017%.
The diff coverage is 100%.

@@              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

@Mohitbalwani26
Copy link
Member Author

@oscarbenjamin can you review this?

@asmeurer
Copy link
Member

asmeurer commented Jan 20, 2020

What happens if the rhs includes both a hyperbolic function and exp(x)? Does it get confused? We should add a test for this.


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)
Copy link
Collaborator

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'.

Copy link
Member Author

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)
Copy link
Member

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.

Copy link
Collaborator

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
                               ⅈxf(x) = C₁sin(x) + C₂cos(x) - ────────
                                  2  

Maybe there should be a parameter to dsolve to influence which type of solutions it generates.

Copy link
Member

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.

@Mohitbalwani26
Copy link
Member Author

@oscarbenjamin does this look good?

@oscarbenjamin
Copy link
Collaborator

Yes, looks good.

@oscarbenjamin oscarbenjamin merged commit fa1432d into sympy:master Jan 21, 2020
@Mohitbalwani26 Mohitbalwani26 deleted the 18408_bug branch March 4, 2020 09:16
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.

classify_ode doesn't recognise nth_linear_constant_coeff_undetermined_coefficients

4 participants