# What is the recommended way to plot a function with a dependent variable?

I am currently learning the basics of Mathematica. I can't seem to find a straightforward answer in the Wolfram documentation, probably for a lack of clarity in my queries.

For example, I want to plot $$f=\frac{a}{x}$$ with $$x=\frac{y}{b}$$, and manipulate the variable $$y$$, but obtain a graph with $$x$$ on the $$x$$-axis.

On Mathematica I would write:

f=a/x;
x=y/b;
Plot[f,{y,0,10}]


This gives me the correct resulting plot but, of course, with the ticks'values of $$y$$ on the $$x$$-axis, instead of the ones of the dependent variable $$x$$. Do I need to change the ticks, or is there a more elegant way to achieve a plot with the values of $$x$$ on the $$x$$-axis?

Thank you.

• Try with ParametricPlot reference.wolfram.com/language/ref/ParametricPlot.html – mattiav27 Sep 24 '18 at 18:30
• I am not sure I understand this. You want x on the x axis and a/x on the y axis? Where does y and b come into this? – Hugh Sep 24 '18 at 18:52
• @mattiav27 thank you! That's exactly what I was looking for. – bg_da Sep 24 '18 at 18:59
• @Hugh Yes, x on the x-axis, and a/x on the y-axis. y is the only variable by which x depends on, as the values of a and b are known. What I needed was the ParametricPlot command. – bg_da Sep 24 '18 at 19:04

A static solution can be written like this:

With[{a = 1., b = .4, tmin = 0, tmax = 10},
Block[{f, x, xticks},
f[u_] := a/u;
x[u_] := u/b;
xticks = {#, Round[x[#], .1]} & /@ Subdivide[tmin, tmax, 11];
Plot[f[x[t]], {t, tmin, tmax},
PlotRange -> {Automatic, {0, 3}},
Ticks -> {xticks, Automatic}]]] A more interesting dynamic solution looks like this:

With[{tmin = 0, tmax = 10},
Manipulate[
Dynamic @
Plot[f[x[t]], {t, tmin, tmax},
PlotRange -> {Automatic, {0, 3}},
Ticks -> {xticks, Automatic}],
{{a, 1.}, 0, 2, .1, Appearance -> "Labeled"},
{{b, 1.}, .1, 2, .1, Appearance -> "Labeled"},
{xticks, None},
Initialization :> (
f[u_] := a/u;
x[u_] := u/b;
xticks := {#, Round[x[#], .1]} & /@ Subdivide[tmin, tmax, 11])]] 