# Adding circles on a function plot depending on the slope

I have the following function and I use manipulate to change the plot of the function and the integral respectively. In nonlinear dynamics one plots a little circle/point on the intersections of the (left) graph with the x-axis. If the slope at the point of intersection is negative the circle/point is black, if the slope is positive, the point is white.

I want to do the same (only for the left graph), but dependent on the magnitude of the slope at the point of intersection (with the x-axes), I want to color the circles continuously, e.g. light green for a small negative slope at this point, getting more and more dark as the magnitude of the slope becomes more negative and the same for a positive slope e.g. red.

Any help appreciated!

 f[x_, a_, b_] := a x - b x^3

Manipulate[{Plot[f[x, a, b], {x, -2, 2}],
n = -\[Integral]f[x, a, b] \[DifferentialD]x;
Plot[n, {x, -2, 2}, PlotRange -> Automatic]}, {{a, 1/2,
"control parameter"}, -1, 2,
0.1}, {{b, 1/4, "control parameter 2"}, -1, 2, 0.1}]

• …and if the curve is tangent to the $x$-axis, what color do you want? – J. M.'s discontentment May 18 '15 at 10:16

Might you be looking for this?

The modifications are in the addition of the zeros table (though it would be much better to write down an analytical expression) and the rule for Epilog acts on it accordingly to generate the points. In my example, though, they are black for a small slope and become brighter red/green for larger negative/positive slopes. You can modify the arguments of the RGBColor function to adjust coloring to your needs.

Manipulate[
{
zeros = {#, (1/2 (Derivative[1, 0, 0][f])[#, a, b])} & /@
(x /. NSolve[f[x, a, b] == 0, x, Reals]);

Plot[f[x, a, b], {x, -2, 2},
Epilog -> (Flatten@
{PointSize[Large],
RGBColor[
HeavisideTheta[-Last@#] (-Last@#),
HeavisideTheta[Last@#] Last@#,
0],
Point[{First@#, 0}]} & /@ zeros)],

n = -\[Integral] f[x, a, b] \[DifferentialD] x;

Plot[n, {x, -2, 2}, PlotRange -> Automatic]},
{{a, 1/2, "control parameter"}, -1, 2,  0.1},
{{b, 1/4, "control parameter 2"}, -1, 2, 0.1}] • yes, that's exactly what I meant, thank you! – holistic May 18 '15 at 10:35
• One more possible color function: Blend[{Green, White, Red}, 1/(1 + Exp[-x])]. – J. M.'s discontentment May 18 '15 at 10:49