# Basic functions with array

**URL:** https://discourse.julialang.org/t/basic-functions-with-array/18089
**Category:** General Usage
**Created:** [November 28, 2018, 2:09am UTC](https://discourse.julialang.org/t/basic-functions-with-array/18089 "2018-11-28T02:09:36Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Diger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diger/32/36786_2.png) [@Diger](https://discourse.julialang.org/u/Diger)
#### Post date: [November 28, 2018, 2:09am UTC](https://discourse.julialang.org/t/basic-functions-with-array/18089/1 "2018-11-28T02:09:36Z")

</div>

Last time I was using this was 0.5 or so, but when I want to calculate  
x=1:1000  
y=cos(x)  
it complains about  
ERROR: MethodError: no method matching cos(::StepRangeLen{Float64,Base.TwicePrecision{Float64},Base.TwicePrecision{Float64}})  
Closest candidates are:  
cos(::BigFloat) at mpfr.jl:683  
cos(::Missing) at math.jl:1056  
cos(::Complex{Float16}) at math.jl:1005  
…  
Stacktrace:  
[1] top-level scope at none:0

Is that not inteded anymore to use arrays on basic functions?

---

<div class="post-metadata">

### Author: ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)
#### Post date: [November 28, 2018, 2:27am UTC](https://discourse.julialang.org/t/basic-functions-with-array/18089/2 "2018-11-28T02:27:53Z")

</div>

Use 0.7 to upgrade old code — this will give you deprecation warnings for things that are removed from 1.0. If you are upgrading from Julia 0.5, you first need to upgrade to 0.6 (which is where `cos(array)` was deprecated) to get the deprecations, then upgrade to 0.7, then to 1.0.

Applying functions to arrays is now done with “dot calls” like `cos.(1:1000)`. This is much more general (it works for _any_ function) and [has other benefits as well](https://julialang.org/blog/2017/01/moredots).

---

<div class="post-metadata">

### Author: ![Diger](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/diger/32/36786_2.png) [@Diger](https://discourse.julialang.org/u/Diger)
#### Post date: [November 28, 2018, 2:43am UTC](https://discourse.julialang.org/t/basic-functions-with-array/18089/3 "2018-11-28T02:43:57Z")

</div>

Thanks for your reply. But this new syntax on functions as cos.(x) does not affect the old array dot multiplication like (cos.(x)).\*cot.(x)./sin.(x)./x in any way or?

---

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [November 28, 2018, 3:02am UTC](https://discourse.julialang.org/t/basic-functions-with-array/18089/4 "2018-11-28T03:02:44Z")

</div>

It does, in that now `.*` is no longer something special but just the broadcasted use of `*`. This has benefits for both expressiveness and efficiency and is generally excellent. Please read the article that @stevengj linked, which explains all of this in detail.
