tags:

views:

40

answers:

1

hi i can't solve this differential equation by ode45 beacause it has sigularity.

xy"=3xcos(x)+sin(x) ; x(0)=0 , x'(0)=0

can you help me to write ode45 function?

+2  A: 

You can use the sinc(x) function, which is defined as sin(π*x)/(π*x), except at x=0 where its value is 1. So, you can rewrite your ODE as:

y'' = 3*cos(x) + sinc(x/π)

which ode45 shouldn't have any trouble solving.

Ray
Don't you need to throw a `π` in there somewhere? `y'' = 3*cos(x) + π * sinc(x/π)` maybe?
CanSpice
@CanSpice: You're right; I forgot the factor of π on the outside.
Ray
Actually, I don't think the factor of π should be there, since `sinc(x/π) = sin(x)/x`, which is the term being replaced.
gnovice
Okay, so it was right the first time. I can't say I'm a fan of the normalized sinc function, but that's what's implemented in Matlab.
Ray

related questions