03
Jul
08

### Very Useful Things: The Mathematical Expressions Patch

I’ve just discovered you can use

min(number1,number2)
and
max(number1,number2)

in the Mathematical Expression patch.
min simply sets the output to the smaller of the 2 inputs, while max sets the output to the larger input number. You could quite easily combine the two to get an equivalent of the GLSL clamp() function.

Not very exciting, you might think, but it impresses me…
I’ve never liked the the Math patch, purely based on the amount of screen estate it takes up. The Mathematical Expression patch is much neater, and also somehow makes it easier for me to pretend I know something about maths (which is patently not the case, sadly).

EDIT:
Just to clarify: I’ve been using the Mathemetical Expression patch for ages. I’ve just discovered a couple of new features I didn’t know about before.

#### 7 Responses to “Very Useful Things: The Mathematical Expressions Patch”

1. July 3, 2008 at 3:36 pm

I love the Min/Max feature. Use it a lot. Should probably learn to write it in the expression patch though… not really touched that one!

2. July 3, 2008 at 3:57 pm

oh fuck. you mean you’ve been struggling without it for this long? i feel remiss in my duties. its even got the ternary operator in there ffs! not to mention the readability it gives to your patches, with named inputs etc.

3. 3 toneburst
July 3, 2008 at 8:20 pm

Hi toby,

I’ve been using the Mathemetical Expression patch for a while, just never had reason to try min and max before. I’m sure I’ll be using them in the future though.

You’re sacked, by the way 😉

a|x

4. 4 Carter
July 6, 2008 at 4:29 am

The parser also supports the following functions: sin(), cos(), tan(), asin(), acos(), atan(), atan2(), sinh(), cosh(), tanh(), exp(), ln(), log(), abs(), sqrt(), ceil(), floor(), min(), max() and rand(). Some predefined constants are provided: pi and e.

5. 5 toneburst
July 6, 2008 at 8:30 pm

Hi Carter,

thanks for the list. I’ve used PI before, but I didn’t realise rand() was supported. I may use that in future.

Cheers,

a|x

6. 6 Mark
March 23, 2009 at 1:00 am

If anyone gets here looking for a way to raise a value to an exponent (ie a to the power of b), let it be known that there is no direct, built-in way to do that. But you can do exp(ln(a)*b), which does the same thing (it’s just wordier)