# Plot the following custom function?

**URL:** <https://community.wolfram.com/t/plot-the-following-custom-function/15375>\
**Category:** Questions\
**Tags:** calculus, graphics-and-visualization\
**Created:** [February 14, 2020, 1:45am UTC](https://community.wolfram.com/t/plot-the-following-custom-function/15375 "2020-02-14T01:45:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmc1088](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@kmc1088](https://community.wolfram.com/u/kmc1088)\
**Post date:** [February 14, 2020, 1:45am UTC](https://community.wolfram.com/t/plot-the-following-custom-function/15375/1 "2020-02-14T01:45:06Z")

</div>

I am trying to plot this function with Plot3D and ContourPlot and they both give blank boxes. Is there something wrong with my code?

```
f[x_, y_] = 4*Sin[x - 2] + 4*Cos[y - 4] + 9*x^2 - 5*xy + 1*y^2 - 2*x + 4*y

```

---

<div class="post-metadata">

**Author:** ![dontdont9](https://avatars.discourse-cdn.com/v4/letter/d/54ee81/32.png) [@dontdont9](https://community.wolfram.com/u/dontdont9)\
**Post date:** [February 14, 2020, 2:40am UTC](https://community.wolfram.com/t/plot-the-following-custom-function/15375/2 "2020-02-14T02:40:30Z")

</div>

Try

```
f[x_, y_] := 4Sin[x - 2] + 4Cos[y - 4] + 9x^2 - 5x*y + 1y^2 - 2x + 4*y ;
Plot3D[f[x,y],{x,-Pi,Pi},{y,-Pi,Pi}]

```

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [February 14, 2020, 2:41am UTC](https://community.wolfram.com/t/plot-the-following-custom-function/15375/3 "2020-02-14T02:41:19Z")

</div>

Hi Katelyn,

You did not post the code you tried so it is not possible to identify what is wrong with it.

```
f[x_, y_] := 4 Sin[x - 2] + 4 Cos[y - 4] + 9 x^2 - 5 x y + 1 y^2 - 2 x + 4*y
Plot3D[Evaluate@f[x, y], {x, -2 Pi, 2 Pi}, {y, -2 Pi, 2 Pi}]

```

 ![8257plot.png](https://global.discourse-cdn.com/wolfram/original/3X/4/3/433ca98ed25716fe36ac5e7afabca2d2412a67c9.png)

---

<div class="post-metadata">

**Author:** ![wjhnjust](https://avatars.discourse-cdn.com/v4/letter/w/45deac/32.png) [@wjhnjust](https://community.wolfram.com/u/wjhnjust)\
**Post date:** [March 12, 2020, 10:18am UTC](https://community.wolfram.com/t/plot-the-following-custom-function/15375/4 "2020-03-12T10:18:47Z")

</div>

I suggest you use the delayed evaluation “:=”. For example,If we set x=1;the define a function x+2 with direct assignment and delayed assignment,respectively.The following answer we will get.

 ![360截图16800418293752.png](https://global.discourse-cdn.com/wolfram/original/3X/5/0/5012cab16ae07660ea2b32bda32dba44773490f8.png)

---

<div class="post-metadata">

**Author:** ![murray](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/murray/32/39879_2.png) [@murray](https://community.wolfram.com/u/murray)\
**Post date:** [March 15, 2020, 3:14pm UTC](https://community.wolfram.com/t/plot-the-following-custom-function/15375/5 "2020-03-15T15:14:41Z")

</div>

Note that including `Evaluate` in the `Plot` expression cuts the time roughly in half (on my system, from around 0.293 sec to around 0.017 sec).

This should hardly matter — except, say, if you were going to be changing the function or the plot range dynamically within a `Manipulate`.
