# [SOLVED]plotting mathematica

#### dwsmith

##### Well-known member
Code:
f[r_][x_] := 1 + r*x + x^2;
A = Table[
cps[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz], {r, -5,
5, 0.01}];
I want to then tell mathematica to check the derivative of f with each value from the table, plot the values, but make the lines where there derivative in less than 0 solid and dashed for greater than 0.

Any ideas on how to finish this?

#### dwsmith

##### Well-known member
Code:
f[r_][x_] := 1 + r*x + x^2;
cps[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz]
I want to then tell mathematica to check the derivative of f with each value from the table, plot the values, but make the lines where there derivative in less than 0 solid and dashed for greater than 0.

Any ideas on how to finish this?
So I got rid of the table.
Code:
f[r_][x_] := 1 + r*x + x^2;
cps[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz];
g[r_] = x /. Quiet[Solve[f[r][x] == 0, x], Solve::ratnz]
Plot[g[r], {r, -5, 5}, PlotStyle -> {Red, Thick}]
{1/2 (-r - Sqrt[-4 + r^2]), 1/2 (-r + Sqrt[-4 + r^2])}
Manipulate[Plot[f[r][x], {x, -4, 4}], {r, -10, 10}]

y[r_] = 1/2 (-r - Sqrt[-4 + r^2]);
t[r_] = 1/2 (-r + Sqrt[-4 + r^2]);
Plot[{y[r], t[r]}, {r, -5, 5},
PlotStyle -> {{Dashing[{Medium}], Red}, {Thick, Red}}]
I can create what I want be defining the g[r] output but is there a way to have the g[r] output automatically defined as functions without doing it by hand?