I have a very basic question. Suppose I have two similar looking plots. May be they differ by some over all scaling (e.g, f[x_]:= x^2-x^3 and g[x_]:= 37(x^2-x^3)). But I do not know their functional forms. Is there a way in mathematica to superimpose them to decide whether they are same up to a scaling?

  • 3
    $\begingroup$ g[x]/f[x]? Or using Overlay. $\endgroup$ – Karsten 7. Nov 14 '15 at 20:27
  • $\begingroup$ Oh, so by "plots" you meant "functions"? f[x_] is not a plot, it is a function. A plot is a picture that depicts the function. $\endgroup$ – user484 Nov 14 '15 at 22:13
f[x_] := x^2 - x^3
g[x_] := 5 (x^2 - x^3)

Plot[{f[x], g[x], g[x]/f[x]}, {x, -2, 2}, PlotLegends -> "Expressions"]

enter image description here

g[x_] := 5 x (x^2 - x^3)

enter image description here

| improve this answer | |
  • $\begingroup$ Can I use this method if I have a numerical plot? $\endgroup$ – Physics Moron Nov 14 '15 at 20:52
  • $\begingroup$ What do you mean with numerical plot? ListPlot ? $\endgroup$ – eldo Nov 14 '15 at 21:05
  • $\begingroup$ I have a plot which I got solving a differential equation using ParametricNDSolveValue . I want to compare it with another known function. $\endgroup$ – Physics Moron Nov 14 '15 at 21:21
  • 1
    $\begingroup$ Yes, for example pfun = ParametricNDSolveValue[{f''[t] + a f[t] == 0, f[0] == 1, f'[0] == 0}, f[10], {t, 0, 10}, {a}] and then Plot[pfun[a]/Sin[a], {a, 0, 2}] $\endgroup$ – eldo Nov 14 '15 at 21:31
  • $\begingroup$ Thanks! So, all one has to check is to see whether f[x]/g[x] is a straight line. That line may not intersect the origin in general. If one gets almost straight line then the curves are very nearly equal. Are these statements correct? $\endgroup$ – Physics Moron Nov 14 '15 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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