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.


1 Answer 1


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


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]]

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

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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