Skip to main content
1-Visitor
May 5, 2014
Solved

Periodic function doesn't work with ODEsolve?

  • May 5, 2014
  • 6 replies
  • 3549 views

Hello, everyone!

I've noticed that there is a friendly and helpful community here, so maybe you can help me out with my issue.

I'm solving a differential equation with odesolve command, and everything works no problem.

Now I'm trying to add a periodic square wave function with variable duty cycle into the equation, and everything gets more complicated. I've used two similar methods to define the periodic function and they both work almost the same.

The trouble is - with bigger values of duty cycle it works flawlessly, but as soon as I try to lower it, it seems that odesolve misses some values and the solution looks obviously wrong. My first guess is that it is a numerical problem, as the equation also contains some relatively small and big numbers, changing some of which also helps a bit, but that's unfortunately not an option. Maybe there is an option to use some other method besides odesolve, or any other trick to fix this behaviour?

All other comments and graphs are in the attached file.

Any help is highly appriciated!

BR, Maxim.

Best answer by AlanStevens

See attached. The default solver was the problem! I changed it to Adaptive (right-click on the word Odesolve to see the options).

Alan

6 replies

19-Tanzanite
May 5, 2014

See attached. The default solver was the problem! I changed it to Adaptive (right-click on the word Odesolve to see the options).

Alan

1-Visitor
May 5, 2014

Wow, that was easy!

Thank you so much! Wish I could be as proficient in Mathcad as you are.

I had no idea that changing solvers is such a simple, but kinda hidden process.

Thanks again.

Maxim