Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Built-In fuctions redefined---How?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62641] Re: Built-In fuctions redefined---How?
  • From: Peter Pein <petsie at dordos.net>
  • Date: Wed, 30 Nov 2005 00:06:27 -0500 (EST)
  • References: <dmh92m$8rj$1@smc.vnet.net> <dmhfbi$bf4$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Peter Pein schrieb:
> Virgil Stokes schrieb:
>> How can I introduce the following definitions:
>>
>>     cx for Cos[x]
>>   sx for Sin[x]
>>  
>> where, the argument x, will always be a single symbol, and then still be 
>> able to use the trigonometric identities associated with Sin, Cos; e.g.,
>>
>>   cx^2 + sx^2 = 1
>>
>> Note, this is not  c x (3 symbol expression); but,  cx (2 symbol 
>> expression).
>> Why? Because I have some rather large matrices with many elements that 
>> contain expressions in Cos and Sin terms that make printing and 
>> displaying messy and using the MatrixForm can give truncation in the 
>> printed output.
>>
>> --V. Stokes
>>
>>
>>   
> 
> Hi!
> 
> Use Format:
> 
> 
> In[1]:=
> Unprotect[Cos, Sin];
> Format[Cos[x_] := "c" <> ToString[x]];
> Format[Sin[x_] := "s" <> ToString[x]];
> 
> In[4]:=
> Expand[(Cos[x] + Sin[t])^3]
> Out[4]= "cx"^3 + 3*"cx"^2*"st" + 3*"cx"*"st"^2 + "st"^3
> 
> In[5]:= TrigExpand[% /. t -> x]
> Out[5]= 1 + 2*"cx"*"sx"
> 
> Peter
> 
Something went terribly wrong: The above Mathematica-lines should read 
In[1]:=
Unprotect[Cos,Sin];
Format[Cos[x_]]:="c"<>ToString[x];
Format[Sin[x_]]:="s"<>ToString[x];
Expand[(Cos[x]+Sin[t])^2]
Out[4]= "cx"^2 + 2*"cx"*"st" + "st"^2

In/Out[5] are correct.

Peter


  • Prev by Date: Re: Hardcopy or electronic books?
  • Next by Date: Re: Bypassing built-in functions in differentiation
  • Previous by thread: Re: Built-In fuctions redefined---How?
  • Next by thread: MathLink slow