2
$\begingroup$

I am trying to work on a problem with a probability distribution. I wanted to get the result in analytical form. Suppose I need to keep p1, p2, p3, p4 variables such that p1+p2+p3+p4=1;

How to use this information (p1+p2+p3+p4=1) in mathematica so that wherever in my calculation this term appears, it takes the value 1. Otherwise I will have to find this expression in a lengthy result and convert.

$\endgroup$
3
$\begingroup$

You could use explicit assumptions:

Assuming[p1 + p2 + p3 + p4 == 1, Simplify[Exp[p1 + p2 + 3 p3 + p4 + 3]]]

(* Out: E^(4 + 2 p3) *)
$\endgroup$
  • $\begingroup$ okay, it works. Thanks $\endgroup$ – kphy Jun 7 '15 at 17:27
  • $\begingroup$ @KunalSharma One can also set $Assumptions = p1 + p2 + p3 + p4 == 1. It is equivalent to Assuming, except that Assuming temporarily sets $Assumptions and setting $Assumptions will remain in effect for computations until it is reset ($Assumptions = True). Sometimes one form (Assuming vs $Assumptions) is more convenient than the other. Also note that only some functions, such as Simplify, use $Assumptions. $\endgroup$ – Michael E2 Jun 7 '15 at 17:33
  • $\begingroup$ @KunalSharma if the solution I proposed worked for you, you might consider accepting my answer. You can do so by clicking on the checkmark next to it in the left margin. Thank you! $\endgroup$ – MarcoB Jun 8 '15 at 23:02

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.