# Problem Lambdifying atan function

**URL:** https://discourse.julialang.org/t/problem-lambdifying-atan-function/41501
**Category:** General Usage
**Tags:** question
**Created:** [June 16, 2020, 8:24am UTC](https://discourse.julialang.org/t/problem-lambdifying-atan-function/41501 "2020-06-16T08:24:44Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Jake\_Double\_U](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake_double_u/32/10653_2.png) [@Jake\_Double\_U](https://discourse.julialang.org/u/Jake_Double_U)
#### Post date: [June 16, 2020, 8:24am UTC](https://discourse.julialang.org/t/problem-lambdifying-atan-function/41501/1 "2020-06-16T08:24:44Z")

</div>

Hi Folks,

Apology if this is not the appropriate location for this post. Also, I am not much of a computer programmer so I also apologize for any incorrect terminology in the following.

I have run across a problem that Julia’s “lambdify()” command will not convert Python’s symbolic function “atan2(x,y)” back into the Julia function “atan(x,y)”. As an example, consider the following lines of Julia code that I have written:

using SymPy

x = symbols(“x”)

f\_x = atan(sin(x),cos(x))

# Lambdify the symbolic expression f\_x and evaluate at value x = 3/2\*pi:

nf\_x = lambdify(f\_x,[x,x])(3/2_pi,3/2_pi)

What happens when I run this example (in either Julia-1.1 or Julia-1.4) is that Julia throws up a message “ERROR: LoadError: UndefVarError: atan2 not defined”. I can see that in the SymPy.jl package, there is a line in the mathfuns.jl script that finds the Julia function “atan” as missing and adds the line

Base.atan(y::Sym, x) = sympy.atan2(y,x)

in order to be able to convert the Julia function into a SymPy compatible code. I am guessing that there is something missing in the “lambdify.jl” script that prevents the conversion of the Python “atan2(x,y)” into a Julia function.

If anyone has a fix to this problem, it would be GREATLY appreciated. Thanks.

NOTE: the “3/2pi” should have a multiplication symbol in between the 2 and pi but it is not showing up properly here.

---

<div class="post-metadata">

### Author: ![fgerick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fgerick/32/13228_2.png) [@fgerick](https://discourse.julialang.org/u/fgerick)
#### Post date: [June 16, 2020, 9:04am UTC](https://discourse.julialang.org/t/problem-lambdifying-atan-function/41501/2 "2020-06-16T09:04:41Z")

</div>

`atan2` does not seem to be in the `fn_maps` dictionary of SymPy.jl. You can use:

```julia
jf_x = lambdify(f_x, fns = Dict("atan2"=>:atan))
nf_x = jf_x(3/2pi)

```

---

<div class="post-metadata">

### Author: ![fgerick](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fgerick/32/13228_2.png) [@fgerick](https://discourse.julialang.org/u/fgerick)
#### Post date: [June 16, 2020, 9:08am UTC](https://discourse.julialang.org/t/problem-lambdifying-atan-function/41501/3 "2020-06-16T09:08:16Z")

</div>

Also, see [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) on how to highlight code (as you had issues displaying it correctly).

---

<div class="post-metadata">

### Author: ![Jake\_Double\_U](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jake_double_u/32/10653_2.png) [@Jake\_Double\_U](https://discourse.julialang.org/u/Jake_Double_U)
#### Post date: [June 16, 2020, 12:20pm UTC](https://discourse.julialang.org/t/problem-lambdifying-atan-function/41501/4 "2020-06-16T12:20:46Z")

</div>

Thanks fgerick! I was able to get this to work in my much larger expressions with a minor tweak. I am uber-grateful for you very prompt response.
