
(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.1) (* 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.1) {
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.1) 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.1], 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.1:\\
\;\;\;\;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.10000000000000009Initial 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.3%
+-commutative85.3%
unpow285.3%
fma-define85.3%
Simplified85.3%
if 2.10000000000000009 < 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.6%
(FPCore (re im) :precision binary64 (if (<= im 1.15) (sin re) (* (* 0.5 (sin re)) (+ (exp im) 3.0))))
double code(double re, double im) {
double tmp;
if (im <= 1.15) {
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.15d0) 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.15) {
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.15: 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.15) 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.15) 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.15], 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.15:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + 3\right)\\
\end{array}
\end{array}
if im < 1.1499999999999999Initial 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 69.7%
Taylor expanded in re around inf 69.7%
if 1.1499999999999999 < 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 simplification76.5%
(FPCore (re im)
:precision binary64
(if (<= im 9.5e-13)
(sin re)
(if (<= im 1.05e+103)
(*
(* 0.5 re)
(+
(exp im)
(+ 1.0 (* im (+ (* im (+ 0.5 (* im -0.16666666666666666))) -1.0)))))
(*
(* 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 <= 9.5e-13) {
tmp = sin(re);
} else if (im <= 1.05e+103) {
tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} 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 <= 9.5d-13) then
tmp = sin(re)
else if (im <= 1.05d+103) then
tmp = (0.5d0 * re) * (exp(im) + (1.0d0 + (im * ((im * (0.5d0 + (im * (-0.16666666666666666d0)))) + (-1.0d0)))))
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 <= 9.5e-13) {
tmp = Math.sin(re);
} else if (im <= 1.05e+103) {
tmp = (0.5 * re) * (Math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0))));
} 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 <= 9.5e-13: tmp = math.sin(re) elif im <= 1.05e+103: tmp = (0.5 * re) * (math.exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))) 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 <= 9.5e-13) tmp = sin(re); elseif (im <= 1.05e+103) tmp = Float64(Float64(0.5 * re) * Float64(exp(im) + Float64(1.0 + Float64(im * Float64(Float64(im * Float64(0.5 + Float64(im * -0.16666666666666666))) + -1.0))))); 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 <= 9.5e-13) tmp = sin(re); elseif (im <= 1.05e+103) tmp = (0.5 * re) * (exp(im) + (1.0 + (im * ((im * (0.5 + (im * -0.16666666666666666))) + -1.0)))); 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, 9.5e-13], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.05e+103], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[(1.0 + N[(im * N[(N[(im * N[(0.5 + N[(im * -0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 9.5 \cdot 10^{-13}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.05 \cdot 10^{+103}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{im} + \left(1 + im \cdot \left(im \cdot \left(0.5 + im \cdot -0.16666666666666666\right) + -1\right)\right)\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 < 9.49999999999999991e-13Initial 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 69.7%
Taylor expanded in re around inf 69.7%
if 9.49999999999999991e-13 < im < 1.0500000000000001e103Initial 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 re around 0 81.8%
Taylor expanded in im around 0 81.8%
if 1.0500000000000001e103 < 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 simplification75.0%
(FPCore (re im)
:precision binary64
(if (<= im 4.0)
(sin re)
(if (<= im 1.05e+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 <= 4.0) {
tmp = sin(re);
} else if (im <= 1.05e+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 <= 4.0d0) then
tmp = sin(re)
else if (im <= 1.05d+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 <= 4.0) {
tmp = Math.sin(re);
} else if (im <= 1.05e+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 <= 4.0: tmp = math.sin(re) elif im <= 1.05e+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 <= 4.0) tmp = sin(re); elseif (im <= 1.05e+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 <= 4.0) tmp = sin(re); elseif (im <= 1.05e+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, 4.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.05e+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 4:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.05 \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 < 4Initial 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 69.7%
Taylor expanded in re around inf 69.7%
if 4 < im < 1.0500000000000001e103Initial 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.8%
associate-*r*81.8%
*-commutative81.8%
Simplified81.8%
if 1.0500000000000001e103 < 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 simplification75.0%
(FPCore (re im)
:precision binary64
(if (<= im 3.8)
(sin re)
(if (<= im 2.1e+146)
(* (+ (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 <= 3.8) {
tmp = sin(re);
} else if (im <= 2.1e+146) {
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 <= 3.8d0) then
tmp = sin(re)
else if (im <= 2.1d+146) 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 <= 3.8) {
tmp = Math.sin(re);
} else if (im <= 2.1e+146) {
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 <= 3.8: tmp = math.sin(re) elif im <= 2.1e+146: 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 <= 3.8) tmp = sin(re); elseif (im <= 2.1e+146) 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 <= 3.8) tmp = sin(re); elseif (im <= 2.1e+146) 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, 3.8], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.1e+146], 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 3.8:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.1 \cdot 10^{+146}:\\
\;\;\;\;\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 < 3.7999999999999998Initial 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 69.7%
Taylor expanded in re around inf 69.7%
if 3.7999999999999998 < im < 2.1000000000000001e146Initial 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 85.7%
associate-*r*85.7%
*-commutative85.7%
Simplified85.7%
if 2.1000000000000001e146 < 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 97.1%
*-commutative97.1%
Simplified97.1%
Final simplification74.6%
(FPCore (re im)
:precision binary64
(if (<= im 31000.0)
(sin re)
(if (<= im 3.6e+105)
(* re (+ 1.0 (* -0.16666666666666666 (* re re))))
(* (* 0.5 re) (pow im 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 31000.0) {
tmp = sin(re);
} else if (im <= 3.6e+105) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * pow(im, 2.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 31000.0d0) then
tmp = sin(re)
else if (im <= 3.6d+105) then
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
else
tmp = (0.5d0 * re) * (im ** 2.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 31000.0) {
tmp = Math.sin(re);
} else if (im <= 3.6e+105) {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
} else {
tmp = (0.5 * re) * Math.pow(im, 2.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 31000.0: tmp = math.sin(re) elif im <= 3.6e+105: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) else: tmp = (0.5 * re) * math.pow(im, 2.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 31000.0) tmp = sin(re); elseif (im <= 3.6e+105) tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); else tmp = Float64(Float64(0.5 * re) * (im ^ 2.0)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 31000.0) tmp = sin(re); elseif (im <= 3.6e+105) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); else tmp = (0.5 * re) * (im ^ 2.0); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 31000.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.6e+105], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 31000:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.6 \cdot 10^{+105}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot {im}^{2}\\
\end{array}
\end{array}
if im < 31000Initial 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 69.3%
Taylor expanded in re around inf 69.3%
if 31000 < im < 3.5999999999999999e105Initial 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 2.5%
Taylor expanded in re around 0 20.5%
unpow220.5%
Applied egg-rr20.5%
if 3.5999999999999999e105 < 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%
Taylor expanded in im around 0 82.1%
+-commutative82.1%
unpow282.1%
fma-define82.1%
Simplified82.1%
Taylor expanded in re around 0 66.8%
associate-*r*66.8%
*-commutative66.8%
+-commutative66.8%
unpow266.8%
fma-undefine66.8%
Simplified66.8%
Taylor expanded in im around inf 66.8%
*-commutative66.8%
associate-*r*66.8%
*-commutative66.8%
Simplified66.8%
Final simplification65.0%
(FPCore (re im) :precision binary64 (if (<= im 2.8) (sin re) (* (+ (exp im) 3.0) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 2.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 <= 2.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 <= 2.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 <= 2.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 <= 2.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 <= 2.8) tmp = sin(re); else tmp = (exp(im) + 3.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.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 2.8:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 3\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 2.7999999999999998Initial 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 69.7%
Taylor expanded in re around inf 69.7%
if 2.7999999999999998 < 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 74.1%
associate-*r*74.1%
*-commutative74.1%
Simplified74.1%
Final simplification70.7%
(FPCore (re im) :precision binary64 (if (<= im 27000.0) (sin re) (* re (+ 1.0 (* -0.16666666666666666 (* re re))))))
double code(double re, double im) {
double tmp;
if (im <= 27000.0) {
tmp = sin(re);
} else {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 27000.0d0) then
tmp = sin(re)
else
tmp = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 27000.0) {
tmp = Math.sin(re);
} else {
tmp = re * (1.0 + (-0.16666666666666666 * (re * re)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 27000.0: tmp = math.sin(re) else: tmp = re * (1.0 + (-0.16666666666666666 * (re * re))) return tmp
function code(re, im) tmp = 0.0 if (im <= 27000.0) tmp = sin(re); else tmp = Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 27000.0) tmp = sin(re); else tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 27000.0], N[Sin[re], $MachinePrecision], N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 27000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\right)\\
\end{array}
\end{array}
if im < 27000Initial 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 69.3%
Taylor expanded in re around inf 69.3%
if 27000 < 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%
Taylor expanded in im around 0 2.7%
Taylor expanded in re around 0 17.4%
unpow217.4%
Applied egg-rr17.4%
(FPCore (re im) :precision binary64 (if (<= re 3.7e-9) re (* im (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (re <= 3.7e-9) {
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 <= 3.7d-9) 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 <= 3.7e-9) {
tmp = re;
} else {
tmp = im * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 3.7e-9: tmp = re else: tmp = im * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (re <= 3.7e-9) 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 <= 3.7e-9) tmp = re; else tmp = im * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 3.7e-9], re, N[(im * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 3.7 \cdot 10^{-9}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;im \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if re < 3.7e-9Initial 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.8%
Taylor expanded in re around 0 37.9%
if 3.7e-9 < 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-rr38.3%
Taylor expanded in im around 0 10.7%
Taylor expanded in im around inf 3.2%
Taylor expanded in re around 0 11.9%
Final simplification32.2%
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* -0.16666666666666666 (* re re)))))
double code(double re, double im) {
return re * (1.0 + (-0.16666666666666666 * (re * re)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (1.0d0 + ((-0.16666666666666666d0) * (re * re)))
end function
public static double code(double re, double im) {
return re * (1.0 + (-0.16666666666666666 * (re * re)));
}
def code(re, im): return re * (1.0 + (-0.16666666666666666 * (re * re)))
function code(re, im) return Float64(re * Float64(1.0 + Float64(-0.16666666666666666 * Float64(re * re)))) end
function tmp = code(re, im) tmp = re * (1.0 + (-0.16666666666666666 * (re * re))); end
code[re_, im_] := N[(re * N[(1.0 + N[(-0.16666666666666666 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(1 + -0.16666666666666666 \cdot \left(re \cdot re\right)\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%
Taylor expanded in im around 0 54.5%
Taylor expanded in re around 0 35.9%
unpow235.9%
Applied egg-rr35.9%
(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 54.5%
Taylor expanded in re around 0 30.2%
(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 54.5%
Applied egg-rr3.1%
pow-base-13.1%
metadata-eval3.1%
Simplified3.1%
metadata-eval3.1%
Applied egg-rr3.1%
herbie shell --seed 2024186
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))