# solve ode on given interval

Hi,

I would like to tell Sage to solve ode on a given interval that I will specify. My final goal is to use this method to solve ode that contains 'piecewise' function like `2*diff(u,x) + u == f(x)`

, where

```
f = piecewise([((-1,0),0), ((0,1),x), ((1,2),2-x), (RealSet.unbounded_above_closed(2),0)])
```

Thanks.

did you try the approach suggested in your previous post, to write $f$ as a sum of

`unit_step`

functions? for instance, here it would be`unit_step(t)*unit_step(1-t)*t + unit_step(t-1)*unit_step(2-t)*(-t+2)`

. perhaps a method`to_unit_step`

of piecewise functions could be useful to have..No, I didn't think about the problem that way, I was rather think of a way to make Sage solve the ode on a specified interval. But, thanks, it's still something that works (at least for this problem).