# Adding a math type fraction to a note when using CL

I am stuck on what is probably a simple solution. I would like for my Note to include a fraction when a certain option is selected from a Choice. I cannot seem to get a fraction to show up.

For example, within part of my code I have

when a=1 "Here is an example of a polynomial function:

f(x)=(1/8)x^3-2x " Note, I don’t have two ’ at the end, but the post was converting it

Is it possible to make the 1/8 show up in math type/latex? I’ve tried using \frac{1}{8} with no luck.

Thanks!

Simple fix: you need two backslashes in desmos rather than the usual one.

1 Like

Yep! That did it! Thank you!!

I am having a similar problem but mine is coming from pulling the fraction out of a student response. The response we are looking for is 1/2x+3 but when I pull the input (input5.latex) and drop it into the content sink its displaying as \frac{1}{2}x+3. What am I missing here?

That sounds like you are on the right track. I think this is what you are looking for.

I am having a similar issue where I am pulling from a graph expression. Even when typed as a fraction in the graph expression, e.g. P=4/3, the note displays its decimal equivalent.

content: “Drag the green point to identify the number ${Graph1.number(“P”)}. Then, click the button see how close you are!” Thank you for any help! I think the note will always display as a decimal the way you described, but there could be a workaround. Maybe someone else has a better way, but here’s my thoughts. One thing to try would be to have two separate equations in the graph component, such as N=4 and D=3? Then in the note, try: content: "Drag the green point to identify the number \frac${graph1.number(“N”)}\${graph1.number(“D”)}. Then, click the button see how close you are!"

I can’t get that to format properly, so here’s the example:

Hmmm. I do like that work around; thank you! I am making an activity for grade 6, where I would like for the teacher to be able to input the number in the graph portion with minimal knowledge of the CL, definitely without going into the CL. So, I could use this for any screens that use fractions, and my version for decimals and integers. Not as clean on the back end as I would hope, but front end works rather well! Thank you!

I just noticed something weird. If either the numerator or denominator is negative, the Note does not display well; it only seems to take the first character of the value of either N or D and moves the rest after the fraction bar. I changed the inputs to become random, and might include a third random variables that takes a value of either 1 or -1 and use the product to see if that works!

This is a pretty brittle example so use with extreme care: fractions? • Activity Builder by Desmos

Some things you should know:

1. It simplifies the input (which might not be a problem if you’re using a value from the graph)
2. it’ll work on fractions that can simplify to a denominator of 100 or less (and might have some cases where it doesn’t even do that).
1 Like

So… I’m getting there, and at this point I think it is time to share my activity. No issues on screens one and 2 where students are asked to plot an integer or a decimal.

On Screen 3, I have it pretty good, but only if the fraction has an initial numerator and denominator of an integer between 1 and 9 (no multi-digit, no negative). Both of those mess things up a bit when the note displays the fractions. This has turned out to be one of the more demanding (fun) activities I’ve created and any further help would be appreciated!

Ordering and Comparing Rational Numbers • Activity Builder by Desmos

your activity was deleted. Any chance of sharing again?

Sure! There are a couple of versions

Here is an example of what is completely usable: Ordering and Comparing Integers and Decimals • Activity Builder by Desmos

Here is an example of placing a fraction on the number line: Ordering and Comparing Rational Numbers • Activity Builder by Desmos. For this, @Jay helped me simply separate out the negative signs and compute (and display) them separately. I have since moved on from this project, but I believe it is completely usable

Can you help me recognize that C must equal 1/6 to be correct please? Here’s what I tried. Neither one worked. This is in the CL and works fine without fractions.

correct: A=-1 and B=-1 and C=1/6 and D=6
correct: A=-1 and B=-1 and C=1\/6 and D=6

Similarly, I seem to be able to use negatives OR decimals, but not negative one half. A gives me an error here. Thank you in advance!

correct: A=-.5 and B=-2 and C=.5 and D=-6

C has to be a number, and numbers need a ones place, so try something like

correct: A=-0.5 and B=-1 and C=frac.evaluateAt(1) and D=6
frac = simpleFunction("\frac{1}{6}")

Thank you! I did find that -0.5 worked. I’m excited to try your fraction method! In the meantime I was doing C<0.16 and C<=0.17 so I’m glad to have something more precise. Thanks!

For fractions that evaluate as non-terminating decimals, it’s best to do as you did specifying a range, or using numericValue and rounding each value to a specified number of decimal places (i.e. C and 1/6), or the absolute value of the difference <= 0.01 (or some other tolerance).

Do you have a specific example of when the math input component would approximate a fraction differently than the simpleFunction fraction in the CL? I tried several fractions, but all of them worked-- even very large primes for both numerator and denominator.

I think @Jay has mentioned before that for things like this, simpleFunction should work well. If using numericValue, then there can be some rounding issues and a tolerance should be used.