# Broadcast macro "breaks" norm

**URL:** https://discourse.julialang.org/t/broadcast-macro-breaks-norm/35570
**Category:** General Usage
**Created:** [March 5, 2020, 11:24am UTC](https://discourse.julialang.org/t/broadcast-macro-breaks-norm/35570 "2020-03-05T11:24:30Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![cshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cshen/32/217287_2.png) [@cshen](https://discourse.julialang.org/u/cshen)
#### Post date: [March 5, 2020, 11:24am UTC](https://discourse.julialang.org/t/broadcast-macro-breaks-norm/35570/1 "2020-03-05T11:24:30Z")

</div>

Hello,

I found this rather interesting behaviour

```julia
julia> using LinearAlgebra
julia> a = [0, 0, 1]
3-element Array{Int64,1}:
 0
 0
 1

julia> @. a/norm(a)
3-element Array{Float64,1}:
 NaN  
 NaN  
   1.0

julia> a./norm(a)
3-element Array{Float64,1}:
 0.0
 0.0
 1.0

```

Only when i tried with `a=[0, 4, 4]` and got out `@. a/norm(a) ` returned `[NaN, 1.0, 1.0]` that i realised that the broadcasting was being passed to `norm` as well.

This is a rather simplistic case but this renders using `@.` over expressions that use the `norm` completely useless, so we can’t take advantage of the performances of fusing broadcasting calls.  
I assumed that norm would only work for vectors and up, since for scalars one could just use `abs`.

The quotes over breaks are because i realise that the norm behaving this way make sense, but still, as i said above one could just use abs to take the norm of a scalar value.

Is there a reason it is this way?

---

<div class="post-metadata">

### Author: ![cstjean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cstjean/32/1444_2.png) [@cstjean](https://discourse.julialang.org/u/cstjean)
#### Post date: [March 5, 2020, 11:51am UTC](https://discourse.julialang.org/t/broadcast-macro-breaks-norm/35570/2 "2020-03-05T11:51:02Z")

</div>

`@.` will add a dot everywhere unless there is a `$` sign before the function. `@. a / $norm(a)` does what you want.
