0
$\begingroup$

Suppose I have a function of x with two parameters a,b : f(x;a,b).

I want to plot x'(a,b) where x' is the root of the above function .i.e f(x';a,b).

I know that for all a and b, the roots real.

How can I plot this over a range of a and b?

I feel like if I specify a resolution, then I'll just get a scatter plot of individual points. I'd like to get a smooth plot ideally.

$\endgroup$
1
  • 1
    $\begingroup$ Please include an example function and the parameter ranges to get a concrete answer. Thanks. $\endgroup$
    – Syed
    Feb 9 at 18:20

1 Answer 1

2
$\begingroup$
$Version

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

Clear["Global`*"]

f[x_, a_, b_] := a*x + b

root[a_, b_] = SolveValues[f[x, a, b] == 0, x][[1]]

(* -(b/a) *)

In 3D

Plot3D[root[a, b], {a, -5, 5}, {b, -6, 6},
 AxesLabel -> (Style[#, 14] & /@ {a, b, root}),
 ClippingStyle -> None]

enter image description here

In 2D

Plot[Evaluate@Table[
   Tooltip[root[a, b], b], {b, -6, 6}],
 {a, -5, 5},
 AxesLabel -> (Style[#, 14] & /@ {a, root}),
 PlotLegends -> LineLegend[Range[-6, 6],
   LegendLayout -> {"Column", 2},
   LegendLabel -> Style[b, 14]]]

enter image description here

$\endgroup$

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.