# How we can write quadratic equation (Mathematical functions) In Julia

**URL:** <https://discourse.julialang.org/t/how-we-can-write-quadratic-equation-mathematical-functions-in-julia/37409>\
**Category:** General Usage\
**Tags:** question, math\
**Created:** [April 11, 2020, 6:15pm UTC](https://discourse.julialang.org/t/how-we-can-write-quadratic-equation-mathematical-functions-in-julia/37409 "2020-04-11T18:15:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Neeraj\_Verma\_ASETRAI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neeraj_verma_asetrai/32/13743_2.png) [@Neeraj\_Verma\_ASETRAI](https://discourse.julialang.org/u/Neeraj_Verma_ASETRAI)\
**Post date:** [April 11, 2020, 6:15pm UTC](https://discourse.julialang.org/t/how-we-can-write-quadratic-equation-mathematical-functions-in-julia/37409/1 "2020-04-11T18:15:04Z")

</div>

Suppose i wanted to write a fun y = x^2+1

and wanted to plot in scatter. So how can i plot this in Julia?

i tried this method but didn’t work

y(x) = x^2+1  
x = 1:10  
scatter(x,y(x))

---

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [April 11, 2020, 6:17pm UTC](https://discourse.julialang.org/t/how-we-can-write-quadratic-equation-mathematical-functions-in-julia/37409/2 "2020-04-11T18:17:06Z")

</div>

Try `scatter(x,y.(x))` dots after function names (`.`) make functions broadcast (be applied element-wise)

---

<div class="post-metadata">

**Author:** ![Karajan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/karajan/32/8545_2.png) [@Karajan](https://discourse.julialang.org/u/Karajan)\
**Post date:** [April 14, 2020, 8:14pm UTC](https://discourse.julialang.org/t/how-we-can-write-quadratic-equation-mathematical-functions-in-julia/37409/3 "2020-04-14T20:14:27Z")

</div>

In this case (using `Plots`)

```julia
f(x) = x^2 + 1
scatter(f, x)

```

should also work.

---

<div class="post-metadata">

**Author:** ![Syx\_Pek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/syx_pek/32/6364_2.png) [@Syx\_Pek](https://discourse.julialang.org/u/Syx_Pek)\
**Post date:** [April 14, 2020, 10:17pm UTC](https://discourse.julialang.org/t/how-we-can-write-quadratic-equation-mathematical-functions-in-julia/37409/4 "2020-04-14T22:17:06Z")

</div>

I understand you wanted to do a scatter plot, but if you just want to plot a function using Plots, `plot(x->x^2 + 1)` works as well. I’ve been told that this will work in Makie soon.
