MathGroup Archive 2003

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

Search the Archive

Re: Re: How to NOT convert Sin[x]/Cos[x] to Tan[x] ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44873] Re: [mg44823] Re: How to NOT convert Sin[x]/Cos[x] to Tan[x] ?
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Thu, 4 Dec 2003 03:04:37 -0500 (EST)
  • References: <bq5b08$k05$1@smc.vnet.net> <200312030924.EAA17795@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Another approach (which was already discussed on this formum some years 
ago) is simply to use Format:




Unprotect[Tan];


Format[Tan[x_]]:=sin[x]/cos[x]


Tan[y]


sin[y]/cos[y]


Tan[Pi/4]


1


The advantage of this apprach is that you can make Tan Look like 
sin[x]/cos[x] but still perfomr computations wihtout having to call 
ReleaseHold etc. However, this can be tricky, because you will get 
differnet results depending what you choose your default intput and 
output formats to be. The above works well if you use Standard form for 
Input and Output. If you use TraditionalForm for output you want be 
able to use this simple minded approach. You will need to use MakeBoxes 
etc, which is more complicated but can produce better looking results.

Andrzej Kozlowski

On 3 Dec 2003, at 18:24, Bobby R. Treat wrote:

> Mathematica doesn't compute things so much as apply substitution
> rules. For Divide there's a rule that says Sin[x_]/Cos[x_]:>Tan[x].
> The opposite is also true, so to prevent an infinite loop, Mathematica
> stops with the simplest expression it can find. Tan[x] is simpler than
> the other expression (smaller leaf count, smaller tree depth, smaller
> bytecount, whatever), so that's what it gives you.
>
> Ted Ersek recently told us about a package (HoldTemporary) that will
> help:
>
> http://library.wolfram.com/infocenter/MathSource/705/
>
> Bobby
>
> AES/newspost <siegman at stanford.edu> wrote in message 
> news:<bq5b08$k05$1 at smc.vnet.net>...
>> The Mathematica Book says "Mathematica automatically uses functions 
>> like
>> Tan whenever it can" and shows as an example that Sin[x]^2/Cos[x] is
>> converted to  Sin[x] Tan[x] .
>>
>> Any simple way to stop this in displaying the output of a symbolic
>> calculation?
>>
>> The obvious attempt of applying /.Tan[x]->Sin[x]/Cos[x] doesn't seem 
>> to
>> do what's wanted.
>>
>> [And out of curiousity, WHY does it do this?  That is, why is Tan
>> apparently given a higher priority than Cos?]
>
>


  • Prev by Date: For Loop
  • Next by Date: Scoping, named patterns, local vs global variables
  • Previous by thread: Re: How to NOT convert Sin[x]/Cos[x] to Tan[x] ?
  • Next by thread: Re: Re: How to NOT convert Sin[x]/Cos[x] to Tan[x] ?