# How to apply mathematical function on arrays and vectors and multidimensional matric

**URL:** <https://discourse.julialang.org/t/how-to-apply-mathematical-function-on-arrays-and-vectors-and-multidimensional-matric/17346>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [November 9, 2018, 3:24pm UTC](https://discourse.julialang.org/t/how-to-apply-mathematical-function-on-arrays-and-vectors-and-multidimensional-matric/17346 "2018-11-09T15:24:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dhananjay\_Ghangale](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhananjay_ghangale/32/6249_2.png) [@Dhananjay\_Ghangale](https://discourse.julialang.org/u/Dhananjay_Ghangale)\
**Post date:** [November 9, 2018, 3:24pm UTC](https://discourse.julialang.org/t/how-to-apply-mathematical-function-on-arrays-and-vectors-and-multidimensional-matric/17346/1 "2018-11-09T15:24:57Z")

</div>

Hi guys,

I am quite new to Julia, I come form matlab background. I wanted to know how can you apply any mathematical fuunction like sine, cos or besselh to a matrix or array.

for example in matlab say you have x = rand(3,4,5) and you do y=sin(x) what you get is y a 3d matrix having dimension of (3,4,5). How can you accomplish this julia ?

---

<div class="post-metadata">

**Author:** ![StefanKarpinski](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stefankarpinski/32/24_2.png) [@StefanKarpinski](https://discourse.julialang.org/u/StefanKarpinski)\
**Post date:** [November 9, 2018, 3:28pm UTC](https://discourse.julialang.org/t/how-to-apply-mathematical-function-on-arrays-and-vectors-and-multidimensional-matric/17346/2 "2018-11-09T15:28:54Z")

</div>

```julia
y = sin.(x)

```

For more details see “broadcast and vectorization” in:

[https://docs.julialang.org/en/v1/base/arrays/index.html](https://docs.julialang.org/en/v1/base/arrays/index.html)

and

[https://docs.julialang.org/en/v1/manual/functions/index.html](https://docs.julialang.org/en/v1/manual/functions/index.html)

---

<div class="post-metadata">

**Author:** ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)\
**Post date:** [November 9, 2018, 3:31pm UTC](https://discourse.julialang.org/t/how-to-apply-mathematical-function-on-arrays-and-vectors-and-multidimensional-matric/17346/3 "2018-11-09T15:31:18Z")

</div>

I guess you want to read [Functions · The Julia Language](https://docs.julialang.org/en/v1/manual/functions/#man-vectorized-1) in particular.

---

<div class="post-metadata">

**Author:** ![Dhananjay\_Ghangale](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dhananjay_ghangale/32/6249_2.png) [@Dhananjay\_Ghangale](https://discourse.julialang.org/u/Dhananjay_Ghangale)\
**Post date:** [November 9, 2018, 3:39pm UTC](https://discourse.julialang.org/t/how-to-apply-mathematical-function-on-arrays-and-vectors-and-multidimensional-matric/17346/4 "2018-11-09T15:39:07Z")

</div>

Thanks so much this helps a lot 🙂
