1
$\begingroup$

For next Riccati d.e $ y' = (y^2) - 2 x^2 y + (x^4) + 2 x + 4 $ with DSolve i get Complex general solution

Opres = DSolve[y'[x] == y[x]^2-2x^2*y[x]+x^4+2x+4, y[x], x]

$\left\{\left\{y(x)\to \frac{1}{c_1 e^{4 i x}-\frac{i}{4}}+x^2-2 i\right\}\right\}$

Like you told me here in some my posts that DSolve working with Complex numbers and etc, i want you ask next:

On my universitet in Serbia in our definition for General Solution we are taking only REAL"S General Solution. My teacher told that we took that definition from Rusian's book's, and we do not take complex general solutions.

My question: Is it posible command DSolve to do only with real's numbers and give me only real's general solution ?

Tnx.

$\endgroup$
1
$\begingroup$

Will this be enough?

ComplexExpand performs operations assuming variables will be real.

sol=ComplexExpand[y[x]/.DSolve[y'[x] == y[x]^2-2x^2*y[x]+x^4+2x+4, y[x], x][[1]]]

which gives you

x^2 + (C[1]*Cos[4*x])/(C[1]^2*Cos[4*x]^2 + (-1/4 + C[1]*Sin[4*x])^2) + 
I*(-2 + 1/(4*(C[1]^2*Cos[4*x]^2 + (-1/4 + C[1]*Sin[4*x])^2)) - 
(C[1]*Sin[4*x])/(C[1]^2*Cos[4*x]^2 + (-1/4 + C[1]*Sin[4*x])^2))

The second term appears to be the complex component.

Try solving to make that second term==0.

Simplify[Solve[(-2 + 1/(4*(C[1]^2*Cos[4*x]^2 + (-1/4 + C[1]*Sin[4*x])^2)) -
  (C[1]*Sin[4*x])/(C[1]^2*Cos[4*x]^2 + (-1/4 + C[1]*Sin[4*x])^2))==0,C[1]]]

which gives you

{{C[1] -> -1/4}, {C[1] -> 1/4}}

If you substitute those into your original solution then

sol/.C[1]->-1/4//FullSimplify

gives you

2 + x^2 - 4/(1 + Tan[2*x])

and

sol/.C[1]->1/4//FullSimplify

gives you

2 + x^2 + 4/(-1 + Cot[2*x])

both of which appear to be real solutions.

Please check all this very carefully to make certain there are no mistakes.

$\endgroup$
2
  • $\begingroup$ That's ok for that example, tnx on asnwer , but is it posible for to make some in "General" for DSolve to work only with real's number's , not with Complex ? $\endgroup$ Dec 4 '18 at 4:13
  • 1
    $\begingroup$ By default Mathematica does almost everything assuming complex numbers. Many years ago there was a tool that tried to limit calculations to real values. I do not believe that has been available in any recent version of Mathematica. So I am guessing the answer to your question is no. But someone who knows more than I might be able to think of some way of doing what you want. $\endgroup$
    – Bill
    Dec 4 '18 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.