# Manipulate Plot with Find Root Parameter

I would like to plot the function G(r; x') as a function of r, but with parameter x'.

x' is the solution to F(x';p) = 0 where p is a parameter I can control.

Unfortunately F is messy and I must use FindRoot to solve F.

I would like to be able to use Manipulate to change p on a slider and see how that changes the plot of G.

For example,

F(x;p) = Log(p + px)

G(r;k) = k * Sin(log(k*r))

I'd like to plot G(r) with a slider for p.

How is this possible? Thanks.

\$Version

(* "14.0.0 for Mac OS X ARM (64-bit) (December 13, 2023)" *)

Clear["Global*"]

F[x_, p_] := Log[p + p*x]


Exact solution

xp = SolveValues[F[x, p] == 0, x][[1]]

(* (1 - p)/p *)


Numeric solution

xp2[p_?NumericQ] := x /. FindRoot[F[x, p] == 0, {x, 2}]

G[r_, k_] := k*Sin[Log[k*r]]

Manipulate[
Plot[
{G[r, xp /. p -> pv], G[r, xp2[pv]]},
{r, 0, 5},
PlotStyle -> {Automatic, Dashed},
AxesLabel -> (Style[#, 14] & /@ {r, G})],
{{pv, 0.5, "p"}, 0.01, 0.99, 0.01, Appearance -> "Labeled"},
TrackedSymbols :> {pv}]
`