<jupyter_start><jupyter_text>---author: <NAME> (<EMAIL>)---This answer assumes you have imported SymPy as follows.<jupyter_code>from sympy import *                   # load all math functions
init_printing( use_latex='mathjax' )  # use pretty math output<jupyter_output><empty_output><jupyter_text>Let's re-use here the code from how to write an ordinary differential equation,to write $\frac{dy}{dx}=y$.<jupyter_code>var( 'x' )
y = Function('y')(x)
dydx = Derivative( y, x )
ode = dydx - y
ode<jupyter_output><empty_output><jupyter_text>You can solve an ODE by using the `dsolve` command.<jupyter_code>solution = dsolve( ode )
solution<jupyter_output><empty_output><jupyter_text>If there are initial conditions that need to be substituted in for $x$ and $y$,it is crucial to substitute for $y$ first and then $x$.  Let's assume we have theinitial condition $(3,5)$.  We might proceed as follows.<jupyter_code>with_inits = solution.subs( y, 5 ).subs( x, 3 )
with_inits
solve( with_inits )<jupyter_output><empty_output><jupyter_text>To substitute $C_1=\frac{5}{e^3}$ into the solution, note that $C_1$ is written as `var('C1')`.<jupyter_code>solution.subs( var('C1'), 5/E**3 )<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13112033195020747, 'fraction_numerical': 0.00995850622406639, 'mean_word_length': 5.813559322033898, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '607314', 'license': 'MIT', 'n_tokens_mistral': 440, 'n_tokens_neox': 426, 'n_words': 121, 'path': 'database/tasks/How to solve an ordinary differential equation/Python, using SymPy.ipynb', 'repo_name': 'nathancarter/how2data', 'size': '1224'}