# Playing with Nerdamer symbolic math JS library with Nashorn jjs

I was searching for a self-contained, simple JS library for symbolic math to check homework solutions of my son. On googling "symbolic math javascript", the first hit I got was http://www.nerdamer.com/

I git cloned the source from the git repo:
`\$ cd ~/src\$ git clone https://github.com/jiggzson/nerdamer\$ cd nerdamer`

There is a nice documentation for nerdamer @ http://www.nerdamer.com/documentation

I started Nashorn jjs shell. The following is from my jjs session with nerdamer.

`\$ lsAlgebra.js changelog.md nerdamer.core.js Solve.jsCalculus.js license.txt README.md`

Note: I used rlwrap - http://freecode.com/projects/rlwrap - for better line editing support. Note that rlwrap is not needed for jdk9 builds.
jjs in jdk9 build has integrated better line editing support, tab-completion etc using "jline". "rlwrap" is suggested only for jdk8u builds.

`\$ rlwrap jjs -scriptingjjs> load("nerdamer.core.js")jjs> load("Algebra.js")jjs> load("Calculus.js")jjs> load("Solve.js")jjs> nerdamer('sqrt(x)*sqrt(x)-2').evaluate({x:2})0jjs> nerdamer("diff(tan(x), x)")sec(x)^2jjs> nerdamer.solveEquations("x^2 + 1 = 0", "x")i,-ivar f = nerdamer("x^3 + sin(x)").buildFunction()jjs> ffunction (x) {return (Math.pow(x,3)+Math.sin(x));}jjs> f(Math.PI)31.006276680299816`

I really like this self-contained JS library. No browser specific stuff (window.call_crap_function() --
so that I didn't have to introduce fake helper functions! And no "require('foo.js')" module stuff -- so that I didn't have to fake
a require using nashorn's "load" function. Nerdamer works as advertised and runs smooth on Nashorn!

#### Join the discussion

• guest Sunday, September 27, 2015

Nerdamer is to be used as a node module(server side) as well as on the browser(client side).

• guest Sunday, September 27, 2015

nerdamer is a node module as well as a browser library. It is meant to be used as both.