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

DOC: integrate: Add complex matrix DE solution to examples #14103

Merged
merged 9 commits into from
Aug 25, 2023

Conversation

topolskikevin
Copy link
Contributor

Reference issue

Closes #13437

What does this implement/fix?

Added examples to solve complex matrix differential equations to docstring

Additional information

First commit, welcome to any feedback and changes I can follow up.

Added examples to solve complex matrix differential equations to docstring
Copy link

@tupuinui tupuinui left a comment

Choose a reason for hiding this comment

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

Thank you for your first PR @topolskikevin! Nice example.

On my side (as I don't know these functions) I just have a few cosmetic comments. Let see as well if the doctests pass.

@tupui tupui added Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.integrate labels May 21, 2021
@scipy scipy deleted a comment from tupuinui May 21, 2021
@ilayn ilayn changed the title DOC: integrate: fixed issue #13437 DOC: integrate: Add complex matrix DE solution to examples May 21, 2021
@scipy scipy deleted a comment from tupuinui May 21, 2021
@scipy scipy deleted a comment from tupuinui May 21, 2021
@scipy scipy deleted a comment from tupuinui May 21, 2021
Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

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

Sorry about the mess, I used the wrong account... (Believe me, I hate to have this setup but I don't have the choice...)

scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

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

Thanks for the update. You still have issues with the CI. These suggestions should fix them.

scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
53.17531184+103.80400411j]
[ -2.26105874 +22.19277664j -15.1255713 +70.19616341j
-38.34616845+153.29039931j]]

Specifying points where the solution is desired.
Copy link
Member

Choose a reason for hiding this comment

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

The following example should be placed above as the exponential_decay function is defined above. The examples are linked.

A couple examples of using solve_ivp to solve differential functions with
complex matrix ``A``.

>>> from scipy.integrate import solve_ivp
Copy link
Member

Choose a reason for hiding this comment

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

Already imported above.

Suggested change
>>> from scipy.integrate import solve_ivp

@tupui
Copy link
Member

tupui commented May 25, 2021

@nmayorov could you have a look at the example itself? I am not a user of this so I would not know if this makes sense TBH.

@Patol75
Copy link
Contributor

Patol75 commented Sep 20, 2021

@tupui The idea of this PR is to provide an example of how to use solve_ivp when the variable y is a matrix-valued function. In other words, how to solve an ordinary differential equation that involves a matrix-valued function through solve_ivp. The motivation behind this PR is this SO question that I have answered in which the author is confused about how to proceed in the aforementioned scenario. Indeed, throughout the documentation, it is mentioned that y is a vector. However, the confusion comes from the fact that the author assumed it was necessary to pass a 2-D NumPy array to solve_ivp, while the way to proceed is to provide solve_ivp with the flattened array and reshape y within fun to perform matrix operations before flattening again the returned array. Following my answer on SO, the question's author opened #13437 to ask for a similar example to be included in the documentation. The present PR simply reproduces my answer to the author's question on SO. The ordinary differential equation used does not have anything special. Instead, the idea is to show the flatten/reshape procedure to allow for execution through solve_ivp. I guess that the question here is whether SciPy developers consider this scenario should be documented, and if yes, whether the proposed approach is satisfying.

@mdhaber
Copy link
Contributor

mdhaber commented Apr 16, 2022

@nmayorov Do you have a moment to check out this new example? Rendered documentation is here.

@nitin-pandita
Copy link

Can i work on it

@tupui
Copy link
Member

tupui commented Jul 3, 2023

Hi @nitin-pandita, I am afraid there is no simple way to work on someone else's PR. I would suggest you look at other issues.

@nitin-pandita
Copy link

Hi @nitin-pandita, I am afraid there is no simple way to work on someone else's PR. I would suggest you look at other issues.

Ok Sure

scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
j-bowhay and others added 2 commits August 24, 2023 22:16
[skip actions] [skip cirrus]
[skip actions] [skip cirrus]
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
scipy/integrate/_ivp/ivp.py Outdated Show resolved Hide resolved
[skip ci]
Copy link
Member

@j-bowhay j-bowhay left a comment

Choose a reason for hiding this comment

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

@j-bowhay j-bowhay added this to the 1.12.0 milestone Aug 25, 2023
@j-bowhay j-bowhay merged commit 41c61b2 into scipy:main Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation Issues related to the SciPy documentation. Also check https://github.com/scipy/scipy.org scipy.integrate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Add example as to how to use solve_ivp to solve complex matrix differential equations
7 participants