I’ve asked something similar before, but now I’m wanting to take things a step further and I’m stuck. I would like to graph C=45h+85 {0<=h<=5} and check it.
How do I get the {0<=h<=5} into my code in the math input box?
Thanks for this. But I’m not sure how I actually enter that into the input. I can copy and paste, which I’ve just tried to do, and tried a few combinations, but I keep getting a cross in the box. I’m just not quite sure how it all works together yet.
or do you mean how do you put it into the CL code so that it checks it correctly?
EDIT: Ignore that, sorry - I’ve just tested it with Daniel’s suggestions and yes, it does still give the cross. It seems to fail the pattern matching as soon as you include a domain restriction…
f= simpleFunction(parseEquation(this.latex).rhs,"h")
undef= isUndefined(f.evaluateAt(-0.1)) and isUndefined(f.evaluateAt(5.1))
Add these two lines to your input CL, then add “and undef” to your check variable. It’ll check your pattern like you already had plus the undefined out of the domain.
I think on this occasion you’ll need to evaluate the function for correctness rather than using pattern matching - so this works, for example:
f= simpleFunction(parseEquation(this.latex).rhs,"h")
correct: check
check=f.evaluateAt(1)=130 and f.evaluateAt(2)=175
undef= isUndefined(f.evaluateAt(-0.1)) and isUndefined(f.evaluateAt(5.1))
suffix: when not(this.submitted) ""
when check and undef "✅"
otherwise "❌"
It does not stop students entering wacky variations that evaluate to the same - eg. C=(90/2)h+85 {…} or C=30h+15h+40+45 {…} - but at least works with the domain restriction, where pattern matching seems to trip up…
Thank you both for your suggestions. Very much appreciated. It works now.
Originally I thought I had to do the pattern matching thing in order to enter an equation with variables other than x and y. So is that not the case, so long as I have the function defined in terms of, say, h, as I have in the graph?
The “h” at the end defines what the function is in terms of, so when you evaluateAt that is the variable being evaluated. You can even do multiple say for a volume formula by simply adding more parameters.