# Can the Assuming function be used with ContourPlot or DensityPlot?

I'm new to Mathematica, and for most purposes the program has served me well and been straightforward. However, I'm hitting a snag while trying to create a contour plot for the distribution function

$$\qquad f(x,y) = (x\,y)^{p-1}/(\alpha + \beta\,x + \gamma\,y + \delta\,x\,y)^{p + q}$$

Notice $$x,y$$ are variables, and $$\alpha,\beta,\gamma,\delta, p,$$ and $$q$$ are constants. I need to set a list of assumptions for constants in the function, but my attempts have been fruitless. Every command yields a graph without an image.

I first tried assigning my function with its assumptions by:

Assuming[
{x > 0, y > 0, p > 0, α > 0, β > 0, γ > 0, δ > 0},
f[x_, y_] :=
(x*y)^(p - 1)/(α + β*x + γ*y + δ*x*y)^(p + q)]


After the assignment, I tried plotting with ContourPlot and DensityPlot.

I'll provide just the ContourPlot expression below because not much changes across them:

ContourPlot[f[x, y], {x, 0, 200}, {y, 0, 200}]


In regards to the ContourPlot code, I've changed the domain to both larger and smaller numbers to no avail. Neither ContourPlot nor DensityPlot provides an image. I then try the code without assigning the function beforehand, while including ContourPlot within the Assuming command:

Assuming[
{α > 0, β > 0, γ > 0, δ > 0, p > 0},
ContourPlot[(x*y)^(p - 1)/(α + β*x + γ*y + δ*x*y)^(p + q), {x, 0, 3}, {y, 0, 3}]]


I know this equation should produce some sort of image since it's simply a type of truncated distribution function. I believe I've narrowed down the issue to one of the following: Mathematica does not allow assumptions to be used with ContourPlot/DensityPlot, the distribution function is too complicated for Mathematica, or my user error is hindering me. My next step is to try creating different plots on the same graph for various pre-determined values of the parameters.

Any help is much appreciated. As previously mentioned, I'm not very experienced with Mathematica, so I'm more than willing to learn something new or help further explain my goals.

• MemberQ[Keys[Options[ContourPlot]], Assumptions] returns False, so you can't use assumptions on ContourPlot[]. Your more pressing problem is that you have neglected to provide concrete values for your parameters, so there really is nothing for the plotter to do. (Also, xy and x y are very different things, which contributes to why you can't plot.) Mar 4, 2019 at 2:47
• That makes sense. I'll stop trying to use Assumptions with ContourPlot now. I don't know how I didn't catch myself sooner, but I now realize I had typed xy instead of x*y. This actually fixes another, unrelated issue I was having with the code. That said, thank you so much for your help! Mar 4, 2019 at 3:09
• Shouldn't (xy)^(p - 1)/(α + βx + γy + δxy)^(p + q)] be (x y)^(p - 1)/(α + β x + γ y + δ x y)^(p + q)] The additional spaces make a big difference. Mar 4, 2019 at 3:59
• Yes, was thinking the same thing, otherwise Mathematica thinks each term is one variable for example xy and not the product of these.
– mjw
Mar 4, 2019 at 4:08
• You also need to set the constants to some values to plot your function. To take a simpler example, to plot Exp[-x^2 / (2 sigma^2)] / (sigma Sqrt[2 pi], you would need to specify sigma.
– mjw
Mar 4, 2019 at 4:11

As has been said in the comments to your question, because all plotting functions are based on strictly numerical calculations, you must give definite values to all six parameters. If you are in the position where you have no good idea how the function behaves as the parameters vary, you can explore the situation with Manipulate. Here is an example.

f[α_, β_, γ_, δ_, p_, q_][x_, y_] := (x y)^(p - 1)/(α + β x + γ y + δ x y)^(p + q)

With[{ϵ = .0001},
Manipulate[
ContourPlot[f[α, β, γ, δ, p, q][x, y], {x, 0, 2}, {y, 0, 2}],
{α, ϵ, 1, Appearance -> "Labeled"},
{β, ϵ, 1, Appearance -> "Labeled"},
{γ, ϵ, 1, Appearance -> "Labeled"},
{δ, ϵ, 1, Appearance -> "Labeled"},
{p, 1, 4, 1, Appearance -> "Labeled"},
{q, 1, 4, 1, Appearance -> "Labeled"}]]


Note: I have no clue about what comprise good ranges for either the parameters or the variables. I made some simple assumptions about them. You should revise these assumptions to suit your needs.

• It looks like you separated out the "constants" and the "variables" in your function definition. Is there any significance to that other than convenience of notation? Where is this documented (just did a quick search for defining functions and did not see it)? Thanks!
– mjw
Mar 4, 2019 at 5:33
• @mjw, this tutorial might be of interest. It is not necessary to separate parameters and variables in this way, but it is definitely convenient. Mar 4, 2019 at 5:46
• @mjw. It is documented as J.M. points out. A higher level reference which a list of links about topics concerning functions is this one, which included the link given by J.M. Mar 4, 2019 at 5:50
• @mjw. I use this style more for reasons of clarity than convenience. Mar 4, 2019 at 5:54
• @J.M. Thank you! So what is f[a_,b_][x_,y_], a function? Or a function of a function? I guess that I understand that now the head of the expression is f[a,b].
– mjw
Mar 4, 2019 at 5:57

One way is to simply set the constants as variables in your function definition, and then set them to the values you want when you call the function:

f[x_, y_, α_, β_, γ_, δ_, p_, q_] := (x y)^(p -1)/(α + β x + γ y + δ x y)^(p + q);

ContourPlot[f[x, y, 2, 3, 4, 5, .5, .5], {x, 0, 200}, {y, 0, 200}]