# How to enter g(x, y) = f(3x ? y) into Mathematica for a contourplot?

Posted 9 years ago
4774 Views
|
3 Replies
|
0 Total Likes
|
 For an assignment I need the contour of this function. It is a function within a function
3 Replies
Sort By:
Posted 9 years ago
 But why did you use Exp[-x^2] for f[x]? Where do you get it from? ContourPlot needs a function to evaluate; try ContourPlot[unknownFunction[a, b], {a, -1, 1}, {b, -1/2, 1/2}] to see nothing. Same thing with Clear[f, g] (* f[x_]:= Exp[-x^2] *) g[x_, y_] := f[3 x - y] ContourPlot[g[a, b], {a, -1, 1}, {b, -1/2, 1/2}] again you see nothing because g does not evaluate to some real number. By the way, you may type directly with your function f (let's say f = BesselJ for the sake of definiteness) ContourPlot[BesselJ[1, 3 a - b], {a, -1, 1}, {b, -1/2, 1/2}] CountourPlot does not need a function of two variables, but it needs 2 parameters (a and b in the last example). You can do also ContourPlot[BesselJ[1, 3 a], {a, -1, 1}, {b, -1/2, 1/2}] now the contour plot is real 1-D and even ContourPlot[BesselJ[1, \[Pi]], {a, -1, 1}, {b, -1/2, 1/2}] can be given: now the contour plot is contour-less, it is 0-D, the whole area evaluates to the same value BesselJ[1, Pi]. You say that f is a function of one variable but it consists of x and y? One should distinguish between dependent and independent variables, to make it clear.Is Sin[x0 + 2 x1 + 3 x2 + 4 x3 + 5 x4 + 6 x5] a function of one independent variable? Yes. But this single independent variable variable x = p[x0,x1,x2,x3,x4,x5] = x0 + 2 x1 + 3 x2 + 4 x3 + 5 x4 + 6 x5 is created by the map p: R^6 -> R. Each x represents a whole five dimensional linear space made of the six dependent variables x0, x1, x2, x3, x4, and x5 because of the equation established by the map p.In the end, if somebody talks about a function as a function of one variable, he or she most often means a function of one independent variable.Another way to look into this is the Chain Rule invented by Leibniz, see also Chain Rule.
Posted 9 years ago
 Ok, I got a contourplot now. Thank you for that! But why did you use Exp[-x^2] for f[x]? Where do you get it from? You say that f is a function of one variable but it consists of x and y?
Posted 9 years ago
 In:= Clear[f, g] f[x_] := Exp[-x^2] g[x_, y_] := f[3 x - y] ContourPlot[g[a, b], {a, -1, 1}, {b, -1/2, 1/2}] does not work? Because f is a function of one variable, the contour plot is quasi-1D.