# Mathematica: Plot the derivative of a piecewise function

## Mathematica: Plot the derivative of a piecewise function

Try using `Plot[Evaluate[f[t]], {t, -1, 1}]`

Plot is a bit picky when it comes to user defined functions.

With the given function you could use:

```
Plot[f[t], {t, -1, 1}, Evaluated -> True]
```

`Evaluated -> True`

is to be preferred over `Evaluate[f[t]]`

.

Better is to follow nikies advice and define `f`

differently:

```
Block[{t},
f[t_] = D[moll[t], t]
]
```

See Scoping in assigning a derivative for an explanation.

#### Mathematica: Plot the derivative of a piecewise function

The pickyness of Plot comes from its `Atttributes[Plot]`

, which include `HoldAll`

, so the unadorned `f`

never gets evaluated. Force evaluation as ratatosk suggests.