
(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 15 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 (* (* 0.5 (sin re)) (+ (exp im) (- 1.0 im))))
double code(double re, double im) {
return (0.5 * sin(re)) * (exp(im) + (1.0 - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * sin(re)) * (exp(im) + (1.0d0 - im))
end function
public static double code(double re, double im) {
return (0.5 * Math.sin(re)) * (Math.exp(im) + (1.0 - im));
}
def code(re, im): return (0.5 * math.sin(re)) * (math.exp(im) + (1.0 - im))
function code(re, im) return Float64(Float64(0.5 * sin(re)) * Float64(exp(im) + Float64(1.0 - im))) end
function tmp = code(re, im) tmp = (0.5 * sin(re)) * (exp(im) + (1.0 - im)); end
code[re_, im_] := N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[(1.0 - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot \sin re\right) \cdot \left(e^{im} + \left(1 - im\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 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Final simplification77.8%
(FPCore (re im)
:precision binary64
(if (or (<= im 4.8) (not (<= im 1e+103)))
(*
0.5
(*
(sin re)
(- (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))) im)))
(* (+ (exp im) 1.0) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if ((im <= 4.8) || !(im <= 1e+103)) {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
} else {
tmp = (exp(im) + 1.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 <= 4.8d0) .or. (.not. (im <= 1d+103))) then
tmp = 0.5d0 * (sin(re) * ((2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) - im))
else
tmp = (exp(im) + 1.0d0) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 4.8) || !(im <= 1e+103)) {
tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
} else {
tmp = (Math.exp(im) + 1.0) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 4.8) or not (im <= 1e+103): tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)) else: tmp = (math.exp(im) + 1.0) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if ((im <= 4.8) || !(im <= 1e+103)) tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); else tmp = Float64(Float64(exp(im) + 1.0) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 4.8) || ~((im <= 1e+103))) tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)); else tmp = (exp(im) + 1.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 4.8], N[Not[LessEqual[im, 1e+103]], $MachinePrecision]], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.8 \lor \neg \left(im \leq 10^{+103}\right):\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 4.79999999999999982 or 1e103 < 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 75.8%
neg-mul-175.8%
unsub-neg75.8%
Simplified75.8%
Taylor expanded in im around 0 74.8%
*-commutative74.8%
Simplified74.8%
Taylor expanded in re around inf 74.8%
if 4.79999999999999982 < im < 1e103Initial 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 90.5%
associate-*r*90.5%
*-commutative90.5%
+-commutative90.5%
associate--l+90.5%
Simplified90.5%
Taylor expanded in im around 0 90.5%
Final simplification76.1%
(FPCore (re im)
:precision binary64
(if (<= im 4.6)
(*
(* 0.5 (sin re))
(+ (+ 1.0 (* im (+ (* 0.5 im) -1.0))) (+ 1.0 (* im (+ 1.0 (* 0.5 im))))))
(if (<= im 1e+103)
(* (+ (exp im) 1.0) (* 0.5 re))
(*
0.5
(*
(sin re)
(-
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))
im))))))
double code(double re, double im) {
double tmp;
if (im <= 4.6) {
tmp = (0.5 * sin(re)) * ((1.0 + (im * ((0.5 * im) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1e+103) {
tmp = (exp(im) + 1.0) * (0.5 * re);
} else {
tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 4.6d0) then
tmp = (0.5d0 * sin(re)) * ((1.0d0 + (im * ((0.5d0 * im) + (-1.0d0)))) + (1.0d0 + (im * (1.0d0 + (0.5d0 * im)))))
else if (im <= 1d+103) then
tmp = (exp(im) + 1.0d0) * (0.5d0 * re)
else
tmp = 0.5d0 * (sin(re) * ((2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) - im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 4.6) {
tmp = (0.5 * Math.sin(re)) * ((1.0 + (im * ((0.5 * im) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im)))));
} else if (im <= 1e+103) {
tmp = (Math.exp(im) + 1.0) * (0.5 * re);
} else {
tmp = 0.5 * (Math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 4.6: tmp = (0.5 * math.sin(re)) * ((1.0 + (im * ((0.5 * im) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))) elif im <= 1e+103: tmp = (math.exp(im) + 1.0) * (0.5 * re) else: tmp = 0.5 * (math.sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 4.6) tmp = Float64(Float64(0.5 * sin(re)) * Float64(Float64(1.0 + Float64(im * Float64(Float64(0.5 * im) + -1.0))) + Float64(1.0 + Float64(im * Float64(1.0 + Float64(0.5 * im)))))); elseif (im <= 1e+103) tmp = Float64(Float64(exp(im) + 1.0) * Float64(0.5 * re)); else tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 4.6) tmp = (0.5 * sin(re)) * ((1.0 + (im * ((0.5 * im) + -1.0))) + (1.0 + (im * (1.0 + (0.5 * im))))); elseif (im <= 1e+103) tmp = (exp(im) + 1.0) * (0.5 * re); else tmp = 0.5 * (sin(re) * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 4.6], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 + N[(im * N[(N[(0.5 * im), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1e+103], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.6:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \left(\left(1 + im \cdot \left(0.5 \cdot im + -1\right)\right) + \left(1 + im \cdot \left(1 + 0.5 \cdot im\right)\right)\right)\\
\mathbf{elif}\;im \leq 10^{+103}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\right)\right)\\
\end{array}
\end{array}
if im < 4.5999999999999996Initial 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 91.2%
Taylor expanded in im around 0 91.1%
Taylor expanded in im around 0 86.8%
if 4.5999999999999996 < im < 1e103Initial 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 90.5%
associate-*r*90.5%
*-commutative90.5%
+-commutative90.5%
associate--l+90.5%
Simplified90.5%
Taylor expanded in im around 0 90.5%
if 1e103 < 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in re around inf 100.0%
Final simplification89.2%
(FPCore (re im) :precision binary64 (if (or (<= im 4.6) (not (<= im 1.9e+154))) (* 0.5 (* (sin re) (- (+ (* im (+ 1.0 (* 0.5 im))) 2.0) im))) (* (+ (exp im) 1.0) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if ((im <= 4.6) || !(im <= 1.9e+154)) {
tmp = 0.5 * (sin(re) * (((im * (1.0 + (0.5 * im))) + 2.0) - im));
} else {
tmp = (exp(im) + 1.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 <= 4.6d0) .or. (.not. (im <= 1.9d+154))) then
tmp = 0.5d0 * (sin(re) * (((im * (1.0d0 + (0.5d0 * im))) + 2.0d0) - im))
else
tmp = (exp(im) + 1.0d0) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 4.6) || !(im <= 1.9e+154)) {
tmp = 0.5 * (Math.sin(re) * (((im * (1.0 + (0.5 * im))) + 2.0) - im));
} else {
tmp = (Math.exp(im) + 1.0) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 4.6) or not (im <= 1.9e+154): tmp = 0.5 * (math.sin(re) * (((im * (1.0 + (0.5 * im))) + 2.0) - im)) else: tmp = (math.exp(im) + 1.0) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if ((im <= 4.6) || !(im <= 1.9e+154)) tmp = Float64(0.5 * Float64(sin(re) * Float64(Float64(Float64(im * Float64(1.0 + Float64(0.5 * im))) + 2.0) - im))); else tmp = Float64(Float64(exp(im) + 1.0) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 4.6) || ~((im <= 1.9e+154))) tmp = 0.5 * (sin(re) * (((im * (1.0 + (0.5 * im))) + 2.0) - im)); else tmp = (exp(im) + 1.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 4.6], N[Not[LessEqual[im, 1.9e+154]], $MachinePrecision]], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(N[(N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 4.6 \lor \neg \left(im \leq 1.9 \cdot 10^{+154}\right):\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot \left(\left(im \cdot \left(1 + 0.5 \cdot im\right) + 2\right) - im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 4.5999999999999996 or 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%
Taylor expanded in im around 0 74.6%
neg-mul-174.6%
unsub-neg74.6%
Simplified74.6%
Taylor expanded in im around 0 73.6%
*-commutative73.6%
Simplified73.6%
Taylor expanded in re around inf 73.6%
Taylor expanded in im around 0 88.4%
*-commutative88.4%
Simplified88.4%
if 4.5999999999999996 < 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%
Taylor expanded in im around 0 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 90.6%
associate-*r*90.6%
*-commutative90.6%
+-commutative90.6%
associate--l+90.6%
Simplified90.6%
Taylor expanded in im around 0 90.6%
Final simplification88.6%
(FPCore (re im) :precision binary64 (if (<= im 3.5) (sin re) (* (+ (exp im) 1.0) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if (im <= 3.5) {
tmp = sin(re);
} else {
tmp = (exp(im) + 1.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 <= 3.5d0) then
tmp = sin(re)
else
tmp = (exp(im) + 1.0d0) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.5) {
tmp = Math.sin(re);
} else {
tmp = (Math.exp(im) + 1.0) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.5: tmp = math.sin(re) else: tmp = (math.exp(im) + 1.0) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.5) tmp = sin(re); else tmp = Float64(Float64(exp(im) + 1.0) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.5) tmp = sin(re); else tmp = (exp(im) + 1.0) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.5], N[Sin[re], $MachinePrecision], N[(N[(N[Exp[im], $MachinePrecision] + 1.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.5:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(e^{im} + 1\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 3.5Initial 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 70.2%
if 3.5 < 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 83.9%
associate-*r*83.9%
*-commutative83.9%
+-commutative83.9%
associate--l+83.9%
Simplified83.9%
Taylor expanded in im around 0 83.9%
(FPCore (re im)
:precision binary64
(if (<= im 880.0)
(sin re)
(*
(* 0.5 re)
(+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))))))
double code(double re, double im) {
double tmp;
if (im <= 880.0) {
tmp = sin(re);
} else {
tmp = (0.5 * re) * (2.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 <= 880.0d0) then
tmp = sin(re)
else
tmp = (0.5d0 * re) * (2.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 <= 880.0) {
tmp = Math.sin(re);
} else {
tmp = (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 880.0: tmp = math.sin(re) else: tmp = (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) return tmp
function code(re, im) tmp = 0.0 if (im <= 880.0) tmp = sin(re); else tmp = Float64(Float64(0.5 * re) * Float64(2.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 <= 880.0) tmp = sin(re); else tmp = (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 880.0], N[Sin[re], $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(2.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 880:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right)\\
\end{array}
\end{array}
if im < 880Initial 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 70.2%
if 880 < 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 100.0%
neg-mul-1100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 83.9%
associate-*r*83.9%
*-commutative83.9%
+-commutative83.9%
associate--l+83.9%
Simplified83.9%
Taylor expanded in im around 0 83.9%
Taylor expanded in im around 0 63.7%
Final simplification68.6%
(FPCore (re im) :precision binary64 (* 0.5 (* re (- (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666)))))) im))))
double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (re * ((2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0)))))) - im))
end function
public static double code(double re, double im) {
return 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im));
}
def code(re, im): return 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im))
function code(re, im) return Float64(0.5 * Float64(re * Float64(Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666)))))) - im))) end
function tmp = code(re, im) tmp = 0.5 * (re * ((2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))) - im)); end
code[re_, im_] := N[(0.5 * N[(re * N[(N[(2.0 + N[(im * N[(1.0 + N[(im * N[(0.5 + N[(im * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(re \cdot \left(\left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\right)\right) - im\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 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in im around 0 69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in re around 0 45.3%
Final simplification45.3%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ 2.0 (* im (+ 1.0 (* im (+ 0.5 (* im 0.16666666666666666))))))))
double code(double re, double im) {
return (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * re) * (2.0d0 + (im * (1.0d0 + (im * (0.5d0 + (im * 0.16666666666666666d0))))))
end function
public static double code(double re, double im) {
return (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))));
}
def code(re, im): return (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666))))))
function code(re, im) return Float64(Float64(0.5 * re) * Float64(2.0 + Float64(im * Float64(1.0 + Float64(im * Float64(0.5 + Float64(im * 0.16666666666666666))))))) end
function tmp = code(re, im) tmp = (0.5 * re) * (2.0 + (im * (1.0 + (im * (0.5 + (im * 0.16666666666666666)))))); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(2.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}
\\
\left(0.5 \cdot re\right) \cdot \left(2 + im \cdot \left(1 + im \cdot \left(0.5 + im \cdot 0.16666666666666666\right)\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 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in re around 0 51.6%
associate-*r*51.6%
*-commutative51.6%
+-commutative51.6%
associate--l+51.6%
Simplified51.6%
Taylor expanded in im around 0 48.5%
Taylor expanded in im around 0 45.0%
Final simplification45.0%
(FPCore (re im) :precision binary64 (* 0.5 (* re (- (+ (* im (+ 1.0 (* 0.5 im))) 2.0) im))))
double code(double re, double im) {
return 0.5 * (re * (((im * (1.0 + (0.5 * im))) + 2.0) - im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (re * (((im * (1.0d0 + (0.5d0 * im))) + 2.0d0) - im))
end function
public static double code(double re, double im) {
return 0.5 * (re * (((im * (1.0 + (0.5 * im))) + 2.0) - im));
}
def code(re, im): return 0.5 * (re * (((im * (1.0 + (0.5 * im))) + 2.0) - im))
function code(re, im) return Float64(0.5 * Float64(re * Float64(Float64(Float64(im * Float64(1.0 + Float64(0.5 * im))) + 2.0) - im))) end
function tmp = code(re, im) tmp = 0.5 * (re * (((im * (1.0 + (0.5 * im))) + 2.0) - im)); end
code[re_, im_] := N[(0.5 * N[(re * N[(N[(N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision] - im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(re \cdot \left(\left(im \cdot \left(1 + 0.5 \cdot im\right) + 2\right) - im\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 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in im around 0 69.0%
*-commutative69.0%
Simplified69.0%
Taylor expanded in re around 0 45.3%
Taylor expanded in im around 0 53.5%
*-commutative77.9%
Simplified53.5%
Final simplification53.5%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ (* im (+ 1.0 (* 0.5 im))) 2.0)))
double code(double re, double im) {
return (0.5 * re) * ((im * (1.0 + (0.5 * im))) + 2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * re) * ((im * (1.0d0 + (0.5d0 * im))) + 2.0d0)
end function
public static double code(double re, double im) {
return (0.5 * re) * ((im * (1.0 + (0.5 * im))) + 2.0);
}
def code(re, im): return (0.5 * re) * ((im * (1.0 + (0.5 * im))) + 2.0)
function code(re, im) return Float64(Float64(0.5 * re) * Float64(Float64(im * Float64(1.0 + Float64(0.5 * im))) + 2.0)) end
function tmp = code(re, im) tmp = (0.5 * re) * ((im * (1.0 + (0.5 * im))) + 2.0); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(N[(im * N[(1.0 + N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \left(im \cdot \left(1 + 0.5 \cdot im\right) + 2\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 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in re around 0 51.6%
associate-*r*51.6%
*-commutative51.6%
+-commutative51.6%
associate--l+51.6%
Simplified51.6%
Taylor expanded in im around 0 48.5%
Taylor expanded in im around 0 53.2%
Final simplification53.2%
(FPCore (re im) :precision binary64 (if (<= re 2.25e+65) re (* (* re im) -0.5)))
double code(double re, double im) {
double tmp;
if (re <= 2.25e+65) {
tmp = re;
} else {
tmp = (re * im) * -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 <= 2.25d+65) then
tmp = re
else
tmp = (re * im) * (-0.5d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 2.25e+65) {
tmp = re;
} else {
tmp = (re * im) * -0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 2.25e+65: tmp = re else: tmp = (re * im) * -0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= 2.25e+65) tmp = re; else tmp = Float64(Float64(re * im) * -0.5); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 2.25e+65) tmp = re; else tmp = (re * im) * -0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 2.25e+65], re, N[(N[(re * im), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 2.25 \cdot 10^{+65}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\left(re \cdot im\right) \cdot -0.5\\
\end{array}
\end{array}
if re < 2.25e65Initial 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 77.7%
+-commutative77.7%
unpow277.7%
fma-define77.7%
Simplified77.7%
Taylor expanded in re around 0 59.6%
Taylor expanded in im around 0 35.9%
if 2.25e65 < 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%
Taylor expanded in im around 0 92.6%
neg-mul-192.6%
unsub-neg92.6%
Simplified92.6%
Taylor expanded in re around 0 32.7%
associate-*r*32.7%
*-commutative32.7%
+-commutative32.7%
associate--l+32.7%
Simplified32.7%
Taylor expanded in im around inf 10.3%
*-commutative10.3%
*-commutative10.3%
Simplified10.3%
(FPCore (re im) :precision binary64 (* (* 0.5 re) (+ im 2.0)))
double code(double re, double im) {
return (0.5 * re) * (im + 2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (0.5d0 * re) * (im + 2.0d0)
end function
public static double code(double re, double im) {
return (0.5 * re) * (im + 2.0);
}
def code(re, im): return (0.5 * re) * (im + 2.0)
function code(re, im) return Float64(Float64(0.5 * re) * Float64(im + 2.0)) end
function tmp = code(re, im) tmp = (0.5 * re) * (im + 2.0); end
code[re_, im_] := N[(N[(0.5 * re), $MachinePrecision] * N[(im + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot re\right) \cdot \left(im + 2\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 77.8%
neg-mul-177.8%
unsub-neg77.8%
Simplified77.8%
Taylor expanded in re around 0 51.6%
associate-*r*51.6%
*-commutative51.6%
+-commutative51.6%
associate--l+51.6%
Simplified51.6%
Taylor expanded in im around 0 48.5%
Taylor expanded in im around 0 34.3%
Final simplification34.3%
(FPCore (re im) :precision binary64 re)
double code(double re, double im) {
return re;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re
end function
public static double code(double re, double im) {
return re;
}
def code(re, im): return re
function code(re, im) return re end
function tmp = code(re, im) tmp = re; end
code[re_, im_] := re
\begin{array}{l}
\\
re
\end{array}
Initial program 100.0%
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 78.1%
+-commutative78.1%
unpow278.1%
fma-define78.1%
Simplified78.1%
Taylor expanded in re around 0 53.6%
Taylor expanded in im around 0 29.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%
Applied egg-rr3.0%
pow-base-13.0%
metadata-eval3.0%
Simplified3.0%
herbie shell --seed 2024116
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))