# Parameter space constraint in Manipulate

I am trying to plot and manipulate the following 3rd degree polynomial:

f[a_,b_,c_,d_][x_]=ax^3+bx^2+c*x+d;

Manipulate[Plot[f[a, b, c, d][x],{x, -2, 2},PlotRange->All],
{{a, 2.76},-4,4},{{b,-3.12},-5,5},{{c, 1.14},-5, 5},{{d, 3},-8,8}]

but at the same time I want my parameters to satisfy the following condition:

b^2-3a*c=0

I am struggling to understand how to import such condition to the parameters in Manipulate. I've tried Piecewise but it didn't work. Since this condition has to be satisfied when I manipulate one of the parameters the others should automatically change.

• TrackingFunction is often a way to go
– Kuba
Nov 30, 2017 at 18:25
• @Kuba it works! Thank you! Dec 1, 2017 at 0:50

but at the same time I want my parameters to satisfy the following condition: b^2-3a*c=0

This can be done using second argument of dynamics as follows

Manipulate[
Grid[{
{Row[{Style["b^2-3a*c = ",16],Chop[b^2-3a*c]}]},
{Plot[(a*x^3+b*x^2+c*x+d)^2,{x,-2,2},PlotRange->All,ImageSize->400]
}},Frame->All,Spacings->{1, 1}],

Grid[{
{"a ",Manipulator[Dynamic[a,{a=#;c=#;b=Sqrt[3 a c]}&],{-4,7}],Dynamic[NumberForm[a,{3,3}]]},
{"b ",Manipulator[Dynamic[b,{b=#;c=#;a=b/3}&],{-5,5}],Dynamic[NumberForm[b,{3,3}]]},
{"c ",Manipulator[Dynamic[c,{c=#;b=#;a=c/3}&],{-4,7}],Dynamic[NumberForm[N@c,{3,3}]]},
{"d ",Manipulator[Dynamic[d,{d=#}&],{-5,5}],Dynamic[NumberForm[d,{3,3}]]}
}],
{{a,-1},None},
{{b,Sqrt[3.0]},None},
{{c,-1},None},
{{d,-3},None},
Alignment->Center,SynchronousUpdating->True,
SynchronousInitialization->True,
FrameMargins->1,ImageMargins->1,ControlPlacement->Left
]

The above will insure b^2-3a*c=0 when changing a or b or c.

• +1. But is there a way to do this with TrackingFunction? Dec 19, 2017 at 1:31
• @aardvark2012 as far as I know tracking function should work also, as it is similar to using second argument of dynamics, but I do not use trackingFunction. I like to find one method that works and stick to it. So I use the above method in all my manipulate code. If trackingFunction does not work for you, may be you could open a new question on this and someone who know more about this function could help. Dec 19, 2017 at 1:42