Operations in CL

On slide 19 of my activity input13 table, I need to be able to check students points based on their points. They are doing rotations about the origin 90 degrees and I had them create their own shape on slide 18. Using those points, I want to check if their new coordinates after using (x,y)-> (-y,x) are correct. However, I’m not sure if I am able to multiply a Numeric Value by -1 or how to do it exactly. Any help would be appreciated.

opp=-1
correct1 = numericValue(pt5.x) = y1*opp and numericValue(pt1.y) = x1

Yeah, this took me a while to really wrap my head around when I first started CL, because there are really no native calculations you can do like in a typical programming language. Everything has to be done through evaluations of latex strings.

So, the simple way to multiply by -1 would be something like:

a = 5
b = numericValue("-1(${a})")

To get properly formatted latex, the easiest way is to type exactly what you want in a desmos graph, copy it, and then paste it into CL. It will paste as proper latex. Eventually, you will get used to the most common latex syntaxes and will be able to just type them in more quickly.

Using numericValue like this does have some downsides, and will have trouble with things like scientific notation, because it will see the ‘e’ and turn it into 2.71… There are some other issues as well. So it’s fine for simple operations with expected inputs. But it’s pretty handy to use the simpleFunction approach, where you take the function that you want and create a function object which you can then reuse with different parameters. This avoids a lot of the numericValue issues because of the way it’s handled behind the scenes. So for multiplying by -1, you could do:

a = 5
fProduct = simpleFunction("x(y)", "x", "y")
b = fProduct.evaluateAt(a, -1)
c = fProduct.evaluateAt(a, 3)

In this approach, you still use a latex string to define the function, and you can use as many parameters as you need - in this case, I just used x and y, but you can use other letters as well. Then you can call the function as many times as you need using whatever parameter values you want.

I hope this makes sense. Here are some examples of both usages.

Yes, this makes perfect sense thanks to your awesome explanation! Thank you for giving me both options, in case I need the more complex version for future assignments!

1 Like