signum function

Tim Crist's icon
sgn_function.maxpat
Max Patch

Can someone provide some advice on implementing the following signum function?

G(x)= -Bx + Csgn(x)

I tried it here in gen~ which I am not very confident in using. I wonder if I screwed up the math here, which I am prone to do, and am misrepresenting the formula.

Based on Sprott's formula provided here:

https://sprott.physics.wisc.edu/pubs/paper244.pdf

TFL's icon

The only issue I see is that you are computing the sign of C instead of x.

FWIW, you can also use sign directly:

You could also remove that [+] since multiple cords getting in the same inlet are summed anyway.

And if you're more comfortable with lines of code:


Next time you want to share patchers, instead of uploading a file that we need to download, you can select the relevant objects then in the Max menu bar: Edit > Copy Compressed, and paste here.

Tim Crist's icon

Thanks so much! I didn't know about the summing rule in gen~. Here's a revision.

Max Patch
Copy patch and select New From Clipboard in Max.