Ask Your Question
1

IVP and complex solutions

asked 2018-01-19 23:06:34 +0200

Ashish gravatar image
f(x,y)=-(-3*y+2*y^2)
p5sol2=desolve(diff(y,x)==f(x,y),y,ics=[0,0.5])

Returns the following:

-1/3*log(2*y(x) - 3) + 1/3*log(y(x)) == x - 26714619/25510582*I - 27229598/58926009

I get the following result from Mathematica:

y[x] -> (1.5 E^(3 x))/(2. + E^(3 x))

Why is sage returning a complex solution? I am assuming it has to do with the logs and absolute values when integrating. Any help will be appreciated. Thanks!!!

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2018-01-20 03:53:40 +0200

dan_fulea gravatar image

I tried more exactly (instead of that 0.5):

sage: x = var('x')
sage: y = function('y')(x)
sage: p5sol2 = desolve( diff(y,x) == 3*y - 2*y^2, y, ics=[0, 1/2], show_method=True )
sage: p5sol2
[-1/3*log(2*y(x) - 3) + 1/3*log(y(x)) == -1/3*I*pi + x - 2/3*log(2),
 'separable']

The offered implicit solution can now be rewritten, we multiply with $3$, we apply $\exp$ on both sides, then we can isolate $y$. Explicitly, after multiplying with $3$... $$ -\log(2y-3) + \log y = -i\pi + 3x -2\log 2\ .$$

sage: p5sol2 = desolve( diff(y,x) == 3*y - 2*y^2, y, ics=[0, 1/2] )
sage: 3 * p5sol2
-log(2*y(x) - 3) + log(y(x)) == -I*pi + 3*x - 2*log(2)

The rôle of $i$ is now simple to figure out, we apply $\exp$ and $e^{-i\pi}$ becomes real. Explicitly: $$\frac y{2y-3} = -\frac 14 e^{3x}\ .$$ Equivalently: $$\frac {2y-3}y = -4 e^{-3x}\ .$$ The LHS is $2-\frac 3y$, and we can easily extract $y$ from here, $$ y = \frac 32\cdot\frac 1{1+2e^{-3x}}\ .$$ (The Mathematica solution, and the following one coincide with the above, after amplification with $e^{3x}$.) Let us do this with code:

sage: solve( exp(-log(2*y(x) - 3) + log(y(x))) == exp(-I*pi + 3*x - 2*log(2)), y(x) )
[y(x) == 3/2*e^(3*x)/(e^(3*x) + 2)]
edit flag offensive delete link more

Comments

You can get the "Mathematica solution" with the following one-liner :

sage: (desolve(diff(y(x),x)==3*y-2*y^2,y,ics=[0,1/2])*3).exp().maxima_methods().exponentialize().solve(y(x))
[y(x) == 3/2*e^(3*x)/(e^(3*x) + 2)]

which is $\displaystyle y\left(x\right) = \frac{3 \, e^{\left(3 \, x\right)}}{2 \, {\left(e^{\left(3 \, x\right)} + 2\right)}}$

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 2018-01-20 09:18:32 +0200 )edit

Emmanuel Charpentier: Your idea works great. Thanks!!!!!!!

x=var('x');y=function('y')(x)
a=(desolve(diff(y(x),x)==3*y-2*y^2,y,ics=[0,1/2])*3).exp().maxima_methods().exponentialize().solve(y(x))
a=solve(a,y(x))[0].rhs()
plot(a,(x,0,10),ymin=0,ymax=2)
Ashish gravatar imageAshish ( 2018-01-21 00:30:14 +0200 )edit
0

answered 2018-01-21 00:29:43 +0200

Ashish gravatar image

dan_fulea:

Thanks!!! I appreciate your response but I was hoping that Sage would give me the solution without having to do the extra step of raising both sides of the implicit solution to E^(##) and then solving for y(x).

Emmanuel Charpentier: Your idea works great. Thanks!!!!!!!

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2018-01-19 23:06:34 +0200

Seen: 332 times

Last updated: Jan 21 '18