Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Your differential equation being linear first order, its solution involves one integration constant, which cannot (in general) satisfy two boundary conditions.

If you need a verification :

 sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:
:y = function("y")
:de = y(x)+y(x).diff(x) == x^2
:sol = desolve(de, y(x)) ; sol
:# Declare the integration constant
:Csts = [str(u) for u in sol.variables() if str(u) not in globals()]
:if len(Csts)>0 : var(Csts)
:# Check solution
:chk = bool(de.substitute_function(y, sol.function(x)))
:# Satisfy the first boundary condition:
:C1=solve(sol(x=1)==1, _C) ; C1
:# Satisfy the second boundary condition:
:C2 = solve(sol.diff(x)(x=1)==1, _C) ; C2
:
:--
((x^2 - 2*x + 2)*e^x + _C)*e^(-x)
[_C == 0]
[_C == -e]

your boundary conditions are mutually incompatible...

HTH,

Your differential equation being linear first order, its solution involves one integration constant, which cannot (in general) satisfy two boundary conditions.

If you need a verification :

 sage: %cpaste
Pasting code; enter '--' alone on the line to stop or use Ctrl-D.
:
:y = function("y")
:de = y(x)+y(x).diff(x) == x^2
:sol = desolve(de, y(x)) ; sol
:# Declare the integration constant
:Csts = [str(u) for u in sol.variables() if str(u) not in globals()]
:if len(Csts)>0 : var(Csts)
:# Check solution
:chk = bool(de.substitute_function(y, sol.function(x)))
:# Satisfy the first boundary condition:
:C1=solve(sol(x=1)==1, _C) ; C1
:# Satisfy the second boundary condition:
:C2 = solve(sol.diff(x)(x=1)==1, _C) ; C2
:
:--
((x^2 - 2*x + 2)*e^x + _C)*e^(-x)
[_C == 0]
[_C == -e]

your boundary conditions are mutually incompatible...

HTH,

EDIT : The same principle applies ; and since your DE is linear second order, two integration constants appear, which may fullfill two boundary conditions : :

sage: y=function("y")
sage: de=y(x)+y(x).diff(x,2)==x^2
sage: sol=desolve(de,y(x)) ; sol
x^2 + _K2*cos(x) + _K1*sin(x) - 2
sage: Csts = [str(u) for u in sol.variables() if str(u) not in globals()] ; Csts
['_K1', '_K2']
sage: if len(Csts)>0 : var(Csts)
(_K1, _K2)
# Solving for simultaneous boundary conditions :
sage: solve([sol(x=1)==1, sol.diff(x)(x=2)==1],(_K1, _K2))
[[_K1 == -(3*cos(1) - 2*sin(2))/(cos(2)*cos(1) + sin(2)*sin(1)), _K2 == (2*cos(2) + 3*sin(1))/(cos(2)*cos(1) + sin(2)*sin(1))]]

Note : Now, your question strongly smells of an (initialy mistyped) homework. Are you sure that, by taking the ask.sagemath.org shortcut, you aren't missing the point of said homework ?