0
$\begingroup$

I'm trying to solve a boundary-value problem using sympy. I was able to solve the ODE but the dsolve function doesn't return the values of the constants $C_1$ and $C_2$.

Boundary-value problem:

$u''_{xx}+u+1=0$ with a boundary condition $u(0)=0, \quad u'_x(1)=1$

Python Code:

I tried the next code in jupyter notebook and sympy live

from sympy import *
init_printing(use_latex='mathjax')
u = Function('u')
x = Symbol('x')
dsolve(Derivative(u(x),x,x)+u(x)+1,u(x),ics={u(0): 0, u(x).diff(x).subs(x, 1): 1})

This return the follow result:

$$u(x)=C_1\sin(x)+C_2\cos(x)−1$$

While expected full solution is:

$$u(x)=-1+\cos(x)+\sec(1)\sin(x)+\sin (x) \tan (1)$$

Is there something wrong with my python code? How can I contour this situation to obtain the full solution using sympy?

$\endgroup$
0
$\begingroup$

There doesn't seem to be anything wrong with your code, per se, but the current version of SymPy doesn't actually support the use of initial conditions and boundary values, according to sources I read a little while ago. It seems that version 1.2 will.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.