# Infinite initial conditions in ODE and arbitrary constant

This post is a wiki. Anyone with karma >750 is welcome to improve it.

Is it possible to include infinite initial conditions in an ODE? For example,

ode_soln = desolve(ode, q, ics[0, -Infity])


throws and error.

Alternatively, I can leave the initial condition blank:

ode_soln = desolve(ode, q)
soln = solve(ode_soln, q)
show(soln[0])


Then output Includes an arbitrary constant written C $$q\left(t\right) = -\frac{p}{C {\left(p + 1\right)} + {\left(p + 1\right)} t}$$

I tried to set a value for $C$ via,

show(soln[0].substitute(C = 0))


but it made no difference. Here $p$ I declared as a variable, and I can do things like

show(soln[0].substitute(p = 1))


to produce the expected output

$$q\left(t\right) = -\frac{1}{2 {\left(C + t\right)}}$$

So it seems that I need to refer to the arbitrary constant by some other name than $C$. How can I do this?

edit retag close merge delete

Sort by » oldest newest most voted

The answer to your second question (substituting for $C$) is

soln[0].substitute({SR.var('_C'): 0})


This is because constants that appear in solutions of ODEs, like _C (which is displayed as $C$), are not put in the global namespace, hence they have to be recovered from their names in the Symbolic Ring (SR) by SR.var('_C').

more

Excellent. That does the job, thank you.

( 2017-09-07 06:42:11 -0500 )edit