# Is there any way to plot function from other function?

For example, I have a function

W[L_, m_] := 1 + 3 L + 2 L^2 - 6 m - 6 Lm + 6 m^2

I also have

r = m/L


What is the easiest way to plot W-function from r?

Now I just manually plug in expression for r in W and obtain

W[L_, r_] := 1 + 3 L + 2 L^2 - 6 r*L - 6 L (r*L) + 6 (r*L)^2


Is there any other way to do that?

Note that you should not use upper-case letters for variables or names beginning with upper-case letters as they might conflict with Mathematica's internal names.

w[l_, m_] := 1 + 3 l + 2 l^2 - 6 m - 6  l m + 6 m^2

z[l_, r_] := w[l, m] /. m -> r l

w[l, m]


(* 1 + 3 l + 2 l^2 - 6 m - 6 l m + 6 m^2 *)

z[l, r]


(* 1 + 3 l + 2 l^2 - 6 m - 6 l m + 6 m^2 *)

• Or just w[l, r*l]. – march Nov 5 '15 at 17:40
• @march I interpretted Maria's question to require a function (with slots) with the substitution. But yes... if you need merely compute w with the substitution, your answer is fine. – David G. Stork Nov 5 '15 at 17:42
• True. But it's always worth letting the new users see multiple ways of doing things of course. But I think you accidentally removed the edit I made: r -> r l should be m -> r l, as illustrated by the output of z[l, r] that you copy-and-pasted. – march Nov 5 '15 at 17:44
• Should it be  r -> m/l ? Is there any difference if I write z[l_, r_] := w[l, m] /. m -> r l or z[l_, r_] := w[l, m] /. r -> m/ l ? – Maria Nov 5 '15 at 17:48
• @Maria. You should experiment with the different expression that you've written down and see which one works! It's the best way to learn Mathematica. – march Nov 5 '15 at 17:51