Message Boards Message Boards

Telling NDSolve to solve for reals only

POSTED BY: Josh Wofford

Using this code above I keep getting imaginary solutions, which I don't want.

Well, if that is the solution, then there is really nothing you can do about it. You can always change the problem to obtain a solution that does not generate a complex solution.

But if you want to remove the complex terms after you obtain the solution, then you can try something as

myImaginarySolution = x^3 + 2 Sin[x t] + 3 I + t Sin[2 t] - 5 I x;
Simplify @ ComplexExpand @  Re @ myImaginarySolution

   x^3 + t Sin[2 t] + 2 Sin[t x]

btw, DSolve does not take assumptions. (but I think functions, if any, called by DSolve uses assumptions, I seem to remember this). So if you try to make assumptions before calling DSolve (as in Assuming[....,DSolve]), these will be ignored by DSolve. Which removes terms that are complex, returning

POSTED BY: Nasser M. Abbasi
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