In [1]:
from sympy import *
In [2]:
init_printing()
In [3]:
x,k,c1,c2=symbols('x,k,c_1,c_2')
y=Function('y')(x)
x,k,c1,c2,y
Out[3]:
In [4]:
ecu6a=Eq(y,c1*x+c2*x**2)
ecu6a
z=ecu6a.rhs
z
ec1=Eq(y.diff(x),z.diff(x))
ec2=Eq(y.diff(x,2),z.diff(x,2))
subs1=solve([ec1,ec2],[c1,c2])
(ecu6a.subs(subs1)).simplify()
Out[4]:
In [5]:
ecu6b=Eq(y,c1*exp(k*x)+c2*exp(-k*x))
ecu6b
Out[5]:
In [6]:
z=c1*exp(k*x)+c2*exp(-k*x)
z
Out[6]:
In [7]:
z.diff(x)
Out[7]:
In [8]:
ec1=Eq(y.diff(x),z.diff(x))
ec2=Eq(y.diff(x,2),z.diff(x,2))
ec1, ec2
Out[8]:
In [9]:
subs1=solve([ec1,ec2],[c1,c2])
subs1
Out[9]:
In [10]:
(ecu6b.subs(subs1)).simplify()
Out[10]:
In [11]:
ecu6c=Eq(y,c1*sin(k*x)+c2*cos(-k*x))
ecu6c
Out[11]:
In [12]:
z=ecu6c.rhs
z
Out[12]:
In [13]:
ec1=Eq(y.diff(x),z.diff(x))
ec2=Eq(y.diff(x,2),z.diff(x,2))
ec1, ec2
Out[13]:
In [14]:
subs1=solve([ec1,ec2],[c1,c2])
subs1
Out[14]:
In [15]:
(ecu6c.subs(subs1)).simplify()
Out[15]:
In [16]:
z1=x
z2=x**2
((z1.diff(x,2)-(2/x)*z1.diff(x)+(2/(x**2))*z1)).simplify(), ((z2.diff(x,2)-(2/x)*z2.diff(x)+(2/(x**2))*z2)).simplify()
Out[16]:
In [17]:
solve([Eq(3,c1+c2), Eq(5,c1+2*c2)],[c1, c2])
Out[17]:
In [18]:
v=Function('v')(x)
y2=v*x
y2, (1-x**2)*y.diff(x,2)-2*x*y.diff(x)+2*y
Out[18]:
In [19]:
ecv=((1-x**2)*y2.diff(x,2)-2*x*y2.diff(x)+2*y2).simplify()
ecv
Out[19]:
In [20]:
u=Function('u')(x)
ecu=Eq(u.diff(x)+2*(1/x-x/(1-x**2))*u)
ecu
Out[20]:
In [21]:
dsolve(ecu,u)
Out[21]:
In [22]:
V=integrate(dsolve(ecu,u).rhs,x)
V
Out[22]:
In [23]:
#Luego y_3=V*x resuelve (1-x^2)y''-2xy'+2y=0
y3=V*x
y3.simplify(), ((1-x**2)*y3.diff(x,2)-2*x*y3.diff(x)+2*y3).simplify()
Out[23]:
In [53]:
#verifiquemos que 1/\sqrt(x) es solucion de x^2y''+xy'+(x^2-1/4)y=0
x=symbols('x')
y1=(x)**(-Rational(1,2))*sin(x)
yy=(x**2*(y1.diff(x,2))+x*y1.diff(x)+(x**2-Rational(1,4))*y1).simplify()
y1, yy
Out[53]:
In [56]:
v=Function('v')(x)
y2=v*y1
ecc=(x**2*(y2.diff(x,2))+x*y2.diff(x)+(x**2-Rational(1,4))*y2).simplify()
y2, ecc
Out[56]:
In [58]:
u=Function('u')(x)
ecu=Eq(sin(x)*u.diff(x)+2*cos(x)*u)
ecu
Out[58]:
In [62]:
sol=dsolve(ecu,u)
sol
Out[62]:
In [64]:
integrate(sol.rhs,x)
Out[64]:
In [ ]:
In [ ]:
In [ ]:
In [45]:
f=Function('f')(x)
v=Function('v')(x)
y2=v*x
y2
Out[45]:
In [26]:
(y2.diff(x,2)-x*f*y2.diff(x)+f*y2).simplify()
Out[26]:
In [27]:
u=Function('u')(x)
In [28]:
c1,c2=symbols('c_1,c_2')
solve([Eq(2,c1*exp(1)+c2*exp(-9)),Eq(0,c1*exp(1)-9*c2*exp(-9))],[c1,c2])
Out[28]:
In [29]:
c1,c2=symbols('c_1,c_2')
z=1/x*(c1*cos(3*log(x))+c2*sin(3*log(x)))
z
Out[29]:
In [30]:
(x**2*z.diff(x,2)+3*x*z.diff(x)+10*z).simplify()
Out[30]:
In [31]:
c1,c2=symbols('c_1,c_2')
z=1/(x**2)*(c1*log(x)+c2)
z
Out[31]:
In [32]:
(2*x**2*z.diff(x,2)+10*x*z.diff(x)+8*z).simplify()
Out[32]:
In [33]:
b,k=symbols('b,k')
z=1/(k**2-b**2)*sin(b*x)
z
Out[33]:
In [34]:
((z.diff(x,2)+k**2*z)-sin(b*x)).simplify()
Out[34]:
In [35]:
integrate(x*exp(-x),x), integrate(x**2*exp(-x),x)
Out[35]:
In [36]:
C1=-integrate(Rational(1,2)*tan(2*x)*sin(2*x),x).simplify()
C2=integrate(Rational(1,2)*tan(2*x)*cos(2*x),x).simplify()
C1, C2
Out[36]:
In [37]:
Y=(C1*cos(2*x)+C2*sin(2*x)).simplify()
Y
Out[37]:
In [38]:
(Y.diff(x,2)+4*Y).simplify()
Out[38]:
In [39]:
m,g,L,r,rhoa,C=symbols('m,g,L,r,rho_a,C',positive=true)
C1,C2,t=symbols('C_1,C_2,t')
x=Function('x')(t)
In [40]:
x=C1*cos(sqrt(C)*t)+C2*sin(sqrt(C)*t)-g/C+L
x
Out[40]:
In [41]:
ec1=Eq(x.subs(t,0),0)
ec2=Eq(x.diff(t).subs(t,0),0)
ec1, ec2
Out[41]: