# Solving graphically equation

I am trying to solve a equation graphically but the plot doesn't display anything...

eqn = K == (Cc + x)/((Ca - 2 x)^2 (Cb - x))
const = {K -> 0.016, Ca -> 42, Cb -> 28, Cc -> 4}
f[x_] = eqn /. const
Plot[f[x], {x, 0, 20}]


I tried with Plot, but it doesn't work, how can I solve it graphically?

• f = eqn /. const and Plot[f, {x, 0, 20}], or leave f[x_] as is and use Plot[Evaluate[f[x]], {x, 0, 20}]. – AccidentalFourierTransform Apr 25 '18 at 21:40
• @AccidentalFourierTransform and that's all I have to do to solve it graphycally? Or there are others steps? – Darius Ionut Apr 25 '18 at 21:51

eqn = K == (Cc + x)/((Ca - 2 x)^2 (Cb - x));
const = {K -> 0.016 // Rationalize, Ca -> 42, Cb -> 28, Cc -> 4};
f[x_] = eqn /. const;

plt = Plot[Evaluate@f[x], {x, 0, 20}, MaxRecursion -> 5] Finding the x-value of the point on the plot line that is closest to y == 0

SortBy[Cases[plt, Line[pts_] :> pts, Infinity][], Abs[#[]] &][[1, 1]]

(* 15.9261 *)


Compare with the actual root

Solve[f[x], x, Reals][] // N

(* {x -> 15.923} *)


This is another approach in which is plotted the crossing-point with MeshFunction, and extract that point:

eqn = K == (Cc + x)/((Ca - 2 x)^2 (Cb - x));
const = {K -> 0.016 // Rationalize, Ca -> 42, Cb -> 28, Cc -> 4};
f[x_] = eqn /. const


$$\frac{2}{125}=\frac{x+4}{(42-2 x)^2 (28-x)}$$

plt = Plot[Evaluate@f[x], {x, 0, 20}, MaxRecursion -> 5, Mesh -> {{0.}},
MeshFunctions -> Function[{x}, -(2/125) + (4 + x)/((42 - 2 x)^2 (28 - x))],
Frame -> True,
MeshStyle -> {{Red, PointSize[Medium]}, {Green, PointSize[Medium]}}] Cases[plt[[1, 1, 1]], {a_, b_} /; Abs[b] < 10^-6]


{{15.923, -1.13533*10^-7}}