       Re: Converting a number back to a symbol?

• To: mathgroup at smc.vnet.net
• Subject: [mg82931] Re: Converting a number back to a symbol?
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sun, 4 Nov 2007 06:03:26 -0500 (EST)
• Organization: The Open University, Milton Keynes, UK
• References: <fgenct\$fsd\$1@smc.vnet.net> <fghb0r\$i8g\$1@smc.vnet.net>

```Jean-Marc Gulliet wrote:
> AES wrote:
>
> <snip>
>
>> But what about the reverse case: we have an expression containing
>> various integer powers of Pi, and we want to replace all the explicitly
>> appearing Pi's by 2 u0.  Writing
>>
>>    expr /. {Pi-> 2 u0}
>>
>> doesn't seem to do it.
>>
>> Is there a way?
>
> Please, could you give a concrete example where such a transformation
> does not work?
>
> In:= expr = Pi + Pi^2 + Pi^3 + (Pi/2 + (Pi/2)^2 + (Pi/5)^3) + 1/(Pi +
> Pi^2 + Pi^3)
>
> Out=            2         3
> 3 Pi   5 Pi    126 Pi          1
> ---- + ----- + ------- + --------------
>   2       4       125            2     3
>                           Pi + Pi  + Pi
>
> In:= expr /. Pi -> 2 u0
>
> Out=                       3
>             2   1008 u0             1
> 3 u0 + 5 u0  + -------- + --------------------
>                   125                 2       3
>                            2 u0 + 4 u0  + 8 u0
>

Oops! I have just realized that I had forgotten to add an extra carriage
return after each output in OutputForm (this is required since version
6) so the first row of exponents was misplaced in the previous message.
Here is a more readable version.

In:= expr = Pi + Pi^2 + Pi^3 + (Pi/2 + (Pi/2)^2 + (Pi/5)^3) + 1/(Pi +
Pi^2 + Pi^3)

Out=
2         3
3 Pi   5 Pi    126 Pi          1
---- + ----- + ------- + --------------
2       4       125            2     3
Pi + Pi  + Pi

In:= expr /. Pi -> 2 u0

Out=
3
2   1008 u0             1
3 u0 + 5 u0  + -------- + --------------------
125                 2       3
2 u0 + 4 u0  + 8 u0

Cheers,
--
Jean-Marc

```

• Prev by Date: Re: Displaying graphics with the MathKernel in OS X
• Next by Date: Re: The uses of Condition (/;)
• Previous by thread: Re: Converting a number back to a symbol?
• Next by thread: Re: Converting a number back to a symbol?