FW: Tan,Cot,Csc,etc
- To: mathgroup@smc.vnet.net
- Subject: [mg12310] FW: [mg12273] Tan,Cot,Csc,etc
- From: Ersek_Ted%PAX1A@mr.nawcad.navy.mil
- Date: Thu, 7 May 1998 18:51:52 -0400
I noticed how to fix the limitation of my last version.
FirstRule should include Sin->tSin, Cos->tCos That way different
occurrences of Sin[x] will be combined as appropriate.
See below.
Ted Ersek
______________________________
In[1]:=
Off[General::spell1]
In[2]:=
FirstRules= {Csc[x_]->1/tSin[x], Sec[x_]->1/tCos[x],
Tan[x_]->tSin[x]/tCos[x],
Cot[x_]->tCos[x]/tSin[x],Sin->tSin, Cos->tCos};
SecondRules={tSin->Sin,tCos->Cos};
In[3]:=
SinCosOnly[expr_]:=With[{new=expr//.FirstRules},
HoldForm[Evaluate[new]]//.SecondRules]
In[4]:=
ex1=SinCosOnly[ Csc[x]Tan[x]+Tan[x]+Sin[x]Tan[x] ]
Out[4]=
\!\(\*
TagBox[\(1\/Cos[x] + Sin[x]\/Cos[x] + Sin[x]\^2\/Cos[x]\),
HoldForm]\)
In[5]:=
(ex1//.HoldForm->Identity)-Tan[x]
Out[5]=
Sec[x]+Sin[x] Tan[x]
|
| Arturas Acus wrote:
||
||do anybody knows a simple way to get rid of functions like Tan[],
||Cot[], Csc[], and others in the output of trigonometric
computations. ||I would like to keep only Sin[] and Cos[] instead. ||
||For example instead Csc[a]*Cot[a] I would like to have
||Cos[a]/(Sin[a]^2) and so on.
||
|
|I can get you part way there.
|
|In[1]:=
|Off[General::spell1]
|
|In[2]:=
|FirstRules= {Csc[x_]->1/tSin[x], Sec[x_]->1/tCos[x],
Tan[x_]->tSin[x]/tCos[x],
| Cot[x_]->tCos[x]/tSin[x]};
|
|In[3]:=
|SecondRules={tSin->Sin,tCos->Cos};
|
|In[4]:=
|SinCosOnly[expr_]:=With[{new=expr//.FirstRules}, |
HoldForm[Evaluate[new]]//.SecondRules] |
|_______________________________________ |Now I convert an expression to
Sin and Cos only. |
|In[5]:=
|ex1=SinCosOnly[ Csc[x]Tan[x]+Tan[x]+Sin[x]Tan[x] ] |
|Out[5]=
|\!\(\* TagBox[ blah, blah, blah, ..... |
|Translated into ASC we have,
|1/Cos[x]+Sin[x]/Cos[x]+Sin[x]Sin[x]/Cos[x] |
|Unfortunately my rule doesn't simplify (Sin[x]Sin[x]) into (Sin[x]^2).
|If I worked at it I could probably crack that part, but I don't |know
if I will have the time.
|______________________________________ |Now we don't get what we want
if we use the above result in later calculations.
|
|In[6]:=
|ex1-Tan[x]
|
|Out[6]=
|\!\(\*RowBox[{ blah, blah, blah, ..... |
|Translated into ASC we have,
|1/Cos[x]+Sin[x]/Cos[x]+Sin[x]Sin[x]/Cos[x]-Tan[x] |
|_____________________________________ |We can use the above result if
we change HoldForm to Identity. |Note: A few weeks ago I asked the
group what Identity is good for. |
|In[7]:=
|(ex1/.HoldForm->Identity)-Tan[x]
|
|Out[7]=
|Sec[x]+Sin[x] Tan[x]
|
|The new feature at the top of my wish list is a new type of |Hold (I
call it HoldTemporary).
|HoldTemporary could be used here instead of HoldForm. |HoldTemporary
would work very much like HoldForm, except the |hold would be removed
as soon as we try to do anything to an |expression with this head.
This way we would not have to |remove the Hold when we use the held
result in later |calculations.
|
|Ted Ersek
|