public static Function Abs(ComplexFunction z)
 {
     return Function.Sqrt(z.re * z.re + z.im * z.im);
 }
 public static Function Arg(ComplexFunction z)
 {
     // Use Complex.Arg through the inner class defined below.
     return new ArgFunction(z);
 }
 public ReSqrtFunction(ComplexFunction z)
 {
     this.z = z;
 }
 public void Update(ComplexFunction z05)
 {
     this.z05 = z05;
 }
 public ArgFunction(ComplexFunction z)
 {
     this.z = z;
 }
 static ComplexFunction()
 {
     I = new ComplexFunction(0.0, 1.0);
 }
 public static ComplexFunction Sqr(ComplexFunction z)
 {
     return new ComplexFunction(z.re * z.re - z.im * z.im, 2.0 * z.re * z.im);
 }
 public static ComplexFunction Sqrt(ComplexFunction z)
 {
     ReSqrtFunction re = new ReSqrtFunction(z);
     ImSqrtFunction im = new ImSqrtFunction(z);
     ComplexFunction z05 = new ComplexFunction(re, im);
     re.Update(z05);
     im.Update(z05);
     return z05;
 }
 public static Function Re(ComplexFunction z)
 {
     return z.re;
 }
 public static ComplexFunction Log(ComplexFunction z)
 {
     return new ComplexFunction(0.5 * Function.Log(z.re * z.re + z.im * z.im), Arg(z));
 }
 public static Function Im(ComplexFunction z)
 {
     return z.im;
 }
 public static ComplexFunction Exp(ComplexFunction z)
 {
     Function c = Function.Exp(z.re);
     return new ComplexFunction(c * Function.Cos(z.im), c * Function.Sin(z.im));
 }
 public static ComplexFunction Conjugate(ComplexFunction z)
 {
     return new ComplexFunction(z.re, -z.im);
 }