# UndefVarError for defined function

**URL:** <https://discourse.julialang.org/t/undefvarerror-for-defined-function/34405>\
**Category:** New to Julia\
**Created:** [February 10, 2020, 10:38am UTC](https://discourse.julialang.org/t/undefvarerror-for-defined-function/34405 "2020-02-10T10:38:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samantp](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@samantp](https://discourse.julialang.org/u/samantp)\
**Post date:** [February 10, 2020, 10:38am UTC](https://discourse.julialang.org/t/undefvarerror-for-defined-function/34405/1 "2020-02-10T10:38:49Z")

</div>

I think I may have some syntax error here but I can’t figure out what it is. I am trying to write and use a function called probit. In the long term I would like to save this function into a file but for now I’m just trying to call it in the same script

```julia
using SpecialFunctions: erf
        function probit(x)
                return 0.5*(1+erf(x/sqrt(2)))
        end

probit(1)

```

I get an error “UndefVarError: probit not defined”

but I have just defined it in the line above. Is there some problem with my syntax?  
Thanks

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [February 10, 2020, 10:41am UTC](https://discourse.julialang.org/t/undefvarerror-for-defined-function/34405/2 "2020-02-10T10:41:28Z")

</div>

There is nothing wrong with the code, and it does work for me:

```julia
julia> using SpecialFunctions: erf

julia> function probit(x)
           return 0.5*(1+erf(x/sqrt(2)))
       end
probit (generic function with 1 method)

julia> probit(1)
0.8413447460685429

```

did you properly evaluate/define the function before you ran it?

---

<div class="post-metadata">

**Author:** ![samantp](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@samantp](https://discourse.julialang.org/u/samantp)\
**Post date:** [February 10, 2020, 10:46am UTC](https://discourse.julialang.org/t/undefvarerror-for-defined-function/34405/3 "2020-02-10T10:46:33Z")

</div>

oh, not I did not. What I am trying to do however is to evaluate this all in one go. So basically I have a single file, Probit.jl, which I am running all at once in atom. Actually I think the issue may have been that I just wasn’t running the script in the right order. Thanks!
