Re: How to print TraditionalForm without evaluation
- To: mathgroup at smc.vnet.net
- Subject: [mg92636] Re: How to print TraditionalForm without evaluation
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Thu, 9 Oct 2008 06:35:23 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <gci1sm$iv$1@smc.vnet.net>
Serych Jakub wrote:
> I want to write notebook which prints simple integration examples with
> results for the students.
> Something like:
>
> ex1 = (1 - 3*x^3 + 2*x^5)/(4*x^3);
> ex2 = (-5*x^(1/4) + (x^2)^(4/3))/x^(3/2);
>
> Grid[{
> Table[
> TraditionalForm[Integrate[Symbol["ex" <> ToString[nr]], x]], {nr, 1, 2}],
> (* do not integrate this *)
> Table[
> TraditionalForm[Integrate[Symbol["ex" <> ToString[nr]], x]], {nr, 1, 2}]},
> (* integrate this *)
> Frame -> All, ItemStyle -> Directive[FontSize -> 18, Bold]]
>
> (there will be much more examples ex3,ex4, etc.)
>
> This works nice, but I need to tell Mathematica not to Integrate in the first
> row of the table - examples (only in the second one - results). Is there any
> possibility to suppress the evaluation of the Integral in the first row of
> the grid and just print the symbol of Integral and the TraditionalForm of the
> example behind it?
One possible way is illustrated below. First, we prevent the evaluation
of the integrals (but not of the inner expression leading to the
integrands) by substituting a dummy symbol, say 'int', in place of
*Integrate*, then we replace the dummy head by
*HoldForm[Integrate[__]]*, and voila!
ex1 = (1 - 3*x^3 + 2*x^5)/(4*x^3);
ex2 = (-5*x^(1/4) + (x^2)^(4/3))/x^(3/2);
Grid[{Table[
TraditionalForm[
int[Symbol["ex" <> ToString[nr]], x] /.
int[exp__] -> HoldForm[Integrate[exp]]], {nr, 1,
2}],(*do not integrate this*)
Table[TraditionalForm[
Integrate[Symbol["ex" <> ToString[nr]], x]], {nr, 1,
2}]},(*integrate this*)Frame -> All,
ItemStyle -> Directive[FontSize -> 18, Bold]]
Regards,
-- Jean-Marc