Skip to content
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

added hypergeometic method for 1F1 type ode #17750

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

added hypergeometic method for 1F1 type ode #17750

wants to merge 1 commit into from

Conversation

RituRajSingh878
Copy link
Contributor

References to other Issues or PRs

related #17603

Brief description of what is fixed or changed

By implementing this method, any differential equation that can be transform into eq = x*f(x).diff(x, 2) + (c-x)*f(x).diff(x) -a*f(x) by applying the following transformations

1- x --> x**k
2- x --> (a*x + b)/(c*x+d)
3- y --> P(x)*y

then the given equation can be solve.

It will cover a class of ode-

In [5]: eq = x*f(x).diff(x, 2) + (c-x)*f(x).diff(x) -a*f(x)

In [6]: eq
Out[6]: 
              2                         
             d                  d       
-a⋅f(x) + x⋅───(f(x)) + (c - x)⋅──(f(x))
              2                 dx      
            dx                          


Which is solvable in the series solution.

Other comments

Work is still in progress.
sources-
https://en.wikipedia.org/wiki/Frobenius_solution_to_the_hypergeometric_equation
https://drive.google.com/file/d/1wcJlEd6DMTRHAprH2N2oXaCHpa8PLDwp/view

Release Notes

  • solvers
    • added method in dsolve to solve 2nd order ode in 1F1 hyper function

@sympy-bot
Copy link

sympy-bot commented Oct 17, 2019

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

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://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->

related #17603 
#### Brief description of what is fixed or changed
By implementing this method, any differential equation that can be transform into `eq = x*f(x).diff(x, 2) + (c-x)*f(x).diff(x) -a*f(x)` by applying the following transformations 
```
1- x --> x**k
2- x --> (a*x + b)/(c*x+d)
3- y --> P(x)*y
```
then the given equation can be solve.

It will cover a class of ode- 
```
In [5]: eq = x*f(x).diff(x, 2) + (c-x)*f(x).diff(x) -a*f(x)

In [6]: eq
Out[6]: 
              2                         
             d                  d       
-a⋅f(x) + x⋅───(f(x)) + (c - x)⋅──(f(x))
              2                 dx      
            dx                          


```
Which is solvable in the series solution.



#### Other comments
Work is  still in progress.
sources-
https://en.wikipedia.org/wiki/Frobenius_solution_to_the_hypergeometric_equation
https://drive.google.com/file/d/1wcJlEd6DMTRHAprH2N2oXaCHpa8PLDwp/view
#### 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
  - added method in dsolve to solve 2nd order ode in 1F1 hyper function
<!-- END RELEASE NOTES -->

@RituRajSingh878 RituRajSingh878 changed the title added equivalence condition for 1F1 type ode added hypergeometic method for 1F1 type ode Oct 17, 2019
@codecov
Copy link

codecov bot commented Oct 17, 2019

Codecov Report

Merging #17750 into master will increase coverage by 9.538%.
The diff coverage is 0%.

@@              Coverage Diff              @@
##            master    #17750       +/-   ##
=============================================
+ Coverage   65.215%   74.753%   +9.538%     
=============================================
  Files          636       636               
  Lines       166193    166203       +10     
  Branches     39068     39073        +5     
=============================================
+ Hits        108383    124243    +15860     
+ Misses       51856     36449    -15407     
+ Partials      5954      5511      -443

@RituRajSingh878
Copy link
Contributor Author

I am trying to implement the solution and I am using whitm but I am getting the following error whenever I am using a variable inside the whitm.

In [14]: from mpmath import *

In [15]: whitm(1/2, 2/3, x**2/3 + 1)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-15-1ab057ac9216> in <module>()
----> 1 whitm(1/2, 2/3, x**2/3 + 1)

/home/rituraj/.local/lib/python3.6/site-packages/mpmath/ctx_mp_python.py in f_wrapped(ctx, *args, **kwargs)
   1029             def f_wrapped(ctx, *args, **kwargs):
   1030                 convert = ctx.convert
-> 1031                 args = [convert(a) for a in args]
   1032                 prec = ctx.prec
   1033                 try:

/home/rituraj/.local/lib/python3.6/site-packages/mpmath/ctx_mp_python.py in <listcomp>(.0)
   1029             def f_wrapped(ctx, *args, **kwargs):
   1030                 convert = ctx.convert
-> 1031                 args = [convert(a) for a in args]
   1032                 prec = ctx.prec
   1033                 try:

/home/rituraj/.local/lib/python3.6/site-packages/mpmath/ctx_mp_python.py in convert(ctx, x, strings)
    667             try: return ctx.make_mpf(from_Decimal(x, prec, rounding))
    668             except: pass
--> 669         return ctx._convert_fallback(x, strings)
    670 
    671     def npconvert(ctx, x):

/home/rituraj/.local/lib/python3.6/site-packages/mpmath/ctx_mp.py in _convert_fallback(ctx, x, strings)
    632             else:
    633                 raise ValueError("can only create mpf from zero-width interval")
--> 634         raise TypeError("cannot create mpf from " + repr(x))
    635 
    636     def mpmathify(ctx, *args, **kwargs):

TypeError: cannot create mpf from x**2/3 + 1

@oscarbenjamin
Copy link
Contributor

You are importing whitm from mpmath which is a numerical library. You can't use symbols in numerical code.

@RituRajSingh878
Copy link
Contributor Author

RituRajSingh878 commented Oct 23, 2019

Is there any way I can use whitm with a variable?

@oscarbenjamin
Copy link
Contributor

Not if whitm is an mpmath function. If you need this function then you can create a SymPy class to represent the function if there isn't one already. I guess it should go in sympy.functions.special.hyper.

@czgdp1807
Copy link
Member

@RituRajSingh878 @oscarbenjamin Is this related to this year's GSoC ODE project by @mijo2 ?

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.

None yet

4 participants