
(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 12 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 (<= re -200.0)
(exp re)
(if (<= re 2300.0)
(* (cos im) (+ (+ re 1.0) (* re (* re 0.5))))
(if (<= re 2.9e+77)
(exp re)
(*
(cos im)
(+
(+ re 1.0)
(/
(* (* re re) (- 0.25 (* (* re re) 0.027777777777777776)))
(+ 0.5 (* re -0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (re <= -200.0) {
tmp = exp(re);
} else if (re <= 2300.0) {
tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 2.9e+77) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + (((re * re) * (0.25 - ((re * re) * 0.027777777777777776))) / (0.5 + (re * -0.16666666666666666))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-200.0d0)) then
tmp = exp(re)
else if (re <= 2300.0d0) then
tmp = cos(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else if (re <= 2.9d+77) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + (((re * re) * (0.25d0 - ((re * re) * 0.027777777777777776d0))) / (0.5d0 + (re * (-0.16666666666666666d0)))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -200.0) {
tmp = Math.exp(re);
} else if (re <= 2300.0) {
tmp = Math.cos(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 2.9e+77) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + (((re * re) * (0.25 - ((re * re) * 0.027777777777777776))) / (0.5 + (re * -0.16666666666666666))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -200.0: tmp = math.exp(re) elif re <= 2300.0: tmp = math.cos(im) * ((re + 1.0) + (re * (re * 0.5))) elif re <= 2.9e+77: tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + (((re * re) * (0.25 - ((re * re) * 0.027777777777777776))) / (0.5 + (re * -0.16666666666666666)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); elseif (re <= 2.9e+77) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(Float64(Float64(re * re) * Float64(0.25 - Float64(Float64(re * re) * 0.027777777777777776))) / Float64(0.5 + Float64(re * -0.16666666666666666))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5))); elseif (re <= 2.9e+77) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + (((re * re) * (0.25 - ((re * re) * 0.027777777777777776))) / (0.5 + (re * -0.16666666666666666)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -200.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 2300.0], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.9e+77], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(N[(re * re), $MachinePrecision] * N[(0.25 - N[(N[(re * re), $MachinePrecision] * 0.027777777777777776), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.5 + N[(re * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -200:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 2300:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 2.9 \cdot 10^{+77}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \frac{\left(re \cdot re\right) \cdot \left(0.25 - \left(re \cdot re\right) \cdot 0.027777777777777776\right)}{0.5 + re \cdot -0.16666666666666666}\right)\\
\end{array}
\end{array}
if re < -200 or 2300 < re < 2.9000000000000002e77Initial program 100.0%
Taylor expanded in im around 0 95.9%
if -200 < re < 2300Initial program 100.0%
Taylor expanded in re around 0 97.7%
*-commutative97.7%
associate-*r*97.7%
*-commutative97.7%
distribute-lft1-in97.7%
distribute-rgt-out97.7%
+-commutative97.7%
*-commutative97.7%
unpow297.7%
associate-*l*97.7%
Simplified97.7%
if 2.9000000000000002e77 < re Initial program 100.0%
Taylor expanded in re around 0 89.7%
associate-+r+89.7%
*-commutative89.7%
associate-*r*89.7%
*-commutative89.7%
associate-*r*89.7%
distribute-rgt-out89.7%
*-commutative89.7%
*-commutative89.7%
distribute-lft1-in89.7%
distribute-rgt-out89.7%
+-commutative89.7%
cube-mult89.7%
unpow289.7%
associate-*r*89.7%
Simplified89.7%
*-commutative89.7%
flip-+89.7%
associate-*l/100.0%
metadata-eval100.0%
swap-sqr100.0%
metadata-eval100.0%
*-commutative100.0%
cancel-sign-sub-inv100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Final simplification97.3%
(FPCore (re im)
:precision binary64
(if (<= re -200.0)
(exp re)
(if (<= re 2300.0)
(* (cos im) (+ (+ re 1.0) (* re (* re 0.5))))
(if (<= re 1.05e+103)
(exp re)
(*
(cos im)
(+ (+ re 1.0) (* (* re re) (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (re <= -200.0) {
tmp = exp(re);
} else if (re <= 2300.0) {
tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.05e+103) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= (-200.0d0)) then
tmp = exp(re)
else if (re <= 2300.0d0) then
tmp = cos(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
else if (re <= 1.05d+103) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + ((re * re) * (0.5d0 + (re * 0.16666666666666666d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -200.0) {
tmp = Math.exp(re);
} else if (re <= 2300.0) {
tmp = Math.cos(im) * ((re + 1.0) + (re * (re * 0.5)));
} else if (re <= 1.05e+103) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -200.0: tmp = math.exp(re) elif re <= 2300.0: tmp = math.cos(im) * ((re + 1.0) + (re * (re * 0.5))) elif re <= 1.05e+103: tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))) return tmp
function code(re, im) tmp = 0.0 if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); elseif (re <= 1.05e+103) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(Float64(re * re) * Float64(0.5 + Float64(re * 0.16666666666666666))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5))); elseif (re <= 1.05e+103) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + ((re * re) * (0.5 + (re * 0.16666666666666666)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -200.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 2300.0], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.05e+103], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(N[(re * re), $MachinePrecision] * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -200:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 2300:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\mathbf{elif}\;re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + \left(re \cdot re\right) \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\\
\end{array}
\end{array}
if re < -200 or 2300 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 96.0%
if -200 < re < 2300Initial program 100.0%
Taylor expanded in re around 0 97.7%
*-commutative97.7%
associate-*r*97.7%
*-commutative97.7%
distribute-lft1-in97.7%
distribute-rgt-out97.7%
+-commutative97.7%
*-commutative97.7%
unpow297.7%
associate-*l*97.7%
Simplified97.7%
if 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
associate-+r+100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
*-commutative100.0%
*-commutative100.0%
distribute-lft1-in100.0%
distribute-rgt-out100.0%
+-commutative100.0%
cube-mult100.0%
unpow2100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification97.3%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* re 0.5))))
(if (<= re -200.0)
(exp re)
(if (<= re 2300.0)
(* (cos im) (+ (+ re 1.0) t_0))
(if (<= re 1.9e+154) (exp re) (* (cos im) t_0))))))
double code(double re, double im) {
double t_0 = re * (re * 0.5);
double tmp;
if (re <= -200.0) {
tmp = exp(re);
} else if (re <= 2300.0) {
tmp = cos(im) * ((re + 1.0) + t_0);
} else if (re <= 1.9e+154) {
tmp = exp(re);
} else {
tmp = cos(im) * t_0;
}
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 = re * (re * 0.5d0)
if (re <= (-200.0d0)) then
tmp = exp(re)
else if (re <= 2300.0d0) then
tmp = cos(im) * ((re + 1.0d0) + t_0)
else if (re <= 1.9d+154) then
tmp = exp(re)
else
tmp = cos(im) * t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (re * 0.5);
double tmp;
if (re <= -200.0) {
tmp = Math.exp(re);
} else if (re <= 2300.0) {
tmp = Math.cos(im) * ((re + 1.0) + t_0);
} else if (re <= 1.9e+154) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * t_0;
}
return tmp;
}
def code(re, im): t_0 = re * (re * 0.5) tmp = 0 if re <= -200.0: tmp = math.exp(re) elif re <= 2300.0: tmp = math.cos(im) * ((re + 1.0) + t_0) elif re <= 1.9e+154: tmp = math.exp(re) else: tmp = math.cos(im) * t_0 return tmp
function code(re, im) t_0 = Float64(re * Float64(re * 0.5)) tmp = 0.0 if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + t_0)); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = Float64(cos(im) * t_0); end return tmp end
function tmp_2 = code(re, im) t_0 = re * (re * 0.5); tmp = 0.0; if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = cos(im) * ((re + 1.0) + t_0); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = cos(im) * t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[re, -200.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 2300.0], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.9e+154], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * t$95$0), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(re \cdot 0.5\right)\\
\mathbf{if}\;re \leq -200:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 2300:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + t_0\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot t_0\\
\end{array}
\end{array}
if re < -200 or 2300 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 94.5%
if -200 < re < 2300Initial program 100.0%
Taylor expanded in re around 0 97.7%
*-commutative97.7%
associate-*r*97.7%
*-commutative97.7%
distribute-lft1-in97.7%
distribute-rgt-out97.7%
+-commutative97.7%
*-commutative97.7%
unpow297.7%
associate-*l*97.7%
Simplified97.7%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
distribute-lft1-in100.0%
distribute-rgt-out100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification96.6%
(FPCore (re im)
:precision binary64
(if (<= re -3.7e-5)
(exp re)
(if (<= re 2300.0)
(* (cos im) (+ re 1.0))
(if (<= re 1.9e+154) (exp re) (* (cos im) (* re (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if (re <= -3.7e-5) {
tmp = exp(re);
} else if (re <= 2300.0) {
tmp = cos(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
tmp = exp(re);
} else {
tmp = cos(im) * (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 <= (-3.7d-5)) then
tmp = exp(re)
else if (re <= 2300.0d0) then
tmp = cos(im) * (re + 1.0d0)
else if (re <= 1.9d+154) then
tmp = exp(re)
else
tmp = cos(im) * (re * (re * 0.5d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= -3.7e-5) {
tmp = Math.exp(re);
} else if (re <= 2300.0) {
tmp = Math.cos(im) * (re + 1.0);
} else if (re <= 1.9e+154) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * (re * (re * 0.5));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -3.7e-5: tmp = math.exp(re) elif re <= 2300.0: tmp = math.cos(im) * (re + 1.0) elif re <= 1.9e+154: tmp = math.exp(re) else: tmp = math.cos(im) * (re * (re * 0.5)) return tmp
function code(re, im) tmp = 0.0 if (re <= -3.7e-5) tmp = exp(re); elseif (re <= 2300.0) tmp = Float64(cos(im) * Float64(re + 1.0)); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = Float64(cos(im) * Float64(re * Float64(re * 0.5))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -3.7e-5) tmp = exp(re); elseif (re <= 2300.0) tmp = cos(im) * (re + 1.0); elseif (re <= 1.9e+154) tmp = exp(re); else tmp = cos(im) * (re * (re * 0.5)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -3.7e-5], N[Exp[re], $MachinePrecision], If[LessEqual[re, 2300.0], N[(N[Cos[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 1.9e+154], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -3.7 \cdot 10^{-5}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 2300:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -3.69999999999999981e-5 or 2300 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 93.7%
if -3.69999999999999981e-5 < re < 2300Initial program 100.0%
Taylor expanded in re around 0 98.5%
*-rgt-identity98.5%
distribute-lft-in98.5%
Simplified98.5%
if 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
associate-*r*100.0%
*-commutative100.0%
distribute-lft1-in100.0%
distribute-rgt-out100.0%
+-commutative100.0%
*-commutative100.0%
unpow2100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
*-commutative100.0%
unpow2100.0%
associate-*r*100.0%
associate-*r*100.0%
Simplified100.0%
Final simplification96.5%
(FPCore (re im) :precision binary64 (if (<= re -0.000125) (exp re) (if (<= re 2300.0) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -0.000125) {
tmp = exp(re);
} else if (re <= 2300.0) {
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.000125d0)) then
tmp = exp(re)
else if (re <= 2300.0d0) 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.000125) {
tmp = Math.exp(re);
} else if (re <= 2300.0) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -0.000125: tmp = math.exp(re) elif re <= 2300.0: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -0.000125) tmp = exp(re); elseif (re <= 2300.0) 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.000125) tmp = exp(re); elseif (re <= 2300.0) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -0.000125], N[Exp[re], $MachinePrecision], If[LessEqual[re, 2300.0], 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.000125:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 2300:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -1.25e-4 or 2300 < re Initial program 100.0%
Taylor expanded in im around 0 91.1%
if -1.25e-4 < re < 2300Initial program 100.0%
Taylor expanded in re around 0 98.5%
*-rgt-identity98.5%
distribute-lft-in98.5%
Simplified98.5%
Final simplification94.6%
(FPCore (re im) :precision binary64 (if (<= re -200.0) (exp re) (if (<= re 2300.0) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -200.0) {
tmp = exp(re);
} else if (re <= 2300.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 (re <= (-200.0d0)) then
tmp = exp(re)
else if (re <= 2300.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 (re <= -200.0) {
tmp = Math.exp(re);
} else if (re <= 2300.0) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -200.0: tmp = math.exp(re) elif re <= 2300.0: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= -200.0) tmp = exp(re); elseif (re <= 2300.0) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -200.0], N[Exp[re], $MachinePrecision], If[LessEqual[re, 2300.0], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -200:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 2300:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -200 or 2300 < re Initial program 100.0%
Taylor expanded in im around 0 91.7%
if -200 < re < 2300Initial program 100.0%
Taylor expanded in re around 0 97.2%
Final simplification94.3%
(FPCore (re im) :precision binary64 (if (<= re 600.0) (cos im) (* (* re re) (+ 0.5 (* im (* im -0.25))))))
double code(double re, double im) {
double tmp;
if (re <= 600.0) {
tmp = cos(im);
} else {
tmp = (re * re) * (0.5 + (im * (im * -0.25)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 600.0d0) then
tmp = cos(im)
else
tmp = (re * re) * (0.5d0 + (im * (im * (-0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 600.0) {
tmp = Math.cos(im);
} else {
tmp = (re * re) * (0.5 + (im * (im * -0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 600.0: tmp = math.cos(im) else: tmp = (re * re) * (0.5 + (im * (im * -0.25))) return tmp
function code(re, im) tmp = 0.0 if (re <= 600.0) tmp = cos(im); else tmp = Float64(Float64(re * re) * Float64(0.5 + Float64(im * Float64(im * -0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 600.0) tmp = cos(im); else tmp = (re * re) * (0.5 + (im * (im * -0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 600.0], N[Cos[im], $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(0.5 + N[(im * N[(im * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 600:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(0.5 + im \cdot \left(im \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if re < 600Initial program 100.0%
Taylor expanded in re around 0 61.6%
if 600 < re Initial program 100.0%
Taylor expanded in re around 0 42.7%
*-commutative42.7%
associate-*r*42.7%
*-commutative42.7%
distribute-lft1-in42.7%
distribute-rgt-out42.7%
+-commutative42.7%
*-commutative42.7%
unpow242.7%
associate-*l*42.7%
Simplified42.7%
Taylor expanded in re around inf 42.7%
*-commutative42.7%
unpow242.7%
associate-*r*42.7%
associate-*r*42.7%
Simplified42.7%
Taylor expanded in im around 0 10.8%
unpow210.8%
*-commutative10.8%
associate-*r*10.8%
fma-def19.4%
*-commutative19.4%
unpow219.4%
unpow219.4%
associate-*l*19.4%
Simplified19.4%
Taylor expanded in re around 0 43.6%
unpow243.6%
*-commutative43.6%
unpow243.6%
*-commutative43.6%
associate-*r*43.6%
Simplified43.6%
Final simplification57.5%
(FPCore (re im) :precision binary64 (if (<= re 5.4) (+ re 1.0) (* (* re re) (+ 0.5 (* im (* im -0.25))))))
double code(double re, double im) {
double tmp;
if (re <= 5.4) {
tmp = re + 1.0;
} else {
tmp = (re * re) * (0.5 + (im * (im * -0.25)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 5.4d0) then
tmp = re + 1.0d0
else
tmp = (re * re) * (0.5d0 + (im * (im * (-0.25d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 5.4) {
tmp = re + 1.0;
} else {
tmp = (re * re) * (0.5 + (im * (im * -0.25)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 5.4: tmp = re + 1.0 else: tmp = (re * re) * (0.5 + (im * (im * -0.25))) return tmp
function code(re, im) tmp = 0.0 if (re <= 5.4) tmp = Float64(re + 1.0); else tmp = Float64(Float64(re * re) * Float64(0.5 + Float64(im * Float64(im * -0.25)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 5.4) tmp = re + 1.0; else tmp = (re * re) * (0.5 + (im * (im * -0.25))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 5.4], N[(re + 1.0), $MachinePrecision], N[(N[(re * re), $MachinePrecision] * N[(0.5 + N[(im * N[(im * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 5.4:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot re\right) \cdot \left(0.5 + im \cdot \left(im \cdot -0.25\right)\right)\\
\end{array}
\end{array}
if re < 5.4000000000000004Initial program 100.0%
Taylor expanded in re around 0 61.8%
*-rgt-identity61.8%
distribute-lft-in61.8%
Simplified61.8%
Taylor expanded in im around 0 39.5%
if 5.4000000000000004 < re Initial program 100.0%
Taylor expanded in re around 0 42.2%
*-commutative42.2%
associate-*r*42.2%
*-commutative42.2%
distribute-lft1-in42.2%
distribute-rgt-out42.2%
+-commutative42.2%
*-commutative42.2%
unpow242.2%
associate-*l*42.2%
Simplified42.2%
Taylor expanded in re around inf 42.2%
*-commutative42.2%
unpow242.2%
associate-*r*42.2%
associate-*r*42.2%
Simplified42.2%
Taylor expanded in im around 0 10.8%
unpow210.8%
*-commutative10.8%
associate-*r*10.8%
fma-def19.2%
*-commutative19.2%
unpow219.2%
unpow219.2%
associate-*l*19.2%
Simplified19.2%
Taylor expanded in re around 0 43.0%
unpow243.0%
*-commutative43.0%
unpow243.0%
*-commutative43.0%
associate-*r*43.0%
Simplified43.0%
Final simplification40.3%
(FPCore (re im) :precision binary64 (if (<= re 2.6e-102) (+ re 1.0) (+ 1.0 (+ re (* -0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (re <= 2.6e-102) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (re + (-0.5 * (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 <= 2.6d-102) then
tmp = re + 1.0d0
else
tmp = 1.0d0 + (re + ((-0.5d0) * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.6e-102) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (re + (-0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.6e-102: tmp = re + 1.0 else: tmp = 1.0 + (re + (-0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= 2.6e-102) tmp = Float64(re + 1.0); else tmp = Float64(1.0 + Float64(re + Float64(-0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.6e-102) tmp = re + 1.0; else tmp = 1.0 + (re + (-0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.6e-102], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(re + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.6 \cdot 10^{-102}:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + \left(re + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 2.59999999999999986e-102Initial program 100.0%
Taylor expanded in re around 0 58.6%
*-rgt-identity58.6%
distribute-lft-in58.6%
Simplified58.6%
Taylor expanded in im around 0 36.6%
if 2.59999999999999986e-102 < re Initial program 100.0%
Taylor expanded in re around 0 24.4%
*-rgt-identity24.4%
distribute-lft-in24.4%
Simplified24.4%
Taylor expanded in im around 0 31.9%
+-commutative31.9%
*-commutative31.9%
unpow231.9%
+-commutative31.9%
Simplified31.9%
Taylor expanded in re around 0 32.0%
unpow232.0%
Simplified32.0%
Final simplification35.3%
(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 48.7%
*-rgt-identity48.7%
distribute-lft-in48.7%
Simplified48.7%
Taylor expanded in im around 0 31.3%
Final simplification31.3%
(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 48.7%
*-rgt-identity48.7%
distribute-lft-in48.7%
Simplified48.7%
Taylor expanded in re around inf 3.6%
Taylor expanded in im around 0 3.4%
Final simplification3.4%
herbie shell --seed 2023238
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))