2
$\begingroup$

I don't know why the following is not working! The code has a function y[x] then I have g[t] then I want to plot y vs inverse of g:

Clear["Global`*"]

Clear[y, g, x, t, d, b, f, m]

a = 0.7; b = 0.001; d = 0.1; f = 1.3; m = 0.7; x0 = 60;

y[x_] := x0*Sqrt[Sqrt[a - b/x^2] + d];

Plot[y[x], {x, 0, 10}]

g[t_, d_, b_, f_, m_]:=(Sqrt[a]*Log[12*Sqrt[a]*f^2*(t*Sqrt[a]+Sqrt[t^2*a-b])])/m-(ArcTanh[(t*d)/Sqrt[a*t^2-b]]*d)/m-(Log[3*f*(-b+t^2*m)]*d)/(2*m)

ParametricPlot[{{g[x, 0.1, -0.001, 1.3, 0.7], x}}, {x, 0.1, 10}]

ParametricPlot[{y[x],ParametricPlot[{g[x, 0.1, -0.001, 1.3, 0.7], x}]}, {x, 1, 10}]
$\endgroup$
5
  • $\begingroup$ e.g., If p1 = ParametricPlot[{Sin[u], Sin[2 u]}, {u, 0, 2 Pi}] then Head[p1] is Graphics and you are trying to include this inside your plot. $\endgroup$
    – Syed
    Nov 29 '21 at 17:16
  • 3
    $\begingroup$ Try something like ParametricPlot[{y[x], g[x, 0.1, -0.001, 1.3, 0.7]}, {x, 1, 10}, AspectRatio -> 1] for your final line of code. $\endgroup$
    – bbgodfrey
    Nov 29 '21 at 18:17
  • $\begingroup$ I would like to see y[g^-1[t]] $\endgroup$
    – M.S MD
    Nov 29 '21 at 18:34
  • $\begingroup$ Please, have a look at the comment of @bbgodfrey, it is a good solution. Moreover, it does not require any inverse functions. $\endgroup$
    – yarchik
    Nov 29 '21 at 21:09
  • $\begingroup$ We should plot ParametricPlot[{ g[x, 0.1, -0.001, 1.3, 0.7],y[x]}, {x, 1, 10}, AspectRatio -> 1] instead of {y[x], g[x, 0.1, -0.001, 1.3, 0.7]} $\endgroup$
    – cvgmt
    Nov 30 '21 at 2:20
0
$\begingroup$

Not sure what you want but here is a guess:

Clear["Global`*"]

Clear[y, g, x, t, d, b, f, m]

a = 0.7; b = 0.001; d = 0.1; f = 1.3; m = 0.7; x0 = 60;

y[x_] := x0*Sqrt[Sqrt[a - b/x^2] + d];

LogLinearPlot[y[x], {x, 0, 10}, PlotRange -> All]

enter image description here

 g[t_, d_, b_, f_, 
      m_] := (Sqrt[a]*Log[12*Sqrt[a]*f^2*(t*Sqrt[a] + Sqrt[t^2*a - b])])/
       m - (ArcTanh[(t*d)/Sqrt[a*t^2 - b]]*d)/
       m - (Log[3*f*(-b + t^2*m)]*d)/(2*m)

Calculate some values for the inverse function and then interpolate

  vals = Table[{g[x, d, b, f, m], x}, {x, 1, 10, 0.1}];
h = Interpolation[vals];
{g1, g2} = h[[1, 1]];
ParametricPlot[{h[t], y[t]}, {t, g1, g2}, PlotRange -> All, 
 AspectRatio -> 1, 
 AxesLabel -> {"y", "\!\(\*SuperscriptBox[\(g\), \(-1\)]\)"}]

enter image description here

Is this now what you need?

$\endgroup$
4
  • $\begingroup$ I want to plot y[x] vs InverseFunction [g][x] $\endgroup$
    – M.S MD
    Nov 29 '21 at 18:22
  • $\begingroup$ I guess it is better I say like this g[x]=t then x=g^-1[t] so now y[g^-1[t]] $\endgroup$
    – M.S MD
    Nov 29 '21 at 18:37
  • $\begingroup$ h[x]=InverseFunction[g][x] so how to plot parametric y vs h ?! $\endgroup$
    – M.S MD
    Nov 29 '21 at 18:39
  • $\begingroup$ I'm checking it. I will let you know. thanks $\endgroup$
    – M.S MD
    Nov 29 '21 at 23:10
0
$\begingroup$

There are two ways to do this. Since we plot $$y=y(g^{-1}(x))$$ so we can use InverseFunction.

gg[x_] = g[x, 0.1, -0.001, 1.3, 0.7];
fig1=Plot[y@InverseFunction[gg][x], {x, -5, 5},AxesOrigin -> {0, 0}]

enter image description here

The other way is $x=g(t)$,then $t=g^{-1}(x)$,$y(t)=y(g^{-1}(x))$,so we plot ParametricPlot $(g(t),y(t))$

gg[x_] = g[x, 0.1, -0.001, 1.3, 0.7];
fig2=ParametricPlot[{gg[t], y[t]}, {t, -20, 20}, AxesOrigin -> {0, 0}, 
 AspectRatio -> 1,PlotStyle->Red]

We can compare the two way.

Show[fig1, fig2]

enter image description here

$\endgroup$

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