Graph Label with Conditionals

Not necessary for my activity, but curious if it can be done.
I have a random equation generated in the Note CL, that I might have put in the graph as a label, but is there a way to achieve the same results with the conditionals? For example, so it shows y=3x instead of y=3x+0 or so it shows y=2x-5 instead of y=2x+ -5. Random Linear Equation • Activity Builder by Desmos

For this type of display, I’ve created conditionals for m and b. Something like this:

m= wherever your slope is generated
b= wherever your intercept is generated
mText= when m=1 `x`
   when m=-1 `-x`
   otherwise `${m}`
bText= when m>=1 `+${b}`
   when m=<-1 `${b}`
   otherwise ``
exp= `y=${mText}${bText}`
2 Likes

Wait, I have something like that in the Note CL
content: when b=0 “The equation of the line y=${m}x.”
when b<0 “The equation of the line is y=${m}x${b}.”
otherwise “The equation of the line is y=${m}x+${b}.”

It’s the graph labels I am trying to get to emulate that. Can the graph calculator expression list accommodate code like that? I can’t see how to change the labels in the graph from what you wrote.

There’s a point label sink that you can use in the graphing code, not actually in the graph itself. Just define the point with a variable in the graph. Something like A=(0,0) will work. Then pointLabel(“A”): exp from Daniel’s previous code should work.

I have this in my graph CL now.
image

It says “Unexpected type in latex interpolation:string”

Is that why this isn’t working? Or?
image

That error occurs because the mText and bText outputs need to be formatted as latex. Use the backtick symbols instead of the quotation marks. For example,

mText= when m1=1 `x`

You also want to include this line of code:

pointLabel("A"): exp

In the graph, you need this:
image

Works perfectly, thank you both!!

1 Like