15

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.

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
xslittlegrass
  • 27,549
  • 9
  • 97
  • 186

1 Answers1

25

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] *)
Xerxes
  • 3,951
  • 20
  • 31