
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (cos im)))
double code(double re, double im) {
return exp(re) * cos(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * cos(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.cos(im);
}
def code(re, im): return math.exp(re) * math.cos(im)
function code(re, im) return Float64(exp(re) * cos(im)) end
function tmp = code(re, im) tmp = exp(re) * cos(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Cos[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \cos im
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (<= (exp re) 0.0) (exp re) (if (<= (exp re) 1.0) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 0.0) {
tmp = exp(re);
} else if (exp(re) <= 1.0) {
tmp = cos(im);
} else {
tmp = exp(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (exp(re) <= 0.0d0) then
tmp = exp(re)
else if (exp(re) <= 1.0d0) then
tmp = cos(im)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (Math.exp(re) <= 0.0) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 1.0) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 0.0: tmp = math.exp(re) elif math.exp(re) <= 1.0: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 0.0) tmp = exp(re); elseif (exp(re) <= 1.0) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 0.0) tmp = exp(re); elseif (exp(re) <= 1.0) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 0.0], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 0:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 1:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 0.0 or 1 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 93.6%
if 0.0 < (exp.f64 re) < 1Initial program 100.0%
Taylor expanded in re around 0 99.1%
Final simplification96.4%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.052) (and (not (<= re 0.0132)) (<= re 2e+100)))
(exp re)
(*
(cos im)
(+ (* (* re re) (+ (* re 0.16666666666666666) 0.5)) (+ re 1.0)))))
double code(double re, double im) {
double tmp;
if ((re <= -0.052) || (!(re <= 0.0132) && (re <= 2e+100))) {
tmp = exp(re);
} else {
tmp = cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.052d0)) .or. (.not. (re <= 0.0132d0)) .and. (re <= 2d+100)) then
tmp = exp(re)
else
tmp = cos(im) * (((re * re) * ((re * 0.16666666666666666d0) + 0.5d0)) + (re + 1.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.052) || (!(re <= 0.0132) && (re <= 2e+100))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.052) or (not (re <= 0.0132) and (re <= 2e+100)): tmp = math.exp(re) else: tmp = math.cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.052) || (!(re <= 0.0132) && (re <= 2e+100))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(Float64(re * re) * Float64(Float64(re * 0.16666666666666666) + 0.5)) + Float64(re + 1.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.052) || (~((re <= 0.0132)) && (re <= 2e+100))) tmp = exp(re); else tmp = cos(im) * (((re * re) * ((re * 0.16666666666666666) + 0.5)) + (re + 1.0)); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.052], And[N[Not[LessEqual[re, 0.0132]], $MachinePrecision], LessEqual[re, 2e+100]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(N[(re * re), $MachinePrecision] * N[(N[(re * 0.16666666666666666), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.052 \lor \neg \left(re \leq 0.0132\right) \land re \leq 2 \cdot 10^{+100}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re \cdot re\right) \cdot \left(re \cdot 0.16666666666666666 + 0.5\right) + \left(re + 1\right)\right)\\
\end{array}
\end{array}
if re < -0.0519999999999999976 or 0.0132 < re < 2.00000000000000003e100Initial program 100.0%
Taylor expanded in im around 0 98.8%
if -0.0519999999999999976 < re < 0.0132 or 2.00000000000000003e100 < re Initial program 100.0%
Taylor expanded in re around 0 99.2%
associate-+r+99.2%
+-commutative99.2%
associate-+r+99.2%
distribute-rgt1-in99.2%
*-commutative99.2%
associate-*r*99.2%
associate-*r*99.2%
distribute-rgt-out99.2%
distribute-lft-out99.2%
+-commutative99.2%
Simplified99.2%
Final simplification99.1%
(FPCore (re im) :precision binary64 (if (or (<= re -0.052) (and (not (<= re 0.0043)) (<= re 1.35e+154))) (exp re) (* (cos im) (+ 1.0 (+ re (* (* re re) 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.052) || (!(re <= 0.0043) && (re <= 1.35e+154))) {
tmp = exp(re);
} else {
tmp = cos(im) * (1.0 + (re + ((re * re) * 0.5)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((re <= (-0.052d0)) .or. (.not. (re <= 0.0043d0)) .and. (re <= 1.35d+154)) then
tmp = exp(re)
else
tmp = cos(im) * (1.0d0 + (re + ((re * re) * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.052) || (!(re <= 0.0043) && (re <= 1.35e+154))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re + ((re * re) * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.052) or (not (re <= 0.0043) and (re <= 1.35e+154)): tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re + ((re * re) * 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.052) || (!(re <= 0.0043) && (re <= 1.35e+154))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(1.0 + Float64(re + Float64(Float64(re * re) * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.052) || (~((re <= 0.0043)) && (re <= 1.35e+154))) tmp = exp(re); else tmp = cos(im) * (1.0 + (re + ((re * re) * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.052], And[N[Not[LessEqual[re, 0.0043]], $MachinePrecision], LessEqual[re, 1.35e+154]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re + N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.052 \lor \neg \left(re \leq 0.0043\right) \land re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + \left(re + \left(re \cdot re\right) \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.0519999999999999976 or 0.0043 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 97.9%
if -0.0519999999999999976 < re < 0.0043 or 1.35000000000000003e154 < re Initial program 100.0%
log1p-expm1-u_binary6499.9%
Applied rewrite-once99.9%
Taylor expanded in re around 0 99.6%
*-rgt-identity99.6%
+-commutative99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
distribute-lft-out99.6%
*-commutative99.6%
unpow299.6%
Simplified99.6%
Final simplification98.9%
(FPCore (re im)
:precision binary64
(if (<= re -0.06)
(exp re)
(if (<= re 0.004)
(* (cos im) (+ (* re (* re 0.5)) (+ re 1.0)))
(if (<= re 1.35e+154)
(exp re)
(* (cos im) (+ 1.0 (+ re (* (* re re) 0.5))))))))
double code(double re, double im) {
double tmp;
if (re <= -0.06) {
tmp = exp(re);
} else if (re <= 0.004) {
tmp = cos(im) * ((re * (re * 0.5)) + (re + 1.0));
} else if (re <= 1.35e+154) {
tmp = exp(re);
} else {
tmp = cos(im) * (1.0 + (re + ((re * re) * 0.5)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-0.06d0)) then
tmp = exp(re)
else if (re <= 0.004d0) then
tmp = cos(im) * ((re * (re * 0.5d0)) + (re + 1.0d0))
else if (re <= 1.35d+154) then
tmp = exp(re)
else
tmp = cos(im) * (1.0d0 + (re + ((re * re) * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.06) {
tmp = Math.exp(re);
} else if (re <= 0.004) {
tmp = Math.cos(im) * ((re * (re * 0.5)) + (re + 1.0));
} else if (re <= 1.35e+154) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (1.0 + (re + ((re * re) * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.06: tmp = math.exp(re) elif re <= 0.004: tmp = math.cos(im) * ((re * (re * 0.5)) + (re + 1.0)) elif re <= 1.35e+154: tmp = math.exp(re) else: tmp = math.cos(im) * (1.0 + (re + ((re * re) * 0.5))) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.06) tmp = exp(re); elseif (re <= 0.004) tmp = Float64(cos(im) * Float64(Float64(re * Float64(re * 0.5)) + Float64(re + 1.0))); elseif (re <= 1.35e+154) tmp = exp(re); else tmp = Float64(cos(im) * Float64(1.0 + Float64(re + Float64(Float64(re * re) * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.06) tmp = exp(re); elseif (re <= 0.004) tmp = cos(im) * ((re * (re * 0.5)) + (re + 1.0)); elseif (re <= 1.35e+154) tmp = exp(re); else tmp = cos(im) * (1.0 + (re + ((re * re) * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.06], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.004], N[(N[Cos[im], $MachinePrecision] * N[(N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision] + N[(re + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.35e+154], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(1.0 + N[(re + N[(N[(re * re), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.06:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.004:\\
\;\;\;\;\cos im \cdot \left(re \cdot \left(re \cdot 0.5\right) + \left(re + 1\right)\right)\\
\mathbf{elif}\;re \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(1 + \left(re + \left(re \cdot re\right) \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.059999999999999998 or 0.0040000000000000001 < re < 1.35000000000000003e154Initial program 100.0%
Taylor expanded in im around 0 97.9%
if -0.059999999999999998 < re < 0.0040000000000000001Initial program 100.0%
Taylor expanded in re around 0 99.6%
associate-+r+99.6%
+-commutative99.6%
associate-+r+99.6%
distribute-rgt1-in99.6%
*-commutative99.6%
associate-*r*99.6%
associate-*r*99.6%
distribute-rgt-out99.6%
distribute-lft-out99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in re around 0 99.5%
*-commutative99.5%
unpow299.5%
associate-*r*99.5%
Simplified99.5%
if 1.35000000000000003e154 < re Initial program 100.0%
log1p-expm1-u_binary64100.0%
Applied rewrite-once100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
+-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
distribute-lft-out100.0%
*-commutative100.0%
unpow2100.0%
Simplified100.0%
Final simplification98.9%
(FPCore (re im) :precision binary64 (if (<= re -0.052) (exp re) (if (<= re 0.00026) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.052) {
tmp = exp(re);
} else if (re <= 0.00026) {
tmp = cos(im) * (re + 1.0);
} else {
tmp = exp(re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-0.052d0)) then
tmp = exp(re)
else if (re <= 0.00026d0) then
tmp = cos(im) * (re + 1.0d0)
else
tmp = exp(re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -0.052) {
tmp = Math.exp(re);
} else if (re <= 0.00026) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.052: tmp = math.exp(re) elif re <= 0.00026: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.052) tmp = exp(re); elseif (re <= 0.00026) tmp = Float64(cos(im) * Float64(re + 1.0)); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -0.052) tmp = exp(re); elseif (re <= 0.00026) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.052], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.00026], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.052:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.00026:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -0.0519999999999999976 or 2.59999999999999977e-4 < re Initial program 100.0%
Taylor expanded in im around 0 94.2%
if -0.0519999999999999976 < re < 2.59999999999999977e-4Initial program 100.0%
Taylor expanded in re around 0 98.9%
distribute-rgt1-in98.9%
Simplified98.9%
Final simplification96.7%
(FPCore (re im)
:precision binary64
(if (<= re -8200.0)
(* im (* im -0.5))
(if (<= re 5.6e-7)
(cos im)
(+ (+ re 1.0) (/ (- 1.0 (* re re)) (/ (/ -2.0 im) im))))))
double code(double re, double im) {
double tmp;
if (re <= -8200.0) {
tmp = im * (im * -0.5);
} else if (re <= 5.6e-7) {
tmp = cos(im);
} else {
tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-8200.0d0)) then
tmp = im * (im * (-0.5d0))
else if (re <= 5.6d-7) then
tmp = cos(im)
else
tmp = (re + 1.0d0) + ((1.0d0 - (re * re)) / (((-2.0d0) / im) / im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -8200.0) {
tmp = im * (im * -0.5);
} else if (re <= 5.6e-7) {
tmp = Math.cos(im);
} else {
tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -8200.0: tmp = im * (im * -0.5) elif re <= 5.6e-7: tmp = math.cos(im) else: tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im)) return tmp
function code(re, im) tmp = 0.0 if (re <= -8200.0) tmp = Float64(im * Float64(im * -0.5)); elseif (re <= 5.6e-7) tmp = cos(im); else tmp = Float64(Float64(re + 1.0) + Float64(Float64(1.0 - Float64(re * re)) / Float64(Float64(-2.0 / im) / im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -8200.0) tmp = im * (im * -0.5); elseif (re <= 5.6e-7) tmp = cos(im); else tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -8200.0], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 5.6e-7], N[Cos[im], $MachinePrecision], N[(N[(re + 1.0), $MachinePrecision] + N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 / im), $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -8200:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{elif}\;re \leq 5.6 \cdot 10^{-7}:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;\left(re + 1\right) + \frac{1 - re \cdot re}{\frac{\frac{-2}{im}}{im}}\\
\end{array}
\end{array}
if re < -8200Initial program 100.0%
Taylor expanded in re around 0 2.3%
distribute-rgt1-in2.3%
Simplified2.3%
Taylor expanded in im around 0 2.0%
associate-+r+2.0%
unpow22.0%
Simplified2.0%
Taylor expanded in re around 0 2.1%
unpow22.1%
associate-*r*2.1%
*-commutative2.1%
*-commutative2.1%
*-commutative2.1%
Simplified2.1%
Taylor expanded in im around inf 32.1%
unpow232.1%
associate-*r*32.1%
*-commutative32.1%
Simplified32.1%
if -8200 < re < 5.60000000000000038e-7Initial program 100.0%
Taylor expanded in re around 0 97.6%
if 5.60000000000000038e-7 < re Initial program 100.0%
Taylor expanded in re around 0 10.2%
distribute-rgt1-in10.2%
Simplified10.2%
Taylor expanded in im around 0 18.2%
associate-+r+18.2%
unpow218.2%
Simplified18.2%
+-commutative18.2%
associate-*r*18.2%
+-commutative18.2%
flip-+16.7%
associate-*r/16.6%
*-commutative16.6%
metadata-eval16.6%
Applied egg-rr16.6%
associate-/l*16.7%
Simplified16.7%
Taylor expanded in re around 0 39.8%
unpow239.8%
associate-/r*39.8%
Simplified39.8%
Final simplification67.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* im (* im -0.5))))
(if (<= re -1.9e-8)
t_0
(if (<= re 3.4e-18)
(+ re 1.0)
(+ t_0 (/ (- 1.0 (* re re)) (- 1.0 re)))))))
double code(double re, double im) {
double t_0 = im * (im * -0.5);
double tmp;
if (re <= -1.9e-8) {
tmp = t_0;
} else if (re <= 3.4e-18) {
tmp = re + 1.0;
} else {
tmp = t_0 + ((1.0 - (re * re)) / (1.0 - re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = im * (im * (-0.5d0))
if (re <= (-1.9d-8)) then
tmp = t_0
else if (re <= 3.4d-18) then
tmp = re + 1.0d0
else
tmp = t_0 + ((1.0d0 - (re * re)) / (1.0d0 - re))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = im * (im * -0.5);
double tmp;
if (re <= -1.9e-8) {
tmp = t_0;
} else if (re <= 3.4e-18) {
tmp = re + 1.0;
} else {
tmp = t_0 + ((1.0 - (re * re)) / (1.0 - re));
}
return tmp;
}
def code(re, im): t_0 = im * (im * -0.5) tmp = 0 if re <= -1.9e-8: tmp = t_0 elif re <= 3.4e-18: tmp = re + 1.0 else: tmp = t_0 + ((1.0 - (re * re)) / (1.0 - re)) return tmp
function code(re, im) t_0 = Float64(im * Float64(im * -0.5)) tmp = 0.0 if (re <= -1.9e-8) tmp = t_0; elseif (re <= 3.4e-18) tmp = Float64(re + 1.0); else tmp = Float64(t_0 + Float64(Float64(1.0 - Float64(re * re)) / Float64(1.0 - re))); end return tmp end
function tmp_2 = code(re, im) t_0 = im * (im * -0.5); tmp = 0.0; if (re <= -1.9e-8) tmp = t_0; elseif (re <= 3.4e-18) tmp = re + 1.0; else tmp = t_0 + ((1.0 - (re * re)) / (1.0 - re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -1.9e-8], t$95$0, If[LessEqual[re, 3.4e-18], N[(re + 1.0), $MachinePrecision], N[(t$95$0 + N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(1.0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := im \cdot \left(im \cdot -0.5\right)\\
\mathbf{if}\;re \leq -1.9 \cdot 10^{-8}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;re \leq 3.4 \cdot 10^{-18}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;t_0 + \frac{1 - re \cdot re}{1 - re}\\
\end{array}
\end{array}
if re < -1.90000000000000014e-8Initial program 100.0%
Taylor expanded in re around 0 4.0%
distribute-rgt1-in4.0%
Simplified4.0%
Taylor expanded in im around 0 2.1%
associate-+r+2.1%
unpow22.1%
Simplified2.1%
Taylor expanded in re around 0 2.1%
unpow22.1%
associate-*r*2.1%
*-commutative2.1%
*-commutative2.1%
*-commutative2.1%
Simplified2.1%
Taylor expanded in im around inf 30.5%
unpow230.5%
associate-*r*30.5%
*-commutative30.5%
Simplified30.5%
if -1.90000000000000014e-8 < re < 3.40000000000000001e-18Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Taylor expanded in im around 0 51.7%
if 3.40000000000000001e-18 < re Initial program 100.0%
Taylor expanded in re around 0 11.9%
distribute-rgt1-in11.9%
Simplified11.9%
Taylor expanded in im around 0 18.0%
associate-+r+18.0%
unpow218.0%
Simplified18.0%
Taylor expanded in re around 0 14.4%
unpow214.4%
associate-*r*14.4%
*-commutative14.4%
*-commutative14.4%
*-commutative14.4%
Simplified14.4%
flip-+37.1%
metadata-eval37.1%
div-inv37.1%
fma-def37.1%
*-commutative37.1%
associate-*r*37.1%
Applied egg-rr37.1%
fma-udef37.1%
+-commutative37.1%
associate-*r*37.1%
*-commutative37.1%
associate-*r/37.1%
*-commutative37.1%
*-lft-identity37.1%
Simplified37.1%
Final simplification42.6%
(FPCore (re im)
:precision binary64
(if (<= re -1.9e-8)
(* im (* im -0.5))
(if (<= re 3.4e-18)
(+ re 1.0)
(+ (+ re 1.0) (/ (- 1.0 (* re re)) (/ (/ -2.0 im) im))))))
double code(double re, double im) {
double tmp;
if (re <= -1.9e-8) {
tmp = im * (im * -0.5);
} else if (re <= 3.4e-18) {
tmp = re + 1.0;
} else {
tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-1.9d-8)) then
tmp = im * (im * (-0.5d0))
else if (re <= 3.4d-18) then
tmp = re + 1.0d0
else
tmp = (re + 1.0d0) + ((1.0d0 - (re * re)) / (((-2.0d0) / im) / im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.9e-8) {
tmp = im * (im * -0.5);
} else if (re <= 3.4e-18) {
tmp = re + 1.0;
} else {
tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.9e-8: tmp = im * (im * -0.5) elif re <= 3.4e-18: tmp = re + 1.0 else: tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im)) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.9e-8) tmp = Float64(im * Float64(im * -0.5)); elseif (re <= 3.4e-18) tmp = Float64(re + 1.0); else tmp = Float64(Float64(re + 1.0) + Float64(Float64(1.0 - Float64(re * re)) / Float64(Float64(-2.0 / im) / im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.9e-8) tmp = im * (im * -0.5); elseif (re <= 3.4e-18) tmp = re + 1.0; else tmp = (re + 1.0) + ((1.0 - (re * re)) / ((-2.0 / im) / im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.9e-8], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.4e-18], N[(re + 1.0), $MachinePrecision], N[(N[(re + 1.0), $MachinePrecision] + N[(N[(1.0 - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(N[(-2.0 / im), $MachinePrecision] / im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.9 \cdot 10^{-8}:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{elif}\;re \leq 3.4 \cdot 10^{-18}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;\left(re + 1\right) + \frac{1 - re \cdot re}{\frac{\frac{-2}{im}}{im}}\\
\end{array}
\end{array}
if re < -1.90000000000000014e-8Initial program 100.0%
Taylor expanded in re around 0 4.0%
distribute-rgt1-in4.0%
Simplified4.0%
Taylor expanded in im around 0 2.1%
associate-+r+2.1%
unpow22.1%
Simplified2.1%
Taylor expanded in re around 0 2.1%
unpow22.1%
associate-*r*2.1%
*-commutative2.1%
*-commutative2.1%
*-commutative2.1%
Simplified2.1%
Taylor expanded in im around inf 30.5%
unpow230.5%
associate-*r*30.5%
*-commutative30.5%
Simplified30.5%
if -1.90000000000000014e-8 < re < 3.40000000000000001e-18Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Taylor expanded in im around 0 51.7%
if 3.40000000000000001e-18 < re Initial program 100.0%
Taylor expanded in re around 0 11.9%
distribute-rgt1-in11.9%
Simplified11.9%
Taylor expanded in im around 0 18.0%
associate-+r+18.0%
unpow218.0%
Simplified18.0%
+-commutative18.0%
associate-*r*18.0%
+-commutative18.0%
flip-+16.4%
associate-*r/16.4%
*-commutative16.4%
metadata-eval16.4%
Applied egg-rr16.4%
associate-/l*16.4%
Simplified16.4%
Taylor expanded in re around 0 39.1%
unpow239.1%
associate-/r*39.1%
Simplified39.1%
Final simplification43.0%
(FPCore (re im) :precision binary64 (if (<= re -1.9e-8) (* im (* im -0.5)) (if (<= re 3.4e-18) (+ re 1.0) (+ (+ re 1.0) (* -0.5 (* im (* re im)))))))
double code(double re, double im) {
double tmp;
if (re <= -1.9e-8) {
tmp = im * (im * -0.5);
} else if (re <= 3.4e-18) {
tmp = re + 1.0;
} else {
tmp = (re + 1.0) + (-0.5 * (im * (re * im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-1.9d-8)) then
tmp = im * (im * (-0.5d0))
else if (re <= 3.4d-18) then
tmp = re + 1.0d0
else
tmp = (re + 1.0d0) + ((-0.5d0) * (im * (re * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.9e-8) {
tmp = im * (im * -0.5);
} else if (re <= 3.4e-18) {
tmp = re + 1.0;
} else {
tmp = (re + 1.0) + (-0.5 * (im * (re * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.9e-8: tmp = im * (im * -0.5) elif re <= 3.4e-18: tmp = re + 1.0 else: tmp = (re + 1.0) + (-0.5 * (im * (re * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= -1.9e-8) tmp = Float64(im * Float64(im * -0.5)); elseif (re <= 3.4e-18) tmp = Float64(re + 1.0); else tmp = Float64(Float64(re + 1.0) + Float64(-0.5 * Float64(im * Float64(re * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.9e-8) tmp = im * (im * -0.5); elseif (re <= 3.4e-18) tmp = re + 1.0; else tmp = (re + 1.0) + (-0.5 * (im * (re * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.9e-8], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 3.4e-18], N[(re + 1.0), $MachinePrecision], N[(N[(re + 1.0), $MachinePrecision] + N[(-0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.9 \cdot 10^{-8}:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{elif}\;re \leq 3.4 \cdot 10^{-18}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;\left(re + 1\right) + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\
\end{array}
\end{array}
if re < -1.90000000000000014e-8Initial program 100.0%
Taylor expanded in re around 0 4.0%
distribute-rgt1-in4.0%
Simplified4.0%
Taylor expanded in im around 0 2.1%
associate-+r+2.1%
unpow22.1%
Simplified2.1%
Taylor expanded in re around 0 2.1%
unpow22.1%
associate-*r*2.1%
*-commutative2.1%
*-commutative2.1%
*-commutative2.1%
Simplified2.1%
Taylor expanded in im around inf 30.5%
unpow230.5%
associate-*r*30.5%
*-commutative30.5%
Simplified30.5%
if -1.90000000000000014e-8 < re < 3.40000000000000001e-18Initial program 100.0%
Taylor expanded in re around 0 100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Taylor expanded in im around 0 51.7%
if 3.40000000000000001e-18 < re Initial program 100.0%
Taylor expanded in re around 0 11.9%
distribute-rgt1-in11.9%
Simplified11.9%
Taylor expanded in im around 0 18.0%
associate-+r+18.0%
unpow218.0%
Simplified18.0%
Taylor expanded in re around inf 18.0%
*-commutative18.0%
unpow218.0%
associate-*r*18.0%
*-commutative18.0%
*-commutative18.0%
*-commutative18.0%
Simplified18.0%
Final simplification38.6%
(FPCore (re im) :precision binary64 (if (<= re -1.9e-8) (* im (* im -0.5)) (+ re 1.0)))
double code(double re, double im) {
double tmp;
if (re <= -1.9e-8) {
tmp = im * (im * -0.5);
} else {
tmp = re + 1.0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-1.9d-8)) then
tmp = im * (im * (-0.5d0))
else
tmp = re + 1.0d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -1.9e-8) {
tmp = im * (im * -0.5);
} else {
tmp = re + 1.0;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -1.9e-8: tmp = im * (im * -0.5) else: tmp = re + 1.0 return tmp
function code(re, im) tmp = 0.0 if (re <= -1.9e-8) tmp = Float64(im * Float64(im * -0.5)); else tmp = Float64(re + 1.0); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -1.9e-8) tmp = im * (im * -0.5); else tmp = re + 1.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -1.9e-8], N[(im * N[(im * -0.5), $MachinePrecision]), $MachinePrecision], N[(re + 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -1.9 \cdot 10^{-8}:\\
\;\;\;\;im \cdot \left(im \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;re + 1\\
\end{array}
\end{array}
if re < -1.90000000000000014e-8Initial program 100.0%
Taylor expanded in re around 0 4.0%
distribute-rgt1-in4.0%
Simplified4.0%
Taylor expanded in im around 0 2.1%
associate-+r+2.1%
unpow22.1%
Simplified2.1%
Taylor expanded in re around 0 2.1%
unpow22.1%
associate-*r*2.1%
*-commutative2.1%
*-commutative2.1%
*-commutative2.1%
Simplified2.1%
Taylor expanded in im around inf 30.5%
unpow230.5%
associate-*r*30.5%
*-commutative30.5%
Simplified30.5%
if -1.90000000000000014e-8 < re Initial program 100.0%
Taylor expanded in re around 0 74.3%
distribute-rgt1-in74.3%
Simplified74.3%
Taylor expanded in im around 0 39.0%
Final simplification36.5%
(FPCore (re im) :precision binary64 (+ re 1.0))
double code(double re, double im) {
return re + 1.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re + 1.0d0
end function
public static double code(double re, double im) {
return re + 1.0;
}
def code(re, im): return re + 1.0
function code(re, im) return Float64(re + 1.0) end
function tmp = code(re, im) tmp = re + 1.0; end
code[re_, im_] := N[(re + 1.0), $MachinePrecision]
\begin{array}{l}
\\
re + 1
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 54.0%
distribute-rgt1-in54.0%
Simplified54.0%
Taylor expanded in im around 0 28.4%
Final simplification28.4%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 54.0%
distribute-rgt1-in54.0%
Simplified54.0%
Taylor expanded in im around 0 27.7%
associate-+r+27.7%
unpow227.7%
Simplified27.7%
Taylor expanded in re around 0 27.0%
unpow227.0%
associate-*r*27.0%
*-commutative27.0%
*-commutative27.0%
*-commutative27.0%
Simplified27.0%
Taylor expanded in re around inf 3.7%
Final simplification3.7%
herbie shell --seed 2023297
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))