# Functions with two variables

**URL:** <https://discourse.julialang.org/t/functions-with-two-variables/86878>\
**Category:** New to Julia\
**Tags:** plotting\
**Created:** [September 7, 2022, 10:56am UTC](https://discourse.julialang.org/t/functions-with-two-variables/86878 "2022-09-07T10:56:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eric.O](https://avatars.discourse-cdn.com/v4/letter/e/9dc877/32.png) [@Eric.O](https://discourse.julialang.org/u/Eric.O)\
**Post date:** [September 7, 2022, 10:56am UTC](https://discourse.julialang.org/t/functions-with-two-variables/86878/1 "2022-09-07T10:56:47Z")

</div>

Is there any way I can easily plot this function with two variables in Julia? I need some guidance, please.

 ![work1](https://global.discourse-cdn.com/julialang/original/3X/4/6/46c478a8a5a24c6f636ee48968b6a3165349b3b8.jpeg)

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 7, 2022, 11:11am UTC](https://discourse.julialang.org/t/functions-with-two-variables/86878/2 "2022-09-07T11:11:13Z")

</div>

Are you looking for a 3D plot? Here’s how to do it in Plots.jl:

[https://docs.juliaplots.org/stable/gallery/gr/generated/gr-ref24/#gr\_demo\_24](https://docs.juliaplots.org/stable/gallery/gr/generated/gr-ref24/#gr_demo_24)

Basically just define some ranges `x` and `y` for which you want to evaluate your function, and then do `f.(x, y)` to get the function outputs then you can `plot(x, y, f.(x, y)`

---

<div class="post-metadata">

**Author:** ![Eric.O](https://avatars.discourse-cdn.com/v4/letter/e/9dc877/32.png) [@Eric.O](https://discourse.julialang.org/u/Eric.O)\
**Post date:** [September 7, 2022, 2:49pm UTC](https://discourse.julialang.org/t/functions-with-two-variables/86878/3 "2022-09-07T14:49:46Z")

</div>

How do I write the code so that the Right hand sides will multiply each other?. Thus the term in the square root will multiply the term by it. Could you please give me a sample? I will appreciate it if you could please help me code this also using any range of values of x and y. Thank you.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [September 7, 2022, 3:27pm UTC](https://discourse.julialang.org/t/functions-with-two-variables/86878/4 "2022-09-07T15:27:26Z")

</div>

Sorry I don’t understand the question. What do you mean by “Right hand sides will multiply each other”?

I actually was going to include an example of plotting your function initially but then realised I didn’t actually understand what your notation means. If the \binom{x}{y} at the end is supposed to indicate a binomial coefficient, your function might be

```julia
∂f(x, y) = √( x^2 + y^2 ) * binomial(x, y)

```

here I’ve omitted the minus signs in front of `x` and `y`, given the numbers are squared anyway).

I suppose that your notation doesn’t actually reference binomial coefficients though given they are only defined for positive integers and you are subtracting decimal numbers in your second equation, which tells me I don’t know what your notation means.

Ranges in Julia can be created with the colon operator. `1:10` will create a range of integers from 1 to 10, while `1:0.1:5` will create the set of numbers 1, 1.1, 1.2, …, 4.9, 5.

---

<div class="post-metadata">

**Author:** ![Clark](https://avatars.discourse-cdn.com/v4/letter/c/6de8d8/32.png) [@Clark](https://discourse.julialang.org/u/Clark)\
**Post date:** [September 7, 2022, 4:41pm UTC](https://discourse.julialang.org/t/functions-with-two-variables/86878/5 "2022-09-07T16:41:50Z")

</div>

This is a function multiplying a vector, correct? Not a binomial.  
\partial f(x,y) = (x^2 + y^2) \* [x;y] should give you the function you’re looking for.  
the  
plot(x,y,f.(x,y) as mentioned above and in the link
