Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am using functions that are only well-defined for real values (e.g. HeavisideTheta) within NDSolve.

Internally NDSolve works, of course, with complex numbers and sometimes returns a numerically vansihing complex value (e.g. 0.` i) that breaks these functions.

Is it possible to get rid of the complex part (like applying Chop at each step)?

share|improve this question
1  
It would be good to provide a simple example demonstrating the problem, for people to test possible answers with. –  Simon Woods Nov 18 '13 at 21:48

1 Answer 1

Instead of getting rid of the small complex part after each internal step of NDSolve, I would make the projection before feeding those wimpy functions:

unbreakableHeavisideTheta[x_] := HeavisideTheta[Chop[x]]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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