15
$\begingroup$

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.

$\endgroup$
4
  • 1
    $\begingroup$ 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 $\endgroup$
    – rm -rf
    Feb 19, 2013 at 22:07
  • $\begingroup$ 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 $\endgroup$ Feb 19, 2013 at 22:12
  • $\begingroup$ take a look at the questions automatically appearing on the right of the page. they may help $\endgroup$
    – acl
    Feb 19, 2013 at 22:17
  • $\begingroup$ Related: (7741) and (18144) $\endgroup$
    – Mr.Wizard
    Feb 20, 2013 at 0:25

1 Answer 1

25
$\begingroup$

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] *)
$\endgroup$
1
  • $\begingroup$ Alternatively, ComplexityFunction -> (Count[#, Sin[_], {-2}] &) $\endgroup$
    – chyanog
    Apr 16, 2013 at 16:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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