
(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 11 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) 1.0) (exp re) (if (<= (exp re) 2.0) (cos im) (exp re))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 1.0) {
tmp = exp(re);
} else if (exp(re) <= 2.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) <= 1.0d0) then
tmp = exp(re)
else if (exp(re) <= 2.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) <= 1.0) {
tmp = Math.exp(re);
} else if (Math.exp(re) <= 2.0) {
tmp = Math.cos(im);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if math.exp(re) <= 1.0: tmp = math.exp(re) elif math.exp(re) <= 2.0: tmp = math.cos(im) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (exp(re) <= 1.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = exp(re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (exp(re) <= 1.0) tmp = exp(re); elseif (exp(re) <= 2.0) tmp = cos(im); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[N[Exp[re], $MachinePrecision], 1.0], N[Exp[re], $MachinePrecision], If[LessEqual[N[Exp[re], $MachinePrecision], 2.0], N[Cos[im], $MachinePrecision], N[Exp[re], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;e^{re} \leq 1:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;e^{re} \leq 2:\\
\;\;\;\;\cos im\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if (exp.f64 re) < 1 or 2 < (exp.f64 re) Initial program 100.0%
Taylor expanded in im around 0 67.3%
if 1 < (exp.f64 re) < 2Initial program 98.4%
Taylor expanded in re around 0 89.3%
Final simplification67.4%
(FPCore (re im)
:precision binary64
(if (<= (exp re) 5e-83)
(exp re)
(*
(cos im)
(+ (+ re 1.0) (* (* re re) (+ 0.5 (* re 0.16666666666666666)))))))
double code(double re, double im) {
double tmp;
if (exp(re) <= 5e-83) {
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 (exp(re) <= 5d-83) 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 (Math.exp(re) <= 5e-83) {
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 math.exp(re) <= 5e-83: 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 (exp(re) <= 5e-83) 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 (exp(re) <= 5e-83) 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[N[Exp[re], $MachinePrecision], 5e-83], 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}\;e^{re} \leq 5 \cdot 10^{-83}:\\
\;\;\;\;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 (exp.f64 re) < 5e-83Initial program 100.0%
Taylor expanded in im around 0 98.9%
if 5e-83 < (exp.f64 re) Initial program 100.0%
Taylor expanded in re around 0 91.8%
associate-+r+91.8%
*-commutative91.8%
associate-*r*91.8%
*-commutative91.8%
associate-*r*91.8%
distribute-rgt-out91.8%
*-commutative91.8%
*-commutative91.8%
distribute-lft1-in91.8%
distribute-rgt-out91.8%
+-commutative91.8%
cube-mult91.8%
unpow291.8%
associate-*r*91.8%
Simplified91.8%
Final simplification93.7%
(FPCore (re im) :precision binary64 (if (or (<= re -0.038) (and (not (<= re 0.04)) (<= re 1.9e+154))) (exp re) (* (cos im) (+ (+ re 1.0) (* re (* re 0.5))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.038) || (!(re <= 0.04) && (re <= 1.9e+154))) {
tmp = exp(re);
} else {
tmp = cos(im) * ((re + 1.0) + (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.038d0)) .or. (.not. (re <= 0.04d0)) .and. (re <= 1.9d+154)) then
tmp = exp(re)
else
tmp = cos(im) * ((re + 1.0d0) + (re * (re * 0.5d0)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.038) || (!(re <= 0.04) && (re <= 1.9e+154))) {
tmp = Math.exp(re);
} else {
tmp = Math.cos(im) * ((re + 1.0) + (re * (re * 0.5)));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.038) or (not (re <= 0.04) and (re <= 1.9e+154)): tmp = math.exp(re) else: tmp = math.cos(im) * ((re + 1.0) + (re * (re * 0.5))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.038) || (!(re <= 0.04) && (re <= 1.9e+154))) tmp = exp(re); else tmp = Float64(cos(im) * Float64(Float64(re + 1.0) + Float64(re * Float64(re * 0.5)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.038) || (~((re <= 0.04)) && (re <= 1.9e+154))) tmp = exp(re); else tmp = cos(im) * ((re + 1.0) + (re * (re * 0.5))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.038], And[N[Not[LessEqual[re, 0.04]], $MachinePrecision], LessEqual[re, 1.9e+154]]], N[Exp[re], $MachinePrecision], N[(N[Cos[im], $MachinePrecision] * N[(N[(re + 1.0), $MachinePrecision] + N[(re * N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.038 \lor \neg \left(re \leq 0.04\right) \land re \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;e^{re}\\
\mathbf{else}:\\
\;\;\;\;\cos im \cdot \left(\left(re + 1\right) + re \cdot \left(re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.0379999999999999991 or 0.0400000000000000008 < re < 1.8999999999999999e154Initial program 100.0%
Taylor expanded in im around 0 89.6%
if -0.0379999999999999991 < re < 0.0400000000000000008 or 1.8999999999999999e154 < re Initial program 100.0%
Taylor expanded in re around 0 99.6%
*-commutative99.6%
associate-*r*99.6%
*-commutative99.6%
distribute-lft1-in99.6%
distribute-rgt-out99.6%
+-commutative99.6%
*-commutative99.6%
unpow299.6%
associate-*l*99.6%
Simplified99.6%
Final simplification95.7%
(FPCore (re im) :precision binary64 (if (<= re -2.25e-6) (exp re) (if (<= re 0.01) (* (cos im) (+ re 1.0)) (exp re))))
double code(double re, double im) {
double tmp;
if (re <= -2.25e-6) {
tmp = exp(re);
} else if (re <= 0.01) {
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 <= (-2.25d-6)) then
tmp = exp(re)
else if (re <= 0.01d0) 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 <= -2.25e-6) {
tmp = Math.exp(re);
} else if (re <= 0.01) {
tmp = Math.cos(im) * (re + 1.0);
} else {
tmp = Math.exp(re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= -2.25e-6: tmp = math.exp(re) elif re <= 0.01: tmp = math.cos(im) * (re + 1.0) else: tmp = math.exp(re) return tmp
function code(re, im) tmp = 0.0 if (re <= -2.25e-6) tmp = exp(re); elseif (re <= 0.01) 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 <= -2.25e-6) tmp = exp(re); elseif (re <= 0.01) tmp = cos(im) * (re + 1.0); else tmp = exp(re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, -2.25e-6], N[Exp[re], $MachinePrecision], If[LessEqual[re, 0.01], 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 -2.25 \cdot 10^{-6}:\\
\;\;\;\;e^{re}\\
\mathbf{elif}\;re \leq 0.01:\\
\;\;\;\;\cos im \cdot \left(re + 1\right)\\
\mathbf{else}:\\
\;\;\;\;e^{re}\\
\end{array}
\end{array}
if re < -2.25000000000000006e-6 or 0.0100000000000000002 < re Initial program 100.0%
Taylor expanded in im around 0 87.5%
if -2.25000000000000006e-6 < re < 0.0100000000000000002Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-rgt-identity100.0%
distribute-lft-in100.0%
Simplified100.0%
Final simplification93.6%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* -0.5 (* im im))) (t_1 (* re t_0)))
(if (<= re 5.6e+51)
(cos im)
(if (<= re 2.3e+144)
(+ 1.0 (* re (+ 1.0 t_0)))
(+ 1.0 (/ (- (* t_1 t_1) (* re re)) (- t_1 re)))))))
double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double t_1 = re * t_0;
double tmp;
if (re <= 5.6e+51) {
tmp = cos(im);
} else if (re <= 2.3e+144) {
tmp = 1.0 + (re * (1.0 + t_0));
} else {
tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - 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) :: t_1
real(8) :: tmp
t_0 = (-0.5d0) * (im * im)
t_1 = re * t_0
if (re <= 5.6d+51) then
tmp = cos(im)
else if (re <= 2.3d+144) then
tmp = 1.0d0 + (re * (1.0d0 + t_0))
else
tmp = 1.0d0 + (((t_1 * t_1) - (re * re)) / (t_1 - re))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = -0.5 * (im * im);
double t_1 = re * t_0;
double tmp;
if (re <= 5.6e+51) {
tmp = Math.cos(im);
} else if (re <= 2.3e+144) {
tmp = 1.0 + (re * (1.0 + t_0));
} else {
tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - re));
}
return tmp;
}
def code(re, im): t_0 = -0.5 * (im * im) t_1 = re * t_0 tmp = 0 if re <= 5.6e+51: tmp = math.cos(im) elif re <= 2.3e+144: tmp = 1.0 + (re * (1.0 + t_0)) else: tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - re)) return tmp
function code(re, im) t_0 = Float64(-0.5 * Float64(im * im)) t_1 = Float64(re * t_0) tmp = 0.0 if (re <= 5.6e+51) tmp = cos(im); elseif (re <= 2.3e+144) tmp = Float64(1.0 + Float64(re * Float64(1.0 + t_0))); else tmp = Float64(1.0 + Float64(Float64(Float64(t_1 * t_1) - Float64(re * re)) / Float64(t_1 - re))); end return tmp end
function tmp_2 = code(re, im) t_0 = -0.5 * (im * im); t_1 = re * t_0; tmp = 0.0; if (re <= 5.6e+51) tmp = cos(im); elseif (re <= 2.3e+144) tmp = 1.0 + (re * (1.0 + t_0)); else tmp = 1.0 + (((t_1 * t_1) - (re * re)) / (t_1 - re)); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(re * t$95$0), $MachinePrecision]}, If[LessEqual[re, 5.6e+51], N[Cos[im], $MachinePrecision], If[LessEqual[re, 2.3e+144], N[(1.0 + N[(re * N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$1 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(im \cdot im\right)\\
t_1 := re \cdot t_0\\
\mathbf{if}\;re \leq 5.6 \cdot 10^{+51}:\\
\;\;\;\;\cos im\\
\mathbf{elif}\;re \leq 2.3 \cdot 10^{+144}:\\
\;\;\;\;1 + re \cdot \left(1 + t_0\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{t_1 \cdot t_1 - re \cdot re}{t_1 - re}\\
\end{array}
\end{array}
if re < 5.60000000000000009e51Initial program 100.0%
Taylor expanded in re around 0 63.0%
if 5.60000000000000009e51 < re < 2.3000000000000001e144Initial program 100.0%
Taylor expanded in re around 0 4.1%
*-rgt-identity4.1%
distribute-lft-in4.1%
Simplified4.1%
Taylor expanded in im around 0 26.7%
+-commutative26.7%
*-commutative26.7%
unpow226.7%
Simplified26.7%
Taylor expanded in re around inf 26.7%
*-commutative26.7%
+-commutative26.7%
unpow226.7%
Simplified26.7%
if 2.3000000000000001e144 < re Initial program 100.0%
Taylor expanded in re around 0 6.4%
*-rgt-identity6.4%
distribute-lft-in6.4%
Simplified6.4%
Taylor expanded in im around 0 21.7%
+-commutative21.7%
*-commutative21.7%
unpow221.7%
Simplified21.7%
Taylor expanded in re around inf 21.7%
*-commutative21.7%
+-commutative21.7%
unpow221.7%
Simplified21.7%
distribute-lft-in21.7%
*-rgt-identity21.7%
flip-+46.6%
Applied egg-rr46.6%
Final simplification57.8%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* re (* -0.5 (* im im)))))
(if (<= im 3.9e+40)
(+ 1.0 (/ (- (* t_0 t_0) (* re re)) (- t_0 re)))
(+ 1.0 (* -0.5 (* im (* re im)))))))
double code(double re, double im) {
double t_0 = re * (-0.5 * (im * im));
double tmp;
if (im <= 3.9e+40) {
tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re));
} else {
tmp = 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) :: t_0
real(8) :: tmp
t_0 = re * ((-0.5d0) * (im * im))
if (im <= 3.9d+40) then
tmp = 1.0d0 + (((t_0 * t_0) - (re * re)) / (t_0 - re))
else
tmp = 1.0d0 + ((-0.5d0) * (im * (re * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = re * (-0.5 * (im * im));
double tmp;
if (im <= 3.9e+40) {
tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re));
} else {
tmp = 1.0 + (-0.5 * (im * (re * im)));
}
return tmp;
}
def code(re, im): t_0 = re * (-0.5 * (im * im)) tmp = 0 if im <= 3.9e+40: tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re)) else: tmp = 1.0 + (-0.5 * (im * (re * im))) return tmp
function code(re, im) t_0 = Float64(re * Float64(-0.5 * Float64(im * im))) tmp = 0.0 if (im <= 3.9e+40) tmp = Float64(1.0 + Float64(Float64(Float64(t_0 * t_0) - Float64(re * re)) / Float64(t_0 - re))); else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * Float64(re * im)))); end return tmp end
function tmp_2 = code(re, im) t_0 = re * (-0.5 * (im * im)); tmp = 0.0; if (im <= 3.9e+40) tmp = 1.0 + (((t_0 * t_0) - (re * re)) / (t_0 - re)); else tmp = 1.0 + (-0.5 * (im * (re * im))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(re * N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 3.9e+40], N[(1.0 + N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] - N[(re * re), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := re \cdot \left(-0.5 \cdot \left(im \cdot im\right)\right)\\
\mathbf{if}\;im \leq 3.9 \cdot 10^{+40}:\\
\;\;\;\;1 + \frac{t_0 \cdot t_0 - re \cdot re}{t_0 - re}\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 3.9000000000000001e40Initial program 100.0%
Taylor expanded in re around 0 53.2%
*-rgt-identity53.2%
distribute-lft-in53.1%
Simplified53.1%
Taylor expanded in im around 0 31.8%
+-commutative31.8%
*-commutative31.8%
unpow231.8%
Simplified31.8%
Taylor expanded in re around inf 33.2%
*-commutative33.2%
+-commutative33.2%
unpow233.2%
Simplified33.2%
distribute-lft-in33.2%
*-rgt-identity33.2%
flip-+35.9%
Applied egg-rr35.9%
if 3.9000000000000001e40 < im Initial program 100.0%
Taylor expanded in re around 0 46.9%
*-rgt-identity46.9%
distribute-lft-in46.9%
Simplified46.9%
Taylor expanded in im around 0 7.4%
+-commutative7.4%
*-commutative7.4%
unpow27.4%
Simplified7.4%
Taylor expanded in im around inf 7.4%
unpow27.4%
+-commutative7.4%
distribute-rgt1-in6.8%
associate-*r*6.9%
distribute-rgt-in7.4%
*-commutative7.4%
Simplified7.4%
Taylor expanded in re around inf 7.7%
unpow27.7%
associate-*r*7.8%
*-commutative7.8%
Simplified7.8%
Final simplification28.4%
(FPCore (re im) :precision binary64 (if (<= re 480.0) (+ re 1.0) (+ 1.0 (* re (+ 1.0 (* -0.5 (* im im)))))))
double code(double re, double im) {
double tmp;
if (re <= 480.0) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (re * (1.0 + (-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 <= 480.0d0) then
tmp = re + 1.0d0
else
tmp = 1.0d0 + (re * (1.0d0 + ((-0.5d0) * (im * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 480.0) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (re * (1.0 + (-0.5 * (im * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 480.0: tmp = re + 1.0 else: tmp = 1.0 + (re * (1.0 + (-0.5 * (im * im)))) return tmp
function code(re, im) tmp = 0.0 if (re <= 480.0) tmp = Float64(re + 1.0); else tmp = Float64(1.0 + Float64(re * Float64(1.0 + Float64(-0.5 * Float64(im * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 480.0) tmp = re + 1.0; else tmp = 1.0 + (re * (1.0 + (-0.5 * (im * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 480.0], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(re * N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 480:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + re \cdot \left(1 + -0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 480Initial program 100.0%
Taylor expanded in re around 0 65.0%
*-rgt-identity65.0%
distribute-lft-in65.0%
Simplified65.0%
Taylor expanded in im around 0 30.7%
+-commutative30.7%
Simplified30.7%
if 480 < re Initial program 100.0%
Taylor expanded in re around 0 5.1%
*-rgt-identity5.1%
distribute-lft-in5.1%
Simplified5.1%
Taylor expanded in im around 0 21.8%
+-commutative21.8%
*-commutative21.8%
unpow221.8%
Simplified21.8%
Taylor expanded in re around inf 21.8%
*-commutative21.8%
+-commutative21.8%
unpow221.8%
Simplified21.8%
Final simplification28.7%
(FPCore (re im) :precision binary64 (if (<= re 650.0) (+ re 1.0) (+ 1.0 (* -0.5 (* im (* re im))))))
double code(double re, double im) {
double tmp;
if (re <= 650.0) {
tmp = re + 1.0;
} else {
tmp = 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 <= 650.0d0) then
tmp = re + 1.0d0
else
tmp = 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 <= 650.0) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (-0.5 * (im * (re * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 650.0: tmp = re + 1.0 else: tmp = 1.0 + (-0.5 * (im * (re * im))) return tmp
function code(re, im) tmp = 0.0 if (re <= 650.0) tmp = Float64(re + 1.0); else tmp = Float64(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 <= 650.0) tmp = re + 1.0; else tmp = 1.0 + (-0.5 * (im * (re * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 650.0], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * N[(re * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 650:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot \left(re \cdot im\right)\right)\\
\end{array}
\end{array}
if re < 650Initial program 100.0%
Taylor expanded in re around 0 65.0%
*-rgt-identity65.0%
distribute-lft-in65.0%
Simplified65.0%
Taylor expanded in im around 0 30.7%
+-commutative30.7%
Simplified30.7%
if 650 < re Initial program 100.0%
Taylor expanded in re around 0 5.1%
*-rgt-identity5.1%
distribute-lft-in5.1%
Simplified5.1%
Taylor expanded in im around 0 21.8%
+-commutative21.8%
*-commutative21.8%
unpow221.8%
Simplified21.8%
Taylor expanded in im around inf 20.2%
unpow220.2%
+-commutative20.2%
distribute-rgt1-in20.2%
associate-*r*20.2%
distribute-rgt-in20.2%
*-commutative20.2%
Simplified20.2%
Taylor expanded in re around inf 20.2%
unpow220.2%
associate-*r*20.2%
*-commutative20.2%
Simplified20.2%
Final simplification28.3%
(FPCore (re im) :precision binary64 (if (<= re 140.0) (+ re 1.0) (+ 1.0 (* -0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (re <= 140.0) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (-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 <= 140.0d0) then
tmp = re + 1.0d0
else
tmp = 1.0d0 + ((-0.5d0) * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 140.0) {
tmp = re + 1.0;
} else {
tmp = 1.0 + (-0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 140.0: tmp = re + 1.0 else: tmp = 1.0 + (-0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (re <= 140.0) tmp = Float64(re + 1.0); else tmp = Float64(1.0 + Float64(-0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 140.0) tmp = re + 1.0; else tmp = 1.0 + (-0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 140.0], N[(re + 1.0), $MachinePrecision], N[(1.0 + N[(-0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 140:\\
\;\;\;\;re + 1\\
\mathbf{else}:\\
\;\;\;\;1 + -0.5 \cdot \left(im \cdot im\right)\\
\end{array}
\end{array}
if re < 140Initial program 100.0%
Taylor expanded in re around 0 65.0%
*-rgt-identity65.0%
distribute-lft-in65.0%
Simplified65.0%
Taylor expanded in im around 0 30.7%
+-commutative30.7%
Simplified30.7%
if 140 < re Initial program 100.0%
Taylor expanded in re around 0 5.1%
*-rgt-identity5.1%
distribute-lft-in5.1%
Simplified5.1%
Taylor expanded in im around 0 21.8%
+-commutative21.8%
*-commutative21.8%
unpow221.8%
Simplified21.8%
Taylor expanded in re around 0 13.9%
unpow213.9%
Simplified13.9%
Taylor expanded in re around 0 12.6%
unpow212.6%
Simplified12.6%
Final simplification26.6%
(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 51.5%
*-rgt-identity51.5%
distribute-lft-in51.5%
Simplified51.5%
Taylor expanded in im around 0 24.7%
+-commutative24.7%
Simplified24.7%
Final simplification24.7%
herbie shell --seed 2023229
(FPCore (re im)
:name "math.exp on complex, real part"
:precision binary64
(* (exp re) (cos im)))