A friendly and intuitive math library for p5.js
This project aims to bring the mathematical chops of NumPy to the p5.js ecosystem. A few guiding principles are:
- Focus on beginners.
- Complement core p5.js math functions and play nicely with p5.Vector.
- Make the API familiar (e.g.,
createTensor()). - Let ml5.js handle machine learning.
- Encourage all kinds of contributions.
The library is written in TypeScript and uses TensorFlow.js as its linear algebra engine.
Excellent libraries like math.js and p5.dimensions already exist. The idea is to study the masters while creating something new: a production grade library for numeric computation that beginners can grow into over time.
Also, math + code = awesome :)
// A little matrix-vector multiplication
const b = num.tidy(() => {
const a = createTensor([[1, 2], [3, 4]]);
const x = createTensor([5, 6]);
return a.dot(x);
});
print(b.toString());The fluid simulation below was created using a 2-dimensional lattice Boltzmann method.
See CONTRIBUTING.
Thanks goes to these wonderful people (emoji key):
Ashneel Das 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!

