19
$\begingroup$

For example, I hate that Mathematica uses Pochhammer symbol in outputs and prefer all the expressions in Gamma function. How can I ban usage of Pochhammer? I also want all outputs to use HurwitzZeta rather than Zeta.

In another instance I want the results to use my own variant of Polygamma function (modified). How can I mandate its usage when possible?

$\endgroup$
  • $\begingroup$ I cannot give an exact example right now, but I think it quite ofthen appears. I am looking for a general solution that would work everywhere. $\endgroup$ – Anixx Apr 15 '12 at 16:56
  • $\begingroup$ There might be a way to set this as the default, but I think that FunctionExpand[ expr ] can take the argument TargetFunctions->{Gamma,HurwitzZeta}. $\endgroup$ – Eli Lansey Apr 15 '12 at 17:31
  • $\begingroup$ I want FullSimplify to follow these rules. $\endgroup$ – Anixx Apr 15 '12 at 17:53
  • $\begingroup$ An example would be helpful, but what about FullSimplify[expr, TransformationFunctions -> {Gamma,HurwitzZeta}] $\endgroup$ – Eli Lansey Apr 15 '12 at 18:18
  • $\begingroup$ @EliLansey I think that's ComplexExpand not FunctionExpand (having TargetFunctions option). And there it can only take {Re,Im,Abs,Arg,Conjugate,Sign} as values. $\endgroup$ – Sjoerd C. de Vries Apr 15 '12 at 20:55
15
$\begingroup$

You may try for example something like:

f[e_] := 100 Count[e, _Pochhammer, {0, Infinity}] + LeafCount[e];
FullSimplify[Pochhammer[k, n], ComplexityFunction -> f]

(*
->Gamma[k + n]/Gamma[k]
*)
$\endgroup$
  • $\begingroup$ Does Mathematica provide access to the default complexity function, so you can just amend it instead of completely replacing? $\endgroup$ – celtschk Apr 15 '12 at 21:58
  • 4
    $\begingroup$ @celtschk LeafCount[] IS the default Complexity function $\endgroup$ – Dr. belisarius Apr 15 '12 at 22:17
  • $\begingroup$ What complexity is by default assigned to expressions that contain user's functions? Why user-defined functions always expanded to their definitions? Can it be avoided? $\endgroup$ – Anixx Apr 15 '12 at 23:06
  • 1
    $\begingroup$ @celtschk: not quite true that LeafCount is the default complexity function. As the docs ref/ComplexityFunction say, "forms are ranked primarily according to their LeafCount, with corrections to treat integers with more digits as more complex." $\endgroup$ – murray Apr 16 '12 at 0:21
  • 1
    $\begingroup$ @Anixx by user defined 'functions' do you mean things like f[x_]:=Pochammer[x+1]? If so, then the reason is that MMA replaces any instance of f[x] with the RHS (it is actually not a Function), BEFORE any simplification is done (unless holds are in place), and hence doesn't know about simplification rules for it (see mathematica.stackexchange.com/questions/704/…). As to creating those rules: no idea $\endgroup$ – tkott Apr 16 '12 at 11:19
8
$\begingroup$

Perhaps you will find utility in Format and related functions?

Unprotect[Pochhammer];

Format[Pochhammer[k_, n_]] := HoldForm[ Gamma[k + n]/Gamma[k] ]

Protect[Pochhammer];

Pochhammer[a, b]
Gamma[a + b]/Gamma[a]

Similar things can be done with $PrePrint:

$PrePrint = # /. Pochhammer[k_, n_] :> HoldForm[ Gamma[k + n]/Gamma[k] ] &;

Pochhammer[a, b]
Gamma[a + b]/Gamma[a]
$\endgroup$
2
$\begingroup$

I have found ReplaceAll to be useful for when I want to replace instances of Gamma or Binomial calls to show as a factorial.

    x*Gamma[a] + x^2*Gamma[b] - 
  3*Binomial[z, c] /. {Gamma[n_] -> (n - 1)!, 
  Binomial[n_, k_] -> ((n)!/((n - k)!*k!))}

Out:

   x (-1 + a)! + x^2 (-1 + b)! - (3 z!)/(c! (-c + z)!)
$\endgroup$
  • $\begingroup$ but note that it's up to you to know that the replacement is equivalent. $\endgroup$ – T. Webster Sep 4 '12 at 6:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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