Modulus Math in Computational Layer

I was trying to figure out how to do a mod in CL.
In the calculator/graph, I think you can use mod(x,5)
Most languages I know use the % sign: example x % 5
Both of these so if a variable reaches the argument is “recycles to 0”.

Maybe there’s a documentation page somewhere related to this but couldn’t find it.


The most reliable way (and the most efficient if you plan to call on it multiple times) is to use simpleFunction and evaluateAt. You can paste in an expression from the calculator of you’re not sure how to format the latex.

There’s a shorter way using numericValue, but interpolating the numeric values as a string can lead to some errors depending on the Possible input values

If you know the syntax in a graph, you can copy/paste from the graph to the CL to see how it should be formatted in CL.

Here’s roughly what I did.

#Changes label on point A to the modulus of a divided by b
mod = simpleFunction("\mod(a,b)",“a”,“b”)

1 Like

That works. Personally, I’d flip flop a little:

pointlabel("A"): "${simpleFunction("\mod(a,b)")}"

More lines, but looks less complicated to me. *shrug
Also, “.content”? Normally I’d use “.latex” or just numericValue(exp1), but guess it doesn’t matter.