# Integration of multivariable piecewise function in SageMath

I have a problem that can be simplified as below:

```
g(w) = piecewise([[[0, 3], (w-3)^2], [(3, infinity), 0]])
f(w,t) = g*cos(w*t) # t >= 0
#assume(t, 'real')
h = integral(f, w, 0, 10); h
```

Out: t |--> undef

If I do not use piecewise, and integrate only up to w = 3 (where I know g becomes zero), then I obtain the wanted solution:

```
g2(w) = (w-3)^2
f2(w, t) = g2*cos(w*t)
h2 = integral(f2, w, 0, 3); h2
```

Out: t |--> 6/t^2 - 2

sin(3t)/t^3

How can I integrate f(w, t) defining g(w) piece-wisely (or equivalent)?

Welcome to Ask Sage! Thank you for your question!