Theta and numeric value

If I have an input field initialLatex: "\\theta = ", and then want to use this.numericValue, I can’t make it work: It seems that initialLatex only works if it’s something like x or y? Will it work for any latex character?

BONUS question: I’d love for the input field to mark, say, “7*\pi / 4” and “-\pi / 4” as correct. Recommendations for an easy way to do that? I’ve been using inequalities (like this.numericValue > 5.49 and this.numericValue < 5.50) but if I also accept negative values, I can’t think of a good way.

A workaround for the numericValue:

value=numericValue("${parseEquation(Input4.latex).rhs}")

I’ll look into the BONUS later. :slight_smile:

Here’s both.

#parseEquation splits the latex equation into the left and right side. rhs outputs the latex of the right hand side
value=parseEquation(Input4.latex).rhs

correct = when countNumberUsage(value,4)=1 and countNumberUsage(value,5)=1 and numericValue("\\abs(${value})")=numericValue(“5\\pi/4”) “correct” otherwise “”

Since I’m using numericValue instead of the rounded decimal of 5pi/4, I don’t need to use an inequality. I used absolute value because you mentioned using positive or negative values. The countNumberUsage makes sure 5 and 4 are included once in the latex answer. (It wouldn’t accept pi.)

1 Like

Ah, this is clever. Thanks!

I was told on another thread you should always round because sometimes that doesn’t work. So,

numericValue("\\round(\abs(${value}),4)")=numericValue(“\round(5\pi/4,4)”)

or however many decimal places you want it to.