
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp((0.0d0 - im)) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp((0.0 - im)) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp((0.0 - im)) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(0.0 - im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp((0.0 - im)) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[N[(0.0 - im), $MachinePrecision]], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (sin re)) (+ (exp (- im)) (exp im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(-im) + exp(im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(-im) + exp(im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(-im) + Math.exp(im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(-im) + math.exp(im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(Float64(-im)) + exp(im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(-im) + exp(im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} + e^{im}\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
(FPCore (re im) :precision binary64 (let* ((t_0 (* 0.5 (sin re)))) (if (<= im 2.2) (* t_0 (fma im im 2.0)) (* t_0 (+ (exp im) 3.0)))))
double code(double re, double im) {
double t_0 = 0.5 * sin(re);
double tmp;
if (im <= 2.2) {
tmp = t_0 * fma(im, im, 2.0);
} else {
tmp = t_0 * (exp(im) + 3.0);
}
return tmp;
}
function code(re, im) t_0 = Float64(0.5 * sin(re)) tmp = 0.0 if (im <= 2.2) tmp = Float64(t_0 * fma(im, im, 2.0)); else tmp = Float64(t_0 * Float64(exp(im) + 3.0)); end return tmp end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 2.2], N[(t$95$0 * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathbf{if}\;im \leq 2.2:\\
\;\;\;\;t\_0 \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(e^{im} + 3\right)\\
\end{array}
\end{array}
if im < 2.2000000000000002Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 85.0%
+-commutative85.0%
unpow285.0%
fma-define85.0%
Simplified85.0%
if 2.2000000000000002 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Final simplification88.8%
(FPCore (re im) :precision binary64 (if (<= im 1.2) (sin re) (* (* 0.5 (sin re)) (+ (exp im) 3.0))))
double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = sin(re);
} else {
tmp = (0.5 * sin(re)) * (exp(im) + 3.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.2d0) then
tmp = sin(re)
else
tmp = (0.5d0 * sin(re)) * (exp(im) + 3.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.2) {
tmp = Math.sin(re);
} else {
tmp = (0.5 * Math.sin(re)) * (Math.exp(im) + 3.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.2: tmp = math.sin(re) else: tmp = (0.5 * math.sin(re)) * (math.exp(im) + 3.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.2) tmp = sin(re); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(exp(im) + 3.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.2) tmp = sin(re); else tmp = (0.5 * sin(re)) * (exp(im) + 3.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.2], N[Sin[re], $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.2:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + 3\right)\\
\end{array}
\end{array}
if im < 1.19999999999999996Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.9%
Taylor expanded in re around inf 72.9%
if 1.19999999999999996 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Final simplification79.7%
(FPCore (re im)
:precision binary64
(if (<= im 5.2)
(sin re)
(if (<= im 1.02e+103)
(* (+ (exp im) 3.0) (* 0.5 re))
(*
(* 0.5 (sin re))
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))))
double code(double re, double im) {
double tmp;
if (im <= 5.2) {
tmp = sin(re);
} else if (im <= 1.02e+103) {
tmp = (exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 5.2d0) then
tmp = sin(re)
else if (im <= 1.02d+103) then
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
else
tmp = (0.5d0 * sin(re)) * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.2) {
tmp = Math.sin(re);
} else if (im <= 1.02e+103) {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * Math.sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.2: tmp = math.sin(re) elif im <= 1.02e+103: tmp = (math.exp(im) + 3.0) * (0.5 * re) else: tmp = (0.5 * math.sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.2) tmp = sin(re); elseif (im <= 1.02e+103) tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.2) tmp = sin(re); elseif (im <= 1.02e+103) tmp = (exp(im) + 3.0) * (0.5 * re); else tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.2], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.02e+103], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.2:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.02 \cdot 10^{+103}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 5.20000000000000018Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.9%
Taylor expanded in re around inf 72.9%
if 5.20000000000000018 < im < 1.01999999999999991e103Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 77.8%
*-commutative77.8%
*-commutative77.8%
associate-*l*77.8%
Simplified77.8%
if 1.01999999999999991e103 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
Final simplification78.1%
(FPCore (re im)
:precision binary64
(if (<= im 6.8)
(sin re)
(if (<= im 1.9e+154)
(* (+ (exp im) 3.0) (* 0.5 re))
(* (* 0.5 (sin re)) (+ 4.0 (* im (+ 1.0 (* 0.5 im))))))))
double code(double re, double im) {
double tmp;
if (im <= 6.8) {
tmp = sin(re);
} else if (im <= 1.9e+154) {
tmp = (exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 6.8d0) then
tmp = sin(re)
else if (im <= 1.9d+154) then
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
else
tmp = (0.5d0 * sin(re)) * (4.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 6.8) {
tmp = Math.sin(re);
} else if (im <= 1.9e+154) {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
} else {
tmp = (0.5 * Math.sin(re)) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 6.8: tmp = math.sin(re) elif im <= 1.9e+154: tmp = (math.exp(im) + 3.0) * (0.5 * re) else: tmp = (0.5 * math.sin(re)) * (4.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 6.8) tmp = sin(re); elseif (im <= 1.9e+154) tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); else tmp = Float64(Float64(0.5 * sin(re)) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 6.8) tmp = sin(re); elseif (im <= 1.9e+154) tmp = (exp(im) + 3.0) * (0.5 * re); else tmp = (0.5 * sin(re)) * (4.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 6.8], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.9e+154], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.8:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.9 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 6.79999999999999982Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.9%
Taylor expanded in re around inf 72.9%
if 6.79999999999999982 < im < 1.8999999999999999e154Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 71.4%
*-commutative71.4%
*-commutative71.4%
associate-*l*71.4%
Simplified71.4%
if 1.8999999999999999e154 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification76.6%
(FPCore (re im) :precision binary64 (if (<= im 6.8) (sin re) (* (+ (exp im) 3.0) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 6.8) {
tmp = sin(re);
} else {
tmp = (exp(im) + 3.0) * (0.5 * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 6.8d0) then
tmp = sin(re)
else
tmp = (exp(im) + 3.0d0) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 6.8) {
tmp = Math.sin(re);
} else {
tmp = (Math.exp(im) + 3.0) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 6.8: tmp = math.sin(re) else: tmp = (math.exp(im) + 3.0) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 6.8) tmp = sin(re); else tmp = Float64(Float64(exp(im) + 3.0) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 6.8) tmp = sin(re); else tmp = (exp(im) + 3.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 6.8], N[Sin[re], $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 3.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.8:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 6.79999999999999982Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.9%
Taylor expanded in re around inf 72.9%
if 6.79999999999999982 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 81.3%
*-commutative81.3%
*-commutative81.3%
associate-*l*81.3%
Simplified81.3%
Final simplification75.0%
(FPCore (re im)
:precision binary64
(if (<= im 115000.0)
(sin re)
(*
(* 0.5 re)
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (im <= 115000.0) {
tmp = sin(re);
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 115000.0d0) then
tmp = sin(re)
else
tmp = (0.5d0 * re) * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 115000.0) {
tmp = Math.sin(re);
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 115000.0: tmp = math.sin(re) else: tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 115000.0) tmp = sin(re); else tmp = Float64(Float64(0.5 * re) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 115000.0) tmp = sin(re); else tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 115000.0], N[Sin[re], $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 115000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 115000Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 72.9%
Taylor expanded in re around inf 72.9%
if 115000 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 81.3%
*-commutative81.3%
*-commutative81.3%
associate-*l*81.3%
Simplified81.3%
Taylor expanded in im around 0 65.0%
Final simplification70.9%
(FPCore (re im)
:precision binary64
(if (<= im 1.6e+77)
(* re (+ 1.0 (* -0.16666666666666666 (* re re))))
(*
(* 0.5 re)
(+ 4.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (im <= 1.6e+77) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.6d+77) then
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
else
tmp = (0.5d0 * re) * (4.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.6e+77) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.6e+77: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) else: tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.6e+77) tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); else tmp = Float64(Float64(0.5 * re) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.6e+77) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); else tmp = (0.5 * re) * (4.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.6e+77], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.6 \cdot 10^{+77}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(4 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 1.6000000000000001e77Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 68.5%
Taylor expanded in re around 0 38.9%
unpow238.9%
Applied egg-rr38.9%
if 1.6000000000000001e77 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 82.4%
*-commutative82.4%
*-commutative82.4%
associate-*l*82.4%
Simplified82.4%
Taylor expanded in im around 0 78.7%
Final simplification46.8%
(FPCore (re im) :precision binary64 (if (<= im 1.4e+126) (* re (+ 1.0 (* -0.16666666666666666 (* re re)))) (* (* 0.5 re) (+ 4.0 (* im (+ 1.0 (* 0.5 im)))))))
double code(double re, double im) {
double tmp;
if (im <= 1.4e+126) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.4d+126) then
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
else
tmp = (0.5d0 * re) * (4.0d0 + (im * (1.0d0 + (0.5d0 * im))))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.4e+126) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.4e+126: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) else: tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im)))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.4e+126) tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); else tmp = Float64(Float64(0.5 * re) * Float64(4.0 + Float64(im * Float64(1.0 + Float64(0.5 * im))))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.4e+126) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); else tmp = (0.5 * re) * (4.0 + (im * (1.0 + (0.5 * im)))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.4e+126], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(4.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.4 \cdot 10^{+126}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(4 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 1.40000000000000005e126Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 65.7%
Taylor expanded in re around 0 38.3%
unpow238.3%
Applied egg-rr38.3%
if 1.40000000000000005e126 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in re around 0 88.1%
*-commutative88.1%
*-commutative88.1%
associate-*l*88.1%
Simplified88.1%
Taylor expanded in im around 0 83.6%
*-commutative86.8%
Simplified83.6%
Final simplification45.7%
(FPCore (re im) :precision binary64 (if (<= im 3.1e+271) (* re (+ 1.0 (* -0.16666666666666666 (* re re)))) (* im (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 3.1e+271) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = im * (0.5 * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 3.1d+271) then
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
else
tmp = im * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.1e+271) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = im * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.1e+271: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) else: tmp = im * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.1e+271) tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); else tmp = Float64(im * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.1e+271) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); else tmp = im * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.1e+271], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(im * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.1 \cdot 10^{+271}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 3.1000000000000001e271Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 57.5%
Taylor expanded in re around 0 35.5%
unpow235.5%
Applied egg-rr35.5%
if 3.1000000000000001e271 < im Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr100.0%
Taylor expanded in im around 0 7.4%
Taylor expanded in re around 0 43.2%
associate-*r*43.2%
Simplified43.2%
Taylor expanded in im around inf 43.2%
Final simplification35.8%
(FPCore (re im) :precision binary64 (if (<= re 6.4e+14) re (* im (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (re <= 6.4e+14) {
tmp = re;
} else {
tmp = im * (0.5 * re);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 6.4d+14) then
tmp = re
else
tmp = im * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 6.4e+14) {
tmp = re;
} else {
tmp = im * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 6.4e+14: tmp = re else: tmp = im * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (re <= 6.4e+14) tmp = re; else tmp = Float64(im * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 6.4e+14) tmp = re; else tmp = im * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 6.4e+14], re, N[(im * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 6.4 \cdot 10^{+14}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if re < 6.4e14Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 55.5%
Taylor expanded in re around 0 34.7%
if 6.4e14 < re Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr32.4%
Taylor expanded in im around 0 11.1%
Taylor expanded in re around 0 14.2%
associate-*r*14.2%
Simplified14.2%
Taylor expanded in im around inf 14.5%
Final simplification30.0%
(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%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 55.3%
Taylor expanded in re around 0 27.4%
(FPCore (re im) :precision binary64 0.0)
double code(double re, double im) {
return 0.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.0d0
end function
public static double code(double re, double im) {
return 0.0;
}
def code(re, im): return 0.0
function code(re, im) return 0.0 end
function tmp = code(re, im) tmp = 0.0; end
code[re_, im_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
cancel-sign-sub100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
remove-double-neg100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 55.3%
Applied egg-rr3.0%
pow-base-13.0%
metadata-eval3.0%
Simplified3.0%
metadata-eval3.0%
Applied egg-rr3.0%
herbie shell --seed 2024185
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))