# How to add math.js to the p5js editor on browser

**URL:** <https://discourse.processing.org/t/how-to-add-math-js-to-the-p5js-editor-on-browser/35390>\
**Category:** Libraries\
**Created:** [February 23, 2022, 4:21am UTC](https://discourse.processing.org/t/how-to-add-math-js-to-the-p5js-editor-on-browser/35390 "2022-02-23T04:21:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheSynchronomicon](https://avatars.discourse-cdn.com/v4/letter/t/b487fb/32.png) [@TheSynchronomicon](https://discourse.processing.org/u/TheSynchronomicon)\
**Post date:** [February 23, 2022, 4:21am UTC](https://discourse.processing.org/t/how-to-add-math-js-to-the-p5js-editor-on-browser/35390/1 "2022-02-23T04:21:30Z")

</div>

I need to use math.js to solve a system of equations but I honestly have no clue on how to add the math.js library to the browser editor for p5js. I have already tried creating a new sketch file and copying over the html stuff from the math.js website but that didn’t end up correct and I still can’t use any of it because math is still undefined. I desperately need help with this.

---

<div class="post-metadata">

**Author:** ![hsm](https://avatars.discourse-cdn.com/v4/letter/h/ea666f/32.png) [@hsm](https://discourse.processing.org/u/hsm)\
**Post date:** [February 23, 2022, 9:30am UTC](https://discourse.processing.org/t/how-to-add-math-js-to-the-p5js-editor-on-browser/35390/2 "2022-02-23T09:30:56Z")

</div>

Hi,

I’m somewhat new to this but I just tried to do what you described.

So, I added math.js to index.html by doing this in the head:

```auto

` <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjs/10.1.1/math.js" integrity="sha512-0MC8WeRWoyA1u5N3ssCsJDSbNfw3bjF65BIQ3UTPs9nwaV0fy+JN3FH9PQmYACZOEkQFhUvEP+jIqwOlBjEM9w==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>`

```

And then I tested it by doing this in the body:

```auto
  <script type="text/javascript">
    console.log(math.sqrt(-4).toString()) 
       </script>

```

It seemed to work.

---

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [February 23, 2022, 10:49am UTC](https://discourse.processing.org/t/how-to-add-math-js-to-the-p5js-editor-on-browser/35390/3 "2022-02-23T10:49:39Z")

</div>

Hello, @TheSynchronomicon and @hsm, and welcome to the Processing Forum!

Please enjoy the discussions here. It’s great to see that you have both just recently arrived to post for the first time, and have already solved a problem! 🙂

---

<div class="post-metadata">

**Author:** ![mcintyre](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mcintyre/32/14561_2.png) [@mcintyre](https://discourse.processing.org/u/mcintyre)\
**Post date:** [February 23, 2022, 4:23pm UTC](https://discourse.processing.org/t/how-to-add-math-js-to-the-p5js-editor-on-browser/35390/4 "2022-02-23T16:23:08Z")

</div>

Welcome! 👋🏽 Here is a sketch on the p5 Editor that includes math.js and KaTeX for rendering.

> **[p5.js Web Editor](https://editor.p5js.org/mcintyre/sketches/OwQ6MAe81)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.
