# How to manipulate a plot of partial derivatives of self-defined bivariate functions?

I have a piecewise linear function (spline) describing a progressive income tax schedule, with higher marginal rates kicking in for higher and higher incomes.

I want to understand the implications of a rule that some tax exempt income might still raise your average rate on the taxable part. Basically, with x being taxable income and y being exempt income, your taxes will be f(x+y)/(x+y)*x, where f is the nonlinear scheme that would apply to income without exemptions. I can define f as a piecewise linear function, see above.

To calculate marginal tax rates on taxable and exempt income, I’d simply need the partial derivates of this expression, with the particular function f plugged in, and this I can plot against the two variables. Or plot against one and use the other as a parameter for Manipulate.

The derivative looks OK in Mathematica, though it is a bit hard to check with so many cases.

However, I get empty plots, which of course are pointless to manipulate. Where does this go wrong?

Manipulate[Plot[D[Tax[x+y]/(x+y)*x,y],{y,0,200000}],{x,0,200000}]


Think of Tax this way:

Tax [z_]:= Piecewise[{
{0,0    <=z< 11265},
{0+ 0.0856(z-11265),11265<=z}
}]


Use Evaluate in the first argument of Plot:

Manipulate[Plot[Evaluate@D[Tax[x + y]/(x + y)*x, y], {y, 0, 200000}],
{x, 0, 200000}] • Does it work for you? I still get an empty plot, even if I move x around. Jul 2, 2019 at 19:55
• @László, it works in both version 12 (Wolfram Cloud) and version 9 (Windows 19). I posted a picture. (Perrhaps using ClearAll[Tax] before you define Tax may help to avoid possible previous assignments getting in the way).
– kglr
Jul 2, 2019 at 20:07
• Great, it did the trick, thanks! Jul 2, 2019 at 20:24