Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have an expression in the form of $\tt \frac{Sin[x]}{x}$ that I would like to simplify to the form of Sinc[x]. I've tried the Simplify, FullSimplify and TrigReduce, but none of them work.

Simplify[Sin[x]/x]
FullSimplify[Sin[x]/x]
TrigReduce[Sin[x]/x]

all gives the result $\tt\frac{Sin[x]}{x}$. However

FullSimplify[Sin[x]/x == Sinc[x]]

gives True.

I have two questions:

  1. Is there a way to tell MMA that I prefer Sinc[x] than Sin[x]/x, so that it can simplify $\sin(x)/x$ to $\mathrm{sinc}(x)$?
  2. How doees TransformationFunctions and ComplexityFunction work in Simplify? Could you give some examples and explanations of how to use them to control the form of the outcome expression? Can I use them to let Mathematica apply my own defined simplify rules (for example in this case Sin[x]/x -> Sinc[x])? I found their documents are difficult to understand for me. Thanks.

update FullSimplify[Sin[x]/x,ComplexityFunction->Composition[StringLength,ToString,InputForm]] also doesn't work. However,

Composition[StringLength,ToString,InputForm][Sin[x]/x]

gives 8 which is larger than

Composition[StringLength,ToString,InputForm][Sinc[x]]

which gives 7.

share|improve this question
1  
There are plenty of examples on this site for TransformationFunctions and ComplexityFunction... Also search for LeafCount both in the docs and this site and also see this question –  rm -rf Feb 19 '13 at 22:07
    
Re: I found their documents are difficult to understand for me . Yep, the docs need some time to get used to them, but be sure to invest enough time to get through that hurdle –  belisarius Feb 19 '13 at 22:12
    
take a look at the questions automatically appearing on the right of the page. they may help –  acl Feb 19 '13 at 22:17
    
Related: (7741) and (18144) –  Mr.Wizard Feb 20 '13 at 0:25
add comment

1 Answer

up vote 22 down vote accepted

A transformation function is just any function that will take an expression to another expression you consider equivalent. For example, we can make one that takes Sin to Sinc.

sinctrans[expr_] := expr /. Sin[x_] :> x Sinc[x]

You could just use that by itself to do this substitution, but you can also add it to the TransformationFunctions of Simplify to do something more complicated.

Simplify[Sum[((-1)^n*x^(2*n))/(2*n + 1)!, 
     {n, 0, Infinity}], TransformationFunctions -> 
     {Automatic, sinctrans}]
(* Sinc[x] *)

Mathematica will generally use Sinc[x] over Sin[x]/x in these circumstances, since it has fewer elements. We can contrive an example where that's not the case and then introduce a ComplexityFunction that harshly penalizes any expression containing Sin:

Simplify[Sin[x], TransformationFunctions -> 
     {Automatic, sinctrans}, ComplexityFunction -> 
     (LeafCount[#1] + If[FreeQ[#1, Sin], 0, 10^3] & )]
(* x Sinc[x] *)
share|improve this answer
    
Alternatively, ComplexityFunction -> (Count[#, Sin[_], {-2}] &) –  chyaong Apr 16 '13 at 16:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.