Skip to main content
Post Undeleted by RunnyKine
deleted 134 characters in body
Source Link
RunnyKine
  • 33.5k
  • 3
  • 111
  • 178

You can use aOne way will be to add it to the definition of ComplexityFunctionCos to tellby Mathematica to do what you wantUnprotecting it. Here is a simple example of such a function:

cf[e_]Unprotect[Cos] Cos[2 x] := Count[e, _Sin,1 Infinity]- +2 LeafCount[e]Sin[x]^2 Protect[Cos] 

Now you can pass your expression containing $cos(2x)$ to FullSimplify using cf to convert it to $1 - 2sin(x)^2$ like soThen evaluating the following:

FullSimplify[22 Cos[2 x] + 3 x Cos[2 x] + Tan[x] Sin[x] Cos[2 x] +  Exp[Tan[Cos[2 x]]], ComplexityFunction -> cf] 

Mathematica graphics gives:

Mathematica graphics

Which you can further Simplify if you so please. Notice that the desired replacement has occurred everywhere there's Cos[2x]

You can use a ComplexityFunction to tell Mathematica to do what you want. Here is a simple example of such a function:

cf[e_] := Count[e, _Sin, Infinity] + LeafCount[e] 

Now you can pass your expression containing $cos(2x)$ to FullSimplify using cf to convert it to $1 - 2sin(x)^2$ like so:

FullSimplify[2 Cos[2 x] + 3 x Cos[2 x] + Tan[x] Sin[x] Cos[2 x] +  Exp[Tan[Cos[2 x]]], ComplexityFunction -> cf] 

Mathematica graphics

Notice that the desired replacement has occurred everywhere there's Cos[2x]

One way will be to add it to the definition of Cos by Unprotecting it.

Unprotect[Cos] Cos[2 x] := 1 - 2 Sin[x]^2 Protect[Cos] 

Then evaluating the following:

2 Cos[2 x] + 3 x Cos[2 x] + Tan[x] Sin[x] Cos[2 x] + Exp[Tan[Cos[2 x]]] 

gives:

Mathematica graphics

Which you can further Simplify if you so please. Notice that the desired replacement has occurred everywhere there's Cos[2x]

Post Deleted by RunnyKine
Source Link
RunnyKine
  • 33.5k
  • 3
  • 111
  • 178

You can use a ComplexityFunction to tell Mathematica to do what you want. Here is a simple example of such a function:

cf[e_] := Count[e, _Sin, Infinity] + LeafCount[e] 

Now you can pass your expression containing $cos(2x)$ to FullSimplify using cf to convert it to $1 - 2sin(x)^2$ like so:

FullSimplify[2 Cos[2 x] + 3 x Cos[2 x] + Tan[x] Sin[x] Cos[2 x] + Exp[Tan[Cos[2 x]]], ComplexityFunction -> cf] 

Mathematica graphics

Notice that the desired replacement has occurred everywhere there's Cos[2x]