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


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:


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.

  • $\begingroup$ TrackingFunction is often a way to go $\endgroup$ – Kuba Nov 30 '17 at 18:25
  • $\begingroup$ @Kuba it works! Thank you! $\endgroup$ – Paul Schrednicki Dec 1 '17 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

enter image description here

{Row[{Style["b^2-3a*c = ",16],Chop[b^2-3a*c]}]},
}},Frame->All,Spacings->{1, 1}],

{"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}]]}

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

  • $\begingroup$ +1. But is there a way to do this with TrackingFunction? $\endgroup$ – aardvark2012 Dec 19 '17 at 1:31
  • $\begingroup$ @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. $\endgroup$ – Nasser Dec 19 '17 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.