Loading [MathJax]/jax/output/HTML-CSS/jax.js
Ask Your Question
1

IVP and complex solutions

asked 7 years ago

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!!!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 7 years ago

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(2y3)+logy=iπ+3x2log2 .

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 eiπ becomes real. Explicitly: y2y3=14e3x . Equivalently: 2y3y=4e3x . The LHS is 23y, and we can easily extract y from here, y=3211+2e3x . (The Mathematica solution, and the following one coincide with the above, after amplification with e3x.) 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)]
Preview: (hide)
link

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 y(x)=3e(3x)2(e(3x)+2)

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 7 years ago )

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 ( 7 years ago )
0

answered 7 years ago

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!!!!!!!

Preview: (hide)
link

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: 7 years ago

Seen: 474 times

Last updated: Jan 21 '18