Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've encountered the following problem. There is the identity (Legendre's relation) that the special functions EllipticK[x] and EllipticE[x] satisfy:


Mathematica does not seem to know it so I included it into assumptions:

$Assumptions = EllipticK[x] EllipticE[1 - x] + EllipticE[x] EllipticK[1 - x] -
               EllipticK[x] EllipticK[1 - x] == Pi/2

If I now evaluate

Simplify[EllipticK[x] EllipticE[1 - x] + EllipticE[x] EllipticK[1 - x] - 
       EllipticK[x] EllipticK[1 - x]]

I will get Pi/2, fine. The problem is that I want this identity to be used not only symbolically but also numerically, i.e. for example I would like Mathematica to simplify

Simplify[EllipticE[2/3] EllipticK[1/
   3] + (EllipticE[1/3] - EllipticK[1/3]) EllipticK[2/3]]

down to Pi/2. Not only It does not happen when I just stated this identity symbolically but even direct evaluation with this assumption does not yield desirable answer. Namely,

 EllipticE[2/3] EllipticK[1/
    3] + (EllipticE[1/3] - EllipticK[1/3]) EllipticK[2/3], 
 Assumptions -> 
  EllipticE[2/3] EllipticK[1/
      3] + (EllipticE[1/3] - EllipticK[1/3]) EllipticK[2/3] == Pi/2]


EllipticE[2/3] EllipticK[1/
   3] + (EllipticE[1/3] - EllipticK[1/3]) EllipticK[2/3]

How can I get Pi/2 there instead?

share|improve this question
up vote 7 down vote accepted

The following transformation function works in this case:

xfn[e_] := e /. EllipticK[x_] EllipticE[y_] /; x + y == 1 :> 
    Pi/2 - (EllipticE[x] EllipticK[y] - EllipticK[x] EllipticK[y]);

 EllipticE[2/3] EllipticK[1/3] + (EllipticE[1/3] - EllipticK[1/3]) EllipticK[2/3], 
 TransformationFunctions -> {Automatic, xfn}]

(* π/2 *)


The reason the using $Assumptions does not work as it is used in the question is that the assumption is effectively about the symbol x. It will not be used as a general identity about elliptic integrals.

For instance, having the assumption in terms of x and the expression in terms of y results in no simplification:

Block[{$Assumptions = 
   EllipticK[x] EllipticE[1 - x] + EllipticE[x] EllipticK[1 - x] - 
     EllipticK[x] EllipticK[1 - x] == Pi/2}, 
 Simplify[EllipticK[y] EllipticE[1 - y] + 
   EllipticE[y] EllipticK[1 - y] - EllipticK[y] EllipticK[1 - y]]

(* EllipticE[y] EllipticK[1 - y] + (EllipticE[1 - y] - EllipticK[1 - y]) EllipticK[y] *)

If the xa are changed to ys, or vice versa, the output will be π/2.

share|improve this answer
Thank you! Suggested method indeed works. – Weather Report Apr 3 '13 at 9:35

Your Answer


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.