[LON-CAPA-users] math rendering engine

Stefan Bisitz lon-capa-users@mail.lon-capa.org
Tue, 19 Jan 2010 10:32:33 +0100


Hi Justin,

It's quite simple to solve your display issues. You parse the formula twice:
1) $displayfunction1 = &xmlparse('<m>$(x^2 - 1)^2$</m>');
[...]

2) <m eval="on">$(f \circ g)(x) = $displayfunction $</m>

Just change to
<m>$ (f \circ g)(x) = $</m> $displayfunction

$displayfunction is already parsed and must not be included again in the 
<m> tag.

tth as well as mimetex works now (tested on bleeding edge machine).

And yes, please avoid to use jsmath hardcoded in the problem. Let the 
CCs or students decide.

Stefan Bisitz



On 19.01.2010 09:59, Justin Gray wrote:
> When displaying equations, setting the display attribute within the <m> 
> tag to "jsMath" is generally discouraged as it requires users to have
> installed jsmath software on their computer and will override their 
> preferences on how math equations are displayed.
> 
> I have tried viewing the problem below on several computers and jsMath 
> seems to be the only math rendering engine that lets me view the 
> equations properly. (With tth the equations do not show up at all and 
> with mimetex the equations are incomprehensible.) I am reluctant to 
> force users to jsMath for this problem. Perhaps there is another way to 
> remedy this problem?
> 
> Any suggestions are appreciated.
> 
> Thanks,
> Justin
> 
> Justin Gray | Senior Lecturer
> Department of Mathematics | Simon Fraser University
> 8888 University Drive, Burnaby | V5A 1S6 | Canada
> Tel: +1 778.782.4237
> 
> <problem>
> <script type="loncapa/perl">
> $function1 = "(x^2 - 1)^2";
> $function2 = "sqrt(x^2 - 1)";
> $function3 = "3/(2 + x^2)";
> $function4 = "2/(3 + sqrt(1 + x))";
> $displayfunction1 = &xmlparse('<m>$(x^2 - 1)^2$</m>');
> $displayfunction2 = &xmlparse('<m>$\sqrt{x^2 - 1}$</m>');
> $displayfunction3 = &xmlparse('<m>$\displaystyle \frac{3}{2 + x^2}$</m>');
> $displayfunction4 = &xmlparse('<m>$\displaystyle \frac{2}{3 + \sqrt{1 + 
> x}}$</m>');
> $example1=&xmlparse('Many answers are possible. One example would be 
> <m>$f(x) = x^2, \quad g(x) = x^2 - 1$</m>');
> $example2=&xmlparse('Many answers are possible. One example would be 
> <m>$f(x) = \sqrt{x}, \quad g(x) = x^2 - 1$</m>');
> $example3=&xmlparse('Many answers are possible. One example would be 
> <m>$f(x) = 3/x, \quad g(x) = 2 + x^2$</m>');
> $example4=&xmlparse('Many answers are possible. One example would be 
> <m>$f(x) = 2/(3 + x), \quad g(x) = \sqrt{1 + x}$</m>');
> $n = &random(1,4,1);
> $function = &choose($n,"$function1","$function2","$function3","$function4");
> $displayfunction = 
> &choose($n,"$displayfunction1","$displayfunction2","$displayfunction3","$displayfunction4");
> $example = &choose($n,"$example1","$example2","$example3","$example4");
> </script>
> 
> <startouttext /><p>Give an example of two nontrivial functions 
> <m>$f$</m> and <m>$g$</m> such that <m eval="on">$(f \circ g)(x) = 
> $displayfunction $</m>.</p>Enter your answer in the form 
> <p><b>expression1,expression2</b></p> where <m>$f(x) = $</m> 
> <b>expression1</b> and <m>$g(x) = $</m> 
> <b>expression2</b>.<p></p><endouttext />
> 
> <mathresponse answerdisplay="$example" cas="maxima" args="$function" 
> id="11">
>     <answer>f(x) := RESPONSE[1];
> g(x) := RESPONSE[2];
> h(x) := LONCAPALIST[1];
> composition:is(trigsimp(f(g(x)) - h(x)) = 0);
> fnottrivial:is(not(f(x) = x));
> gnottrivial:is(not(g(x) = x));
> composition and fnottrivial and gnottrivial;</answer>
>     <textline readonly="no" size="20" />
>     <hintgroup showoncorrect="no">
>         <mathhint name="composition not equal" cas="maxima" 
> args="$function" id="12">
>             <answer>f(x) := RESPONSE[1];
> g(x) := RESPONSE[2];
> h(x) := LONCAPALIST[1];
> is(not(f(g(x)) = h(x)));</answer>
>         </mathhint>
> <hintpart on="composition not equal">
>     <startouttext /><p>Your example does not satisfy <m eval="on">$(f 
> \circ g)(x) = f(g(x)) = $displayfunction $</m>.</p><endouttext />
> </hintpart>
>     </hintgroup>
>     <hintgroup showoncorrect="no">
>         <mathhint name="f trivial" cas="maxima" id="13">
>             <answer>f(x) := RESPONSE[1];
> is(f(x) = x);</answer>
>         </mathhint>
> <hintpart on="f trivial">
>     <startouttext /><p>The question asks for nontrivial functions, and 
> so you cannot use <m>$f(x) = x$</m>.</p><endouttext />
> </hintpart>
>     </hintgroup>
>     <hintgroup showoncorrect="no">
>         <mathhint name="g trivial" cas="maxima" id="14">
>             <answer>g(x) := RESPONSE[2];
> is(g(x) = x);</answer>
>         </mathhint>
> <hintpart on="g trivial">
>     <startouttext /><p>The question asks for nontrivial functions, and 
> so you cannot use <m>$g(x) = x$</m>.</p><endouttext />
> </hintpart>
>     </hintgroup>
> </mathresponse>
> </problem>
> 
> 
>