
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
(FPCore (re im) :precision binary64 (* (exp re) (sin im)))
double code(double re, double im) {
return exp(re) * sin(im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = exp(re) * sin(im)
end function
public static double code(double re, double im) {
return Math.exp(re) * Math.sin(im);
}
def code(re, im): return math.exp(re) * math.sin(im)
function code(re, im) return Float64(exp(re) * sin(im)) end
function tmp = code(re, im) tmp = exp(re) * sin(im); end
code[re_, im_] := N[(N[Exp[re], $MachinePrecision] * N[Sin[im], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{re} \cdot \sin im
\end{array}
Initial program 100.0%
(FPCore (re im)
:precision binary64
(if (or (<= re -0.0145) (and (not (<= re 0.0004)) (<= re 1.05e+103)))
(* (exp re) im)
(*
(sin im)
(+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0145) || (!(re <= 0.0004) && (re <= 1.05e+103))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * (1.0 + (re * (1.0 + (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 <= (-0.0145d0)) .or. (.not. (re <= 0.0004d0)) .and. (re <= 1.05d+103)) then
tmp = exp(re) * im
else
tmp = sin(im) * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.0145) || (!(re <= 0.0004) && (re <= 1.05e+103))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0145) or (not (re <= 0.0004) and (re <= 1.05e+103)): tmp = math.exp(re) * im else: tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0145) || (!(re <= 0.0004) && (re <= 1.05e+103))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.0145) || (~((re <= 0.0004)) && (re <= 1.05e+103))) tmp = exp(re) * im; else tmp = sin(im) * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0145], And[N[Not[LessEqual[re, 0.0004]], $MachinePrecision], LessEqual[re, 1.05e+103]]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0145 \lor \neg \left(re \leq 0.0004\right) \land re \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if re < -0.0145000000000000007 or 4.00000000000000019e-4 < re < 1.0500000000000001e103Initial program 100.0%
Taylor expanded in im around 0 89.8%
if -0.0145000000000000007 < re < 4.00000000000000019e-4 or 1.0500000000000001e103 < re Initial program 100.0%
Taylor expanded in re around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification96.5%
(FPCore (re im) :precision binary64 (if (or (<= re -0.0058) (and (not (<= re 0.0004)) (<= re 2.3e+151))) (* (exp re) im) (* (sin im) (+ 1.0 (* re (+ 1.0 (* re 0.5)))))))
double code(double re, double im) {
double tmp;
if ((re <= -0.0058) || (!(re <= 0.0004) && (re <= 2.3e+151))) {
tmp = exp(re) * im;
} else {
tmp = sin(im) * (1.0 + (re * (1.0 + (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.0058d0)) .or. (.not. (re <= 0.0004d0)) .and. (re <= 2.3d+151)) then
tmp = exp(re) * im
else
tmp = sin(im) * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((re <= -0.0058) || (!(re <= 0.0004) && (re <= 2.3e+151))) {
tmp = Math.exp(re) * im;
} else {
tmp = Math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5))));
}
return tmp;
}
def code(re, im): tmp = 0 if (re <= -0.0058) or (not (re <= 0.0004) and (re <= 2.3e+151)): tmp = math.exp(re) * im else: tmp = math.sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))) return tmp
function code(re, im) tmp = 0.0 if ((re <= -0.0058) || (!(re <= 0.0004) && (re <= 2.3e+151))) tmp = Float64(exp(re) * im); else tmp = Float64(sin(im) * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((re <= -0.0058) || (~((re <= 0.0004)) && (re <= 2.3e+151))) tmp = exp(re) * im; else tmp = sin(im) * (1.0 + (re * (1.0 + (re * 0.5)))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[re, -0.0058], And[N[Not[LessEqual[re, 0.0004]], $MachinePrecision], LessEqual[re, 2.3e+151]]], N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision], N[(N[Sin[im], $MachinePrecision] * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq -0.0058 \lor \neg \left(re \leq 0.0004\right) \land re \leq 2.3 \cdot 10^{+151}:\\
\;\;\;\;e^{re} \cdot im\\
\mathbf{else}:\\
\;\;\;\;\sin im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if re < -0.0058 or 4.00000000000000019e-4 < re < 2.3000000000000001e151Initial program 100.0%
Taylor expanded in im around 0 90.0%
if -0.0058 < re < 4.00000000000000019e-4 or 2.3000000000000001e151 < re Initial program 100.0%
Taylor expanded in re around 0 99.1%
*-commutative99.1%
Simplified99.1%
Final simplification95.5%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -0.0062)
t_0
(if (<= re 0.00034)
(* (sin im) (+ re 1.0))
(if (<= re 2.3e+151)
t_0
(*
(+ 1.0 (* re (+ 1.0 (* re 0.5))))
(* im (+ 1.0 (* -0.16666666666666666 (* im im))))))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -0.0062) {
tmp = t_0;
} else if (re <= 0.00034) {
tmp = sin(im) * (re + 1.0);
} else if (re <= 2.3e+151) {
tmp = t_0;
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * 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 = exp(re) * im
if (re <= (-0.0062d0)) then
tmp = t_0
else if (re <= 0.00034d0) then
tmp = sin(im) * (re + 1.0d0)
else if (re <= 2.3d+151) then
tmp = t_0
else
tmp = (1.0d0 + (re * (1.0d0 + (re * 0.5d0)))) * (im * (1.0d0 + ((-0.16666666666666666d0) * (im * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * im;
double tmp;
if (re <= -0.0062) {
tmp = t_0;
} else if (re <= 0.00034) {
tmp = Math.sin(im) * (re + 1.0);
} else if (re <= 2.3e+151) {
tmp = t_0;
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -0.0062: tmp = t_0 elif re <= 0.00034: tmp = math.sin(im) * (re + 1.0) elif re <= 2.3e+151: tmp = t_0 else: tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -0.0062) tmp = t_0; elseif (re <= 0.00034) tmp = Float64(sin(im) * Float64(re + 1.0)); elseif (re <= 2.3e+151) tmp = t_0; else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) * Float64(im * Float64(1.0 + Float64(-0.16666666666666666 * Float64(im * im))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -0.0062) tmp = t_0; elseif (re <= 0.00034) tmp = sin(im) * (re + 1.0); elseif (re <= 2.3e+151) tmp = t_0; else tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -0.0062], t$95$0, If[LessEqual[re, 0.00034], N[(N[Sin[im], $MachinePrecision] * N[(re + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[re, 2.3e+151], t$95$0, N[(N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(1.0 + N[(-0.16666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -0.0062:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;re \leq 0.00034:\\
\;\;\;\;\sin im \cdot \left(re + 1\right)\\
\mathbf{elif}\;re \leq 2.3 \cdot 10^{+151}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(im \cdot \left(1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if re < -0.00619999999999999978 or 3.4e-4 < re < 2.3000000000000001e151Initial program 100.0%
Taylor expanded in im around 0 90.0%
if -0.00619999999999999978 < re < 3.4e-4Initial program 100.0%
Taylor expanded in re around 0 98.8%
distribute-rgt1-in98.8%
Simplified98.8%
if 2.3000000000000001e151 < re Initial program 100.0%
Taylor expanded in re around 0 96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in im around 0 85.2%
unpow285.2%
Applied egg-rr85.2%
Final simplification93.9%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (exp re) im)))
(if (<= re -4.5e-8)
t_0
(if (<= re 0.0003)
(sin im)
(if (<= re 2.2e+151)
t_0
(*
(+ 1.0 (* re (+ 1.0 (* re 0.5))))
(* im (+ 1.0 (* -0.16666666666666666 (* im im))))))))))
double code(double re, double im) {
double t_0 = exp(re) * im;
double tmp;
if (re <= -4.5e-8) {
tmp = t_0;
} else if (re <= 0.0003) {
tmp = sin(im);
} else if (re <= 2.2e+151) {
tmp = t_0;
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * 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 = exp(re) * im
if (re <= (-4.5d-8)) then
tmp = t_0
else if (re <= 0.0003d0) then
tmp = sin(im)
else if (re <= 2.2d+151) then
tmp = t_0
else
tmp = (1.0d0 + (re * (1.0d0 + (re * 0.5d0)))) * (im * (1.0d0 + ((-0.16666666666666666d0) * (im * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.exp(re) * im;
double tmp;
if (re <= -4.5e-8) {
tmp = t_0;
} else if (re <= 0.0003) {
tmp = Math.sin(im);
} else if (re <= 2.2e+151) {
tmp = t_0;
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im))));
}
return tmp;
}
def code(re, im): t_0 = math.exp(re) * im tmp = 0 if re <= -4.5e-8: tmp = t_0 elif re <= 0.0003: tmp = math.sin(im) elif re <= 2.2e+151: tmp = t_0 else: tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))) return tmp
function code(re, im) t_0 = Float64(exp(re) * im) tmp = 0.0 if (re <= -4.5e-8) tmp = t_0; elseif (re <= 0.0003) tmp = sin(im); elseif (re <= 2.2e+151) tmp = t_0; else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) * Float64(im * Float64(1.0 + Float64(-0.16666666666666666 * Float64(im * im))))); end return tmp end
function tmp_2 = code(re, im) t_0 = exp(re) * im; tmp = 0.0; if (re <= -4.5e-8) tmp = t_0; elseif (re <= 0.0003) tmp = sin(im); elseif (re <= 2.2e+151) tmp = t_0; else tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Exp[re], $MachinePrecision] * im), $MachinePrecision]}, If[LessEqual[re, -4.5e-8], t$95$0, If[LessEqual[re, 0.0003], N[Sin[im], $MachinePrecision], If[LessEqual[re, 2.2e+151], t$95$0, N[(N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(1.0 + N[(-0.16666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{re} \cdot im\\
\mathbf{if}\;re \leq -4.5 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;re \leq 0.0003:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;re \leq 2.2 \cdot 10^{+151}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(im \cdot \left(1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if re < -4.49999999999999993e-8 or 2.99999999999999974e-4 < re < 2.20000000000000007e151Initial program 100.0%
Taylor expanded in im around 0 89.3%
if -4.49999999999999993e-8 < re < 2.99999999999999974e-4Initial program 100.0%
Taylor expanded in re around 0 97.7%
if 2.20000000000000007e151 < re Initial program 100.0%
Taylor expanded in re around 0 96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in im around 0 85.2%
unpow285.2%
Applied egg-rr85.2%
(FPCore (re im)
:precision binary64
(if (<= re 0.00021)
(sin im)
(if (<= re 2.3e+151)
(*
im
(+
1.0
(*
re
(+
1.0
(*
re
(+
0.5
(* re (+ 0.16666666666666666 (* re 0.041666666666666664)))))))))
(*
(+ 1.0 (* re (+ 1.0 (* re 0.5))))
(* im (+ 1.0 (* -0.16666666666666666 (* im im))))))))
double code(double re, double im) {
double tmp;
if (re <= 0.00021) {
tmp = sin(im);
} else if (re <= 2.3e+151) {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664))))))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (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 <= 0.00021d0) then
tmp = sin(im)
else if (re <= 2.3d+151) then
tmp = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * (0.16666666666666666d0 + (re * 0.041666666666666664d0))))))))
else
tmp = (1.0d0 + (re * (1.0d0 + (re * 0.5d0)))) * (im * (1.0d0 + ((-0.16666666666666666d0) * (im * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.00021) {
tmp = Math.sin(im);
} else if (re <= 2.3e+151) {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664))))))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.00021: tmp = math.sin(im) elif re <= 2.3e+151: tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664)))))))) else: tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))) return tmp
function code(re, im) tmp = 0.0 if (re <= 0.00021) tmp = sin(im); elseif (re <= 2.3e+151) tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * Float64(0.16666666666666666 + Float64(re * 0.041666666666666664))))))))); else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) * Float64(im * Float64(1.0 + Float64(-0.16666666666666666 * Float64(im * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.00021) tmp = sin(im); elseif (re <= 2.3e+151) tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664)))))))); else tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.00021], N[Sin[im], $MachinePrecision], If[LessEqual[re, 2.3e+151], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * N[(0.16666666666666666 + N[(re * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(1.0 + N[(-0.16666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.00021:\\
\;\;\;\;\sin im\\
\mathbf{elif}\;re \leq 2.3 \cdot 10^{+151}:\\
\;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot \left(0.16666666666666666 + re \cdot 0.041666666666666664\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(im \cdot \left(1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if re < 2.1000000000000001e-4Initial program 100.0%
Taylor expanded in re around 0 65.0%
if 2.1000000000000001e-4 < re < 2.3000000000000001e151Initial program 100.0%
Taylor expanded in im around 0 75.0%
log1p-expm1-u75.0%
log1p-undefine75.0%
add-exp-log75.0%
Applied egg-rr75.0%
Taylor expanded in re around 0 51.1%
*-commutative51.1%
Simplified51.1%
if 2.3000000000000001e151 < re Initial program 100.0%
Taylor expanded in re around 0 96.7%
*-commutative96.7%
Simplified96.7%
Taylor expanded in im around 0 85.2%
unpow285.2%
Applied egg-rr85.2%
Final simplification65.4%
(FPCore (re im)
:precision binary64
(if (<= im 2.1e+45)
(*
im
(+
1.0
(*
re
(+
1.0
(*
re
(+ 0.5 (* re (+ 0.16666666666666666 (* re 0.041666666666666664)))))))))
(*
(+ 1.0 (* re (+ 1.0 (* re 0.5))))
(* im (+ 1.0 (* -0.16666666666666666 (* im im)))))))
double code(double re, double im) {
double tmp;
if (im <= 2.1e+45) {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664))))))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.1d+45) then
tmp = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * (0.16666666666666666d0 + (re * 0.041666666666666664d0))))))))
else
tmp = (1.0d0 + (re * (1.0d0 + (re * 0.5d0)))) * (im * (1.0d0 + ((-0.16666666666666666d0) * (im * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.1e+45) {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664))))))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.1e+45: tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664)))))))) else: tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.1e+45) tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * Float64(0.16666666666666666 + Float64(re * 0.041666666666666664))))))))); else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) * Float64(im * Float64(1.0 + Float64(-0.16666666666666666 * Float64(im * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.1e+45) tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * (0.16666666666666666 + (re * 0.041666666666666664)))))))); else tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.1e+45], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * N[(0.16666666666666666 + N[(re * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(1.0 + N[(-0.16666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.1 \cdot 10^{+45}:\\
\;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot \left(0.16666666666666666 + re \cdot 0.041666666666666664\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(im \cdot \left(1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if im < 2.09999999999999995e45Initial program 100.0%
Taylor expanded in im around 0 76.0%
log1p-expm1-u75.9%
log1p-undefine75.9%
add-exp-log75.9%
Applied egg-rr75.9%
Taylor expanded in re around 0 48.8%
*-commutative48.8%
Simplified48.8%
if 2.09999999999999995e45 < im Initial program 100.0%
Taylor expanded in re around 0 58.3%
*-commutative58.3%
Simplified58.3%
Taylor expanded in im around 0 14.1%
unpow214.1%
Applied egg-rr14.1%
Final simplification40.3%
(FPCore (re im)
:precision binary64
(if (<= im 2.1e+45)
(* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666)))))))
(*
(+ 1.0 (* re (+ 1.0 (* re 0.5))))
(* im (+ 1.0 (* -0.16666666666666666 (* im im)))))))
double code(double re, double im) {
double tmp;
if (im <= 2.1e+45) {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 2.1d+45) then
tmp = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
else
tmp = (1.0d0 + (re * (1.0d0 + (re * 0.5d0)))) * (im * (1.0d0 + ((-0.16666666666666666d0) * (im * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.1e+45) {
tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
} else {
tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.1e+45: tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))) else: tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.1e+45) tmp = Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))); else tmp = Float64(Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5)))) * Float64(im * Float64(1.0 + Float64(-0.16666666666666666 * Float64(im * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.1e+45) tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); else tmp = (1.0 + (re * (1.0 + (re * 0.5)))) * (im * (1.0 + (-0.16666666666666666 * (im * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.1e+45], N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(im * N[(1.0 + N[(-0.16666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.1 \cdot 10^{+45}:\\
\;\;\;\;im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right) \cdot \left(im \cdot \left(1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)\right)\\
\end{array}
\end{array}
if im < 2.09999999999999995e45Initial program 100.0%
Taylor expanded in re around 0 68.2%
*-commutative68.2%
Simplified68.2%
Taylor expanded in im around 0 47.2%
if 2.09999999999999995e45 < im Initial program 100.0%
Taylor expanded in re around 0 58.3%
*-commutative58.3%
Simplified58.3%
Taylor expanded in im around 0 14.1%
unpow214.1%
Applied egg-rr14.1%
Final simplification39.1%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* re (+ 1.0 (* re (+ 0.5 (* re 0.16666666666666666))))))))
double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (1.0d0 + (re * (1.0d0 + (re * (0.5d0 + (re * 0.16666666666666666d0))))))
end function
public static double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))));
}
def code(re, im): return im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666))))))
function code(re, im) return Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * Float64(0.5 + Float64(re * 0.16666666666666666))))))) end
function tmp = code(re, im) tmp = im * (1.0 + (re * (1.0 + (re * (0.5 + (re * 0.16666666666666666)))))); end
code[re_, im_] := N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * N[(0.5 + N[(re * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot \left(0.5 + re \cdot 0.16666666666666666\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 66.9%
*-commutative66.9%
Simplified66.9%
Taylor expanded in im around 0 37.6%
Final simplification37.6%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* re (+ 1.0 (* re 0.5))))))
double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * 0.5))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (1.0d0 + (re * (1.0d0 + (re * 0.5d0))))
end function
public static double code(double re, double im) {
return im * (1.0 + (re * (1.0 + (re * 0.5))));
}
def code(re, im): return im * (1.0 + (re * (1.0 + (re * 0.5))))
function code(re, im) return Float64(im * Float64(1.0 + Float64(re * Float64(1.0 + Float64(re * 0.5))))) end
function tmp = code(re, im) tmp = im * (1.0 + (re * (1.0 + (re * 0.5)))); end
code[re_, im_] := N[(im * N[(1.0 + N[(re * N[(1.0 + N[(re * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + re \cdot \left(1 + re \cdot 0.5\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 67.0%
Taylor expanded in re around 0 34.3%
*-commutative61.9%
Simplified34.3%
Final simplification34.3%
(FPCore (re im) :precision binary64 (* im (+ 1.0 (* -0.16666666666666666 (* im im)))))
double code(double re, double im) {
return im * (1.0 + (-0.16666666666666666 * (im * im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (1.0d0 + ((-0.16666666666666666d0) * (im * im)))
end function
public static double code(double re, double im) {
return im * (1.0 + (-0.16666666666666666 * (im * im)));
}
def code(re, im): return im * (1.0 + (-0.16666666666666666 * (im * im)))
function code(re, im) return Float64(im * Float64(1.0 + Float64(-0.16666666666666666 * Float64(im * im)))) end
function tmp = code(re, im) tmp = im * (1.0 + (-0.16666666666666666 * (im * im))); end
code[re_, im_] := N[(im * N[(1.0 + N[(-0.16666666666666666 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(1 + -0.16666666666666666 \cdot \left(im \cdot im\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 50.8%
Taylor expanded in im around 0 29.7%
unpow237.2%
Applied egg-rr29.7%
(FPCore (re im) :precision binary64 (if (<= re 2.55e+33) im (* re im)))
double code(double re, double im) {
double tmp;
if (re <= 2.55e+33) {
tmp = im;
} else {
tmp = 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 <= 2.55d+33) then
tmp = im
else
tmp = re * im
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.55e+33) {
tmp = im;
} else {
tmp = re * im;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.55e+33: tmp = im else: tmp = re * im return tmp
function code(re, im) tmp = 0.0 if (re <= 2.55e+33) tmp = im; else tmp = Float64(re * im); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.55e+33) tmp = im; else tmp = re * im; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.55e+33], im, N[(re * im), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.55 \cdot 10^{+33}:\\
\;\;\;\;im\\
\mathbf{else}:\\
\;\;\;\;re \cdot im\\
\end{array}
\end{array}
if re < 2.5499999999999999e33Initial program 100.0%
Taylor expanded in re around 0 63.3%
Taylor expanded in im around 0 32.3%
if 2.5499999999999999e33 < re Initial program 100.0%
Taylor expanded in re around 0 4.4%
distribute-rgt1-in4.4%
Simplified4.4%
Taylor expanded in re around inf 4.4%
*-commutative4.4%
Simplified4.4%
Taylor expanded in im around 0 12.0%
Final simplification28.1%
(FPCore (re im) :precision binary64 (+ im (* re im)))
double code(double re, double im) {
return im + (re * im);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im + (re * im)
end function
public static double code(double re, double im) {
return im + (re * im);
}
def code(re, im): return im + (re * im)
function code(re, im) return Float64(im + Float64(re * im)) end
function tmp = code(re, im) tmp = im + (re * im); end
code[re_, im_] := N[(im + N[(re * im), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im + re \cdot im
\end{array}
Initial program 100.0%
Taylor expanded in im around 0 67.0%
Taylor expanded in re around 0 28.2%
Final simplification28.2%
(FPCore (re im) :precision binary64 (* im (+ re 1.0)))
double code(double re, double im) {
return im * (re + 1.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im * (re + 1.0d0)
end function
public static double code(double re, double im) {
return im * (re + 1.0);
}
def code(re, im): return im * (re + 1.0)
function code(re, im) return Float64(im * Float64(re + 1.0)) end
function tmp = code(re, im) tmp = im * (re + 1.0); end
code[re_, im_] := N[(im * N[(re + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
im \cdot \left(re + 1\right)
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 51.8%
distribute-rgt1-in51.7%
Simplified51.7%
Taylor expanded in im around 0 28.2%
Final simplification28.2%
(FPCore (re im) :precision binary64 im)
double code(double re, double im) {
return im;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = im
end function
public static double code(double re, double im) {
return im;
}
def code(re, im): return im
function code(re, im) return im end
function tmp = code(re, im) tmp = im; end
code[re_, im_] := im
\begin{array}{l}
\\
im
\end{array}
Initial program 100.0%
Taylor expanded in re around 0 50.8%
Taylor expanded in im around 0 26.1%
herbie shell --seed 2024188
(FPCore (re im)
:name "math.exp on complex, imaginary part"
:precision binary64
(* (exp re) (sin im)))