Why use Pure Math?
Coding a math expression in Scratch is very difficult. We want to make it easier with:
- expressions that are more like math expressions
- expressions that support variables in Scratch
Functions and Definitions
Pure Math is pure and minimal. All you need is an expression.
If you want to reference a variable in Scratch, simply use ${name} with the variable name inside. For example:
Example Expressions
| Given expr | Output | 
| 1+1 | 2 | 
| sqrt(2) | 1.4142135 | 
| 2^3 | 8 | 
| 5! | 120 | 
If you want to use a variable in Scratch, for example, a variable named x, where x = 5:
| Given expr | Output | Description | 
| ${x}^2 | 25 | 5^2 | 
| 2^${x} | 32 | 2^5 | 
| min(${x}, 3) | 3 | return x, if x is greater than 3, return 3 | 
| max(${x}, 10) | 10 | return x, if x is less than 10, return 10 | 
| max(min(${x}, 100), -100) | 5 | return a value of x in the range [-100, 100] | 
Pure math is a wrapper extension of Math.js, a powerful math library JavaScript. If you want to learn more useful expressions, here are more examples from Math.js:
math.js
Math.js is an extensive math library for JavaScript and Node.js. It features big numbers, complex numbers, matrices, units, and a flexible expression parser.
mathjs.org
Roadmap and Change Logs
| Version | What’s New | 
| 0.1 | Added:
- expr
- simplify  | 
Credits
Math.js
If you have any questions or suggestions, you can find us in the discord channel: https://discord.gg/U3nyveCvRa
