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: [mg44874] 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:38 -0500 (EST)
  • References: <bq5b08$k05$1@smc.vnet.net> <200312030924.EAA17795@smc.vnet.net> <D682E882-25FB-11D8-8419-00039311C1CC@mimuw.edu.pl>
  • Sender: owner-wri-mathgroup at wolfram.com

I should have added that, if you are working in StandardForm, you might 
prefer:

In[1]:=
Unprotect[Tan];


In[2]:=

Format[Tan[x_]]:=HoldForm[Sin[x]/Cos[x]]



In[3]:=
Sin[x]^2/Cos[x]^3

Out[3]=
\!\(\*
   RowBox[{\(Sec[x]\), " ",
     SuperscriptBox[
       TagBox[\(Sin[x]\/Cos[x]\),
         HoldForm], "2"]}]\)


Probably you would want then do the same thing to Sec, Cot, Csec etc.


Andrzej Kozlowski


On 4 Dec 2003, at 10:47, Andrzej Kozlowski wrote:

> 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: Re: Mathematica 4.2 and Mandrake 9.2
  • Next by Date: Re: Suggestion: Visualization of complex functions with Mathematica
  • Previous by thread: Re: Re: How to NOT convert Sin[x]/Cos[x] to Tan[x] ?
  • Next by thread: Re: How to NOT convert Sin[x]/Cos[x] to Tan[x] ?