# Error on atan() call

**URL:** <https://discourse.processing.org/t/error-on-atan-call/47373>\
**Category:** Beginners\
**Created:** [October 15, 2025, 9:43pm UTC](https://discourse.processing.org/t/error-on-atan-call/47373 "2025-10-15T21:43:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xero](https://avatars.discourse-cdn.com/v4/letter/x/aca169/32.png) [@Xero](https://discourse.processing.org/u/Xero)\
**Post date:** [October 15, 2025, 9:43pm UTC](https://discourse.processing.org/t/error-on-atan-call/47373/1 "2025-10-15T21:43:43Z")

</div>

Having an issue, is this a bug? or am I doing something wrong?

```javascript
function setup() {
  createCanvas(400, 400);
  background(128);
}

function draw() {
  let a = cos(0.5);
  text(a.toString(), 200,200);
  a = atan(0.5);
  text(a.toString(), 200,250);
}

```

I get an error on the atan call:

🌸 p5.js says: It looks like you’ve called atan outside of a shader’s modify() function.

Thanks

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [October 15, 2025, 9:52pm UTC](https://discourse.processing.org/t/error-on-atan-call/47373/2 "2025-10-15T21:52:30Z")

</div>

Hello @Xero ,

I saw the same error with the 2.x versions.

This is a 1.x version:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/c/5c2cb697d280b7c4f5d6a0eacfb8aeea71f0ec27.png)

`:)`

---

<div class="post-metadata">

**Author:** ![quark](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/quark/32/26_2.png) [@quark](https://discourse.processing.org/u/quark)\
**Post date:** [October 16, 2025, 8:33am UTC](https://discourse.processing.org/t/error-on-atan-call/47373/3 "2025-10-16T08:33:57Z")

</div>

> [@Xero](#):
>
> p5.js says: It looks like you’ve called atan outside of a shader’s modify() function

As a work arround you can call the JS Math function e.g.  
`a = Math.atan(0.5);`
