[LON-CAPA-users] math rendering engine
Justin Gray
lon-capa-users@mail.lon-capa.org
Tue, 19 Jan 2010 15:05:06 -0800
--001517576db65e1fef047d8c8184
Content-Type: text/plain; charset=ISO-8859-1
Thanks, Stefan! This works great and is much cleaner using arrays.
I have left in a separate array @displayfunctions in this problem. Indeed,
this is unnecessary but it allows me to display the equations nicely, and so
I have one array @functions with the functions expressed in Maxima syntax
and another array @displayfunctions with the functions expressed in LaTeX.
The <algebra> tag is versatile but seems to be incompatible with some of the
more cosmetic LaTeX commands that I use to display equations.
Many thanks for identifying my parsing problems.
Best,
Justin
Justin Gray | Senior Lecturer
Department of Mathematics | Simon Fraser University
8888 University Drive, Burnaby | V5A 1S6 | Canada
Tel: +1 778.782.4237
On Tue, Jan 19, 2010 at 2:47 AM, Stefan Bisitz <st.bisitz@ostfalia.de>wrote:
> Hi Justin and other math authors,
>
> Once again another optimization:
> You might want to put your functions into an array and the answer examples,
> too. Then dynamically choose from these lists by using
> $n = &random(1,$#functions,1);
> $function = $functions[$n];
> $example = $examples[$n];
>
> This way, you can easily add (or remove) functions by just adding them to
> the functions array and add an example to the examples array. No other code
> adjustments are needed.
>
> The following problem source code respects all of this and the other
> optimizations discussed before. It's not fully tested, but should work.
>
> Hope this helps,
> Stefan Bisitz
>
> ----------------------------------------------------------------
>
> <problem>
> <script type="loncapa/perl">
> @functions = (
> "(x^2 - 1)^2",
> "sqrt(x^2 - 1)",
> "3/(2 + x^2)",
> "2/(3 + sqrt(1 + x))",
> );
> @examples = (
> &xmlparse('Many answers are possible. One example would be <m>$ f(x) =
> x^2, \quad g(x) = x^2 - 1 $</m>'),
> &xmlparse('Many answers are possible. One example would be <m>$ f(x) =
> \sqrt{x}, \quad g(x) = x^2 - 1 $</m>'),
> &xmlparse('Many answers are possible. One example would be <m>$ f(x) =
> 3/x, \quad g(x) = 2 + x^2 $</m>'),
>
> &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,$#functions,1);
> $function = $functions[$n];
> $example = $examples[$n];
> </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) = $</m>
> <algebra>$function</algebra>.</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)) = $</m> <algebra>$function</algebra>.</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>
> ----------------------------------------------------------------
>
>
>
> On 19.01.2010 11:13, Stefan Bisitz wrote:
>
>> And again... ;-)
>>
>> Much better (the best?):
>>
>> Don't use two variables, one for calculations and one for display. It's
>> simpler, shorter and less error-prone to have only one variable:
>>
>> <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))";
>> $example1=[...]
>> </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) = $</m>
>> <algebra>$displayfunction</algebra>.</p>
>> [...]
>> <endouttext />
>>
>>
>> In general, store or calculate your formula in one variable using the
>> 1-dimensional "pocket calculator" notation. Reuse the same variable to
>> display it by using the <algebra> tag (without any "$") which automatically
>> renders in the preferred method.
>>
>> Stefan Bisitz
>>
>>
>> On 19.01.2010 11:04, Stefan Bisitz wrote:
>>
>>> Hi again,
>>>
>>> Why "pre-parse" anyway?
>>>
>>> Even better:
>>>
>>> 1)
>>> <script type="loncapa/perl">
>>> [...]
>>> $displayfunction1 = '(x^2 - 1)^2';
>>> [...]
>>>
>>> and 2)
>>> [...]
>>> such that <m eval="on">$ (f \circ g)(x) = $displayfunction $</m>.
>>> [...]
>>>
>>>
>>> Stefan Bisitz
>>>
>>>
>>> On 19.01.2010 10:32, Stefan Bisitz wrote:
>>>
>>>> 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>
>>>>>
>>>>>
>>>>>
>>>>>
>>>> _______________________________________________
>>>> LON-CAPA-users mailing list
>>>> LON-CAPA-users@mail.lon-capa.org
>>>> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>>>>
>>>
>>>
>>>
>> _______________________________________________
>> LON-CAPA-users mailing list
>> LON-CAPA-users@mail.lon-capa.org
>> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>>
>
> _______________________________________________
> LON-CAPA-users mailing list
> LON-CAPA-users@mail.lon-capa.org
> http://mail.lon-capa.org/mailman/listinfo/lon-capa-users
>
--001517576db65e1fef047d8c8184
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Thanks, Stefan! This works great and is much cleaner using arrays. <br><br>=
I have left in a separate array @displayfunctions in this problem. Indeed, =
this is unnecessary but it allows me to display the equations nicely, and s=
o I have one array @functions with the functions expressed in Maxima syntax=
and another array @displayfunctions with the functions expressed in LaTeX.=
The <algebra> tag is versatile but seems to be incompatible with som=
e of the more cosmetic LaTeX commands that I use to display equations. <br>
<br>Many thanks for identifying my parsing problems.<br><br>Best,<br>Justin=
<br><br clear=3D"all">Justin Gray | Senior Lecturer<br>Department of Mathem=
atics | Simon Fraser University<br>8888 University Drive, Burnaby | V5A 1S6=
| Canada<br>
Tel: +1 778.782.4237<br><br><br>
<br><br><div class=3D"gmail_quote">On Tue, Jan 19, 2010 at 2:47 AM, Stefan =
Bisitz <span dir=3D"ltr"><<a href=3D"mailto:st.bisitz@ostfalia.de">st.bi=
sitz@ostfalia.de</a>></span> wrote:<br><blockquote class=3D"gmail_quote"=
style=3D"border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.=
8ex; padding-left: 1ex;">
Hi Justin and other math authors,<br>
<br>
Once again another optimization:<br>
You might want to put your functions into an array and the answer examples,=
too. Then dynamically choose from these lists by using<br>
$n =3D &random(1,$#functions,1);<br>
$function =3D $functions[$n];<br>
$example =3D $examples[$n];<br>
<br>
This way, you can easily add (or remove) functions by just adding them to t=
he functions array and add an example to the examples array. No other code =
adjustments are needed.<br>
<br>
The following problem source code respects all of this and the other optimi=
zations discussed before. It's not fully tested, but should work.<br>
<br>
Hope this helps,<br>
Stefan Bisitz<br>
<br>
----------------------------------------------------------------<div class=
=3D"im"><br>
<problem><br>
<script type=3D"loncapa/perl"><br></div>
@functions =3D (<br>
=A0"(x^2 - 1)^2",<br>
=A0"sqrt(x^2 - 1)",<br>
=A0"3/(2 + x^2)",<br>
=A0"2/(3 + sqrt(1 + x))",<br>
);<br>
@examples =3D (<br>
=A0&xmlparse('Many answers are possible. One example would be <=
m>$ f(x) =3D x^2, \quad g(x) =3D x^2 - 1 $</m>'),<br>
=A0&xmlparse('Many answers are possible. One example would be <=
m>$ f(x) =3D \sqrt{x}, \quad g(x) =3D x^2 - 1 $</m>'),<br>
=A0&xmlparse('Many answers are possible. One example would be <=
m>$ f(x) =3D 3/x, \quad g(x) =3D 2 + x^2 $</m>'),<div class=3D=
"im"><br>
=A0&xmlparse('Many answers are possible. One example would be <=
m>$ f(x) =3D 2/(3 + x), \quad g(x) =3D \sqrt{1 + x} $</m>'),<b=
r>
);<br></div>
$n =3D &random(1,$#functions,1);<br>
$function =3D $functions[$n];<br>
$example =3D $examples[$n];<br>
</script><br>
<br>
<startouttext /><br>
<p>Give an example of two nontrivial functions <m>$ f $</m&g=
t; and <m>$ g $</m> such that <m eval=3D"on">$ =
(f \circ g)(x) =3D $</m> <algebra>$function</algebra>.<=
;/p>Enter your answer in the form <p><b>expression1,expressi=
on2</b></p> where <m>$ f(x) =3D =A0$</m> <b>e=
xpression1</b> and <m>$ g(x) =3D =A0$</m> <b>expres=
sion2</b>.<p></p><div class=3D"im">
<br>
<endouttext /><br>
<br>
<mathresponse answerdisplay=3D"$example" cas=3D"maxima&qu=
ot; args=3D"$function" id=3D"11"><br>
=A0 =A0<answer>f(x) :=3D RESPONSE[1];<br>
g(x) :=3D RESPONSE[2];<br>
h(x) :=3D LONCAPALIST[1];<br>
composition:is(trigsimp(f(g(x)) - h(x)) =3D 0);<br>
fnottrivial:is(not(f(x) =3D x));<br>
gnottrivial:is(not(g(x) =3D x));<br>
composition and fnottrivial and gnottrivial;</answer><br>
=A0 =A0<textline readonly=3D"no" size=3D"20" /><=
br>
=A0 =A0<hintgroup showoncorrect=3D"no"><br>
=A0 =A0 =A0 =A0<mathhint name=3D"composition not equal" cas=
=3D"maxima" args=3D"$function" id=3D"12"><=
br>
=A0 =A0 =A0 =A0 =A0 =A0<answer>f(x) :=3D RESPONSE[1];<br>
g(x) :=3D RESPONSE[2];<br>
h(x) :=3D LONCAPALIST[1];<br>
is(not(f(g(x)) =3D h(x)));</answer><br>
=A0 =A0 =A0 =A0</mathhint><br>
<hintpart on=3D"composition not equal"><br></div>
=A0 =A0<startouttext /><p>Your example does not satisfy <m =
eval=3D"on">$ (f \circ g)(x) =3D f(g(x)) =3D $</m> <a=
lgebra>$function</algebra>.</p><endouttext /><div clas=
s=3D"im">
<br>
</hintpart><br>
=A0 =A0</hintgroup><br>
=A0 =A0<hintgroup showoncorrect=3D"no"><br>
=A0 =A0 =A0 =A0<mathhint name=3D"f trivial" cas=3D"maxim=
a" id=3D"13"><br>
=A0 =A0 =A0 =A0 =A0 =A0<answer>f(x) :=3D RESPONSE[1];<br>
is(f(x) =3D x);</answer><br>
=A0 =A0 =A0 =A0</mathhint><br>
<hintpart on=3D"f trivial"><br>
=A0 =A0<startouttext /><p>The question asks for nontrivial fun=
ctions, and so you cannot use <m>$ f(x) =3D x $</m>.</p>&=
lt;endouttext /><br>
</hintpart><br>
=A0 =A0</hintgroup><br>
=A0 =A0<hintgroup showoncorrect=3D"no"><br>
=A0 =A0 =A0 =A0<mathhint name=3D"g trivial" cas=3D"maxim=
a" id=3D"14"><br>
=A0 =A0 =A0 =A0 =A0 =A0<answer>g(x) :=3D RESPONSE[2];<br>
is(g(x) =3D x);</answer><br>
=A0 =A0 =A0 =A0</mathhint><br>
<hintpart on=3D"g trivial"><br>
=A0 =A0<startouttext /><p>The question asks for nontrivial fun=
ctions, and so you cannot use <m>$ g(x) =3D x $</m>.</p>&=
lt;endouttext /><br>
</hintpart><br>
=A0 =A0</hintgroup><br>
</mathresponse><br>
</problem><br></div>
----------------------------------------------------------------<div><div><=
/div><div class=3D"h5"><br>
<br>
<br>
On 19.01.2010 11:13, Stefan Bisitz wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
And again... ;-)<br>
<br>
Much better (the best?):<br>
<br>
Don't use two variables, one for calculations and one for display. It&#=
39;s simpler, shorter and less error-prone to have only one variable:<br>
<br>
<script type=3D"loncapa/perl"><br>
$function1 =3D "(x^2 - 1)^2";<br>
$function2 =3D "sqrt(x^2 - 1)";<br>
$function3 =3D "3/(2 + x^2)";<br>
$function4 =3D "2/(3 + sqrt(1 + x))";<br>
$example1=3D[...]<br>
</script><br>
<br>
<startouttext /><br>
<p>Give an example of two nontrivial functions <m>$ f $</m&g=
t; and <m>$ g $</m> such that <m eval=3D"on">$ =
(f \circ g)(x) =3D $</m> <algebra>$displayfunction</algebra&=
gt;.</p><br>
[...]<br>
<endouttext /><br>
<br>
<br>
In general, store or calculate your formula in one variable using the 1-dim=
ensional "pocket calculator" notation. Reuse the same variable to=
display it by using the <algebra> tag (without any "$") wh=
ich automatically renders in the preferred method.<br>
<br>
Stefan Bisitz<br>
<br>
<br>
On 19.01.2010 11:04, Stefan Bisitz wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi again,<br>
<br>
Why "pre-parse" anyway?<br>
<br>
Even better:<br>
<br>
1)<br>
<script type=3D"loncapa/perl"><br>
[...]<br>
$displayfunction1 =3D '(x^2 - 1)^2';<br>
[...]<br>
<br>
and 2)<br>
[...]<br>
such that <m eval=3D"on">$ (f \circ g)(x) =3D $displayfunct=
ion $</m>.<br>
[...]<br>
<br>
<br>
Stefan Bisitz<br>
<br>
<br>
On 19.01.2010 10:32, Stefan Bisitz wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Justin,<br>
<br>
It's quite simple to solve your display issues. You parse the formula t=
wice:<br>
1) $displayfunction1 =3D &xmlparse('<m>$(x^2 - 1)^2$</m>=
;');<br>
[...]<br>
<br>
2) <m eval=3D"on">$(f \circ g)(x) =3D $displayfunction $<=
;/m><br>
<br>
Just change to<br>
<m>$ (f \circ g)(x) =3D $</m> $displayfunction<br>
<br>
$displayfunction is already parsed and must not be included again in the &l=
t;m> tag.<br>
<br>
tth as well as mimetex works now (tested on bleeding edge machine).<br>
<br>
And yes, please avoid to use jsmath hardcoded in the problem. Let the CCs o=
r students decide.<br>
<br>
Stefan Bisitz<br>
<br>
<br>
<br>
On 19.01.2010 09:59, Justin Gray wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"border-left: 1px solid rgb(204, =
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
When displaying equations, setting the display attribute within the <m&g=
t; tag to "jsMath" is generally discouraged as it requires users =
to have<br>
installed jsmath software on their computer and will override their prefere=
nces on how math equations are displayed.<br>
<br>
I have tried viewing the problem below on several computers and jsMath seem=
s to be the only math rendering engine that lets me view the equations prop=
erly. (With tth the equations do not show up at all and with mimetex the eq=
uations are incomprehensible.) I am reluctant to force users to jsMath for =
this problem. Perhaps there is another way to remedy this problem?<br>
<br>
Any suggestions are appreciated.<br>
<br>
Thanks,<br>
Justin<br>
<br>
Justin Gray | Senior Lecturer<br>
Department of Mathematics | Simon Fraser University<br>
8888 University Drive, Burnaby | V5A 1S6 | Canada<br>
Tel: +1 778.782.4237<br>
<br>
<problem><br>
<script type=3D"loncapa/perl"><br>
$function1 =3D "(x^2 - 1)^2";<br>
$function2 =3D "sqrt(x^2 - 1)";<br>
$function3 =3D "3/(2 + x^2)";<br>
$function4 =3D "2/(3 + sqrt(1 + x))";<br>
$displayfunction1 =3D &xmlparse('<m>$(x^2 - 1)^2$</m>&#=
39;);<br>
$displayfunction2 =3D &xmlparse('<m>$\sqrt{x^2 - 1}$</m>=
;');<br>
$displayfunction3 =3D &xmlparse('<m>$\displaystyle \frac{3}{2=
+ x^2}$</m>');<br>
$displayfunction4 =3D &xmlparse('<m>$\displaystyle \frac{2}{3=
+ \sqrt{1 + x}}$</m>');<br>
$example1=3D&xmlparse('Many answers are possible. One example would=
be <m>$f(x) =3D x^2, \quad g(x) =3D x^2 - 1$</m>');<br>
$example2=3D&xmlparse('Many answers are possible. One example would=
be <m>$f(x) =3D \sqrt{x}, \quad g(x) =3D x^2 - 1$</m>');<b=
r>
$example3=3D&xmlparse('Many answers are possible. One example would=
be <m>$f(x) =3D 3/x, \quad g(x) =3D 2 + x^2$</m>');<br>
$example4=3D&xmlparse('Many answers are possible. One example would=
be <m>$f(x) =3D 2/(3 + x), \quad g(x) =3D \sqrt{1 + x}$</m>=
9;);<br>
$n =3D &random(1,4,1);<br>
$function =3D &choose($n,"$function1","$function2",=
"$function3","$function4");<br>
$displayfunction =3D &choose($n,"$displayfunction1","$di=
splayfunction2","$displayfunction3","$displayfunction4&=
quot;); <br>
$example =3D &choose($n,"$example1","$example2",&qu=
ot;$example3","$example4");<br>
</script><br>
<br>
<startouttext /><p>Give an example of two nontrivial functions =
<m>$f$</m> and <m>$g$</m> such that <m eval=3D&q=
uot;on">$(f \circ g)(x) =3D $displayfunction $</m>.</p>=
Enter your answer in the form <p><b>expression1,expression2<=
/b></p> where <m>$f(x) =3D $</m> <b>expression1&=
lt;/b> and <m>$g(x) =3D $</m> <b>expression2</b>=
.<p></p><endouttext /><br>
<br>
<mathresponse answerdisplay=3D"$example" cas=3D"maxima&qu=
ot; args=3D"$function" id=3D"11"><br>
=A0 =A0<answer>f(x) :=3D RESPONSE[1];<br>
g(x) :=3D RESPONSE[2];<br>
h(x) :=3D LONCAPALIST[1];<br>
composition:is(trigsimp(f(g(x)) - h(x)) =3D 0);<br>
fnottrivial:is(not(f(x) =3D x));<br>
gnottrivial:is(not(g(x) =3D x));<br>
composition and fnottrivial and gnottrivial;</answer><br>
=A0 =A0<textline readonly=3D"no" size=3D"20" /><=
br>
=A0 =A0<hintgroup showoncorrect=3D"no"><br>
=A0 =A0 =A0 =A0<mathhint name=3D"composition not equal" cas=
=3D"maxima" args=3D"$function" id=3D"12"><=
br>
=A0 =A0 =A0 =A0 =A0 =A0<answer>f(x) :=3D RESPONSE[1];<br>
g(x) :=3D RESPONSE[2];<br>
h(x) :=3D LONCAPALIST[1];<br>
is(not(f(g(x)) =3D h(x)));</answer><br>
=A0 =A0 =A0 =A0</mathhint><br>
<hintpart on=3D"composition not equal"><br>
=A0 =A0<startouttext /><p>Your example does not satisfy <m =
eval=3D"on">$(f \circ g)(x) =3D f(g(x)) =3D $displayfunction $=
</m>.</p><endouttext /><br>
</hintpart><br>
=A0 =A0</hintgroup><br>
=A0 =A0<hintgroup showoncorrect=3D"no"><br>
=A0 =A0 =A0 =A0<mathhint name=3D"f trivial" cas=3D"maxim=
a" id=3D"13"><br>
=A0 =A0 =A0 =A0 =A0 =A0<answer>f(x) :=3D RESPONSE[1];<br>
is(f(x) =3D x);</answer><br>
=A0 =A0 =A0 =A0</mathhint><br>
<hintpart on=3D"f trivial"><br>
=A0 =A0<startouttext /><p>The question asks for nontrivial fun=
ctions, and so you cannot use <m>$f(x) =3D x$</m>.</p><=
;endouttext /><br>
</hintpart><br>
=A0 =A0</hintgroup><br>
=A0 =A0<hintgroup showoncorrect=3D"no"><br>
=A0 =A0 =A0 =A0<mathhint name=3D"g trivial" cas=3D"maxim=
a" id=3D"14"><br>
=A0 =A0 =A0 =A0 =A0 =A0<answer>g(x) :=3D RESPONSE[2];<br>
is(g(x) =3D x);</answer><br>
=A0 =A0 =A0 =A0</mathhint><br>
<hintpart on=3D"g trivial"><br>
=A0 =A0<startouttext /><p>The question asks for nontrivial fun=
ctions, and so you cannot use <m>$g(x) =3D x$</m>.</p><=
;endouttext /><br>
</hintpart><br>
=A0 =A0</hintgroup><br>
</mathresponse><br>
</problem><br>
<br>
<br>
<br>
</blockquote>
<br>
_______________________________________________<br>
LON-CAPA-users mailing list<br>
<a href=3D"mailto:LON-CAPA-users@mail.lon-capa.org" target=3D"_blank">LON-C=
APA-users@mail.lon-capa.org</a><br>
<a href=3D"http://mail.lon-capa.org/mailman/listinfo/lon-capa-users" target=
=3D"_blank">http://mail.lon-capa.org/mailman/listinfo/lon-capa-users</a><br=
>
</blockquote>
<br>
<br>
</blockquote>
<br>
_______________________________________________<br>
LON-CAPA-users mailing list<br>
<a href=3D"mailto:LON-CAPA-users@mail.lon-capa.org" target=3D"_blank">LON-C=
APA-users@mail.lon-capa.org</a><br>
<a href=3D"http://mail.lon-capa.org/mailman/listinfo/lon-capa-users" target=
=3D"_blank">http://mail.lon-capa.org/mailman/listinfo/lon-capa-users</a><br=
>
</blockquote>
<br>
_______________________________________________<br>
LON-CAPA-users mailing list<br>
<a href=3D"mailto:LON-CAPA-users@mail.lon-capa.org" target=3D"_blank">LON-C=
APA-users@mail.lon-capa.org</a><br>
<a href=3D"http://mail.lon-capa.org/mailman/listinfo/lon-capa-users" target=
=3D"_blank">http://mail.lon-capa.org/mailman/listinfo/lon-capa-users</a><br=
>
</div></div></blockquote></div><br>
--001517576db65e1fef047d8c8184--