Message Boards Message Boards

0
|
7953 Views
|
8 Replies
|
7 Total Likes
View groups...
Share
Share this post:

[?] Solve an ODE with DSolve?

Posted 7 years ago

Hi, I'm new to Mathematica, and I'm trying to solve an ODE with it, but I get the wrong solution! (or maybe my book is wrong I dunno lol)

Here is the problem: enter image description here

and this should be the solution by my book: enter image description here

Now in Mathematica the code i used is:

DSolve[{x^2 * y''[x] + 7*x*y'[x] + 9*y[x] == 0, y'[-1] == -3, 
  y[-1] == 2}, y[x], x]

and the output is: {{y[x] -> (I (2 I + 9 [Pi] + 9 I Log[x]))/x^3}}

image: enter image description here

What I'm doing wrong?

Thanks.

POSTED BY: Michael Astahov
8 Replies

DSolve[] always treats all variables as complex; unless you tell, say, FullSimplify[] that x is real.

 sol = y[x] /. First@DSolve[{x^2*y''[x] + 7*x*y'[x] + 9*y[x] == 0, y'[-1] == -3, y[-1] == 2}, y[x], x]
 FullSimplify[Re[sol] // ComplexExpand, Assumptions -> x > 0] // Expand

$$y(x)=-\frac{2}{x^3}-\frac{9 \log (x)}{x^3}$$

POSTED BY: Mariusz Iwaniuk

I think there's a slight mistake: (1) The initial condition is at a negative value of $x$, so the domain of the solution is $x < 0$. (2) The solution is real so Re in Re[sol] should be unnecessary. (3) Consequently, the assumption in FullSimplify leads to an expression that has a nonzero imaginary part at $x = -1$ due to $log(x)$, and the initial condition is not satisfied.

POSTED BY: Michael Rogers

Hello

You are absolutely right ,I do not check initial condition for solution.

My mistake.

Regards Mariusz.

POSTED BY: Mariusz Iwaniuk

The solutions are equivalent:

Simplify[(I (2 I + 9 ? + 9 I Log[x]))/x^3 - (-2 x^-3 - 9 x^-3 Log@Abs[x]), x < 0]
(*  0  *)
POSTED BY: Michael Rogers

Yea right it is equal :) but how that's possible.. I don't see how: (9?i*x^-3) have anything to do here?

POSTED BY: Michael Astahov
Posted 7 years ago

Hi,

Keep in mind that Log[] is the complex logarithm:

Simplify[ComplexExpand@Log[x], x < 0]
(*  1/2 (2 I ? + Log[x^2])  *)

Log[-1]
(*  I ?  *)

(* etc. *)

Because your initial condition is at x == -1, the Log[x] in the solution returned by DSolve has a nonzero imaginary part, namely, I ?. You can somewhat recover the desired form of the answer as follows:

Simplify[(I (2 I + 9 ? + 9 I Log[x]))/x^3, x < 0]
(*  (-2 - 9 Log[-x])/x^3  *)

It is, in fact, a strength that Mathematica works in terms of complex analysis, but OTOH, most people haven't studied complex analysis. From the point of view of mathematics through the first two years of college calculus (= introductory real analysis), it can seem unnecessarily complex -- i.e., complicated. :) -- to both students and professors. Recently, as Wolfram has made inroads into the introductory math curriculum and, reciprocally, interest in Wolfram has grown, functions such as CubeRoot[] (V9), Surd[] (V9), and RealAbs[] (V11.1) have been introduced, which are the standard real functions studied in high school.

POSTED BY: Updating Name

It could also be your boundary conditions:

In[28]:= ClearAll["Global`*"]

In[29]:= DSolve[{x^2*y''[x] + 7*x*y'[x] + 9*y[x] == 0, 
  y'[-1] == -9 - 3 I (2 I - 9 \[Pi]), y[-1] == -I (2 I - 9 \[Pi])}, 
 y[x], x]


Out[29]= {{y[x] -> (-2 - 9 Log[x])/x^3}}

In[33]:= y[-1]

Out[33]= -I (2 I - 9 \[Pi])

In[34]:= y'[-1]

Out[34]= -9 - 3 I (2 I - 9 \[Pi])
POSTED BY: Kay Herbert
In[14]:= ClearAll["Global`*"]

In[15]:= DSolve[{x^2*y''[x] + 7*x*y'[x] + 9*y[x] == 0, y'[-1] == -3, 
  y[-1] == 2}, y[x], x]


Out[15]= {{y[x] -> (I (2 I + 9 \[Pi] + 9 I Log[x]))/x^3}}

In[16]:= y[x_] := (I (2 I + 9 \[Pi] + 9 I Log[x]))/x^3

Perhaps you copied down the equation wrong? The solution seems correct:

In[17]:= x^2*y''[x] + 7*x*y'[x] + 9*y[x] == 0

Out[17]= x^2 (63/x^5 + (12 I (2 I + 9 \[Pi] + 9 I Log[x]))/x^5) + 
  7 x (-(9/x^4) - (3 I (2 I + 9 \[Pi] + 9 I Log[x]))/x^4) + (
  9 I (2 I + 9 \[Pi] + 9 I Log[x]))/x^3 == 0

In[18]:= Reduce[
 x^2 (63/x^5 + (12 I (2 I + 9 \[Pi] + 9 I Log[x]))/x^5) + 
   7 x (-(9/x^4) - (3 I (2 I + 9 \[Pi] + 9 I Log[x]))/x^4) + (
   9 I (2 I + 9 \[Pi] + 9 I Log[x]))/x^3 == 0]

Out[18]= True
POSTED BY: Kay Herbert
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract