
(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 10 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-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (if (or (<= im 0.04) (not (<= im 1.35e+154))) (* (sin re) (+ (* 0.5 (* im im)) 1.0)) (* (+ (exp (- im)) (exp im)) (* 0.5 re))))
double code(double re, double im) {
double tmp;
if ((im <= 0.04) || !(im <= 1.35e+154)) {
tmp = sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = (exp(-im) + exp(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 <= 0.04d0) .or. (.not. (im <= 1.35d+154))) then
tmp = sin(re) * ((0.5d0 * (im * im)) + 1.0d0)
else
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 0.04) || !(im <= 1.35e+154)) {
tmp = Math.sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 0.04) or not (im <= 1.35e+154): tmp = math.sin(re) * ((0.5 * (im * im)) + 1.0) else: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) return tmp
function code(re, im) tmp = 0.0 if ((im <= 0.04) || !(im <= 1.35e+154)) tmp = Float64(sin(re) * Float64(Float64(0.5 * Float64(im * im)) + 1.0)); else tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 0.04) || ~((im <= 1.35e+154))) tmp = sin(re) * ((0.5 * (im * im)) + 1.0); else tmp = (exp(-im) + exp(im)) * (0.5 * re); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 0.04], N[Not[LessEqual[im, 1.35e+154]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 0.04 \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 0.0400000000000000008 or 1.35000000000000003e154 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 86.3%
Simplified86.3%
if 0.0400000000000000008 < im < 1.35000000000000003e154Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 89.3%
Simplified89.3%
Final simplification86.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* 0.5 (* im im))))
(if (<= im 0.5)
(+ (sin re) (* (sin re) t_0))
(if (<= im 1.35e+154)
(* (+ (exp (- im)) (exp im)) (* 0.5 re))
(* (sin re) (+ t_0 1.0))))))
double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double tmp;
if (im <= 0.5) {
tmp = sin(re) + (sin(re) * t_0);
} else if (im <= 1.35e+154) {
tmp = (exp(-im) + exp(im)) * (0.5 * re);
} else {
tmp = sin(re) * (t_0 + 1.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = 0.5d0 * (im * im)
if (im <= 0.5d0) then
tmp = sin(re) + (sin(re) * t_0)
else if (im <= 1.35d+154) then
tmp = (exp(-im) + exp(im)) * (0.5d0 * re)
else
tmp = sin(re) * (t_0 + 1.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = 0.5 * (im * im);
double tmp;
if (im <= 0.5) {
tmp = Math.sin(re) + (Math.sin(re) * t_0);
} else if (im <= 1.35e+154) {
tmp = (Math.exp(-im) + Math.exp(im)) * (0.5 * re);
} else {
tmp = Math.sin(re) * (t_0 + 1.0);
}
return tmp;
}
def code(re, im): t_0 = 0.5 * (im * im) tmp = 0 if im <= 0.5: tmp = math.sin(re) + (math.sin(re) * t_0) elif im <= 1.35e+154: tmp = (math.exp(-im) + math.exp(im)) * (0.5 * re) else: tmp = math.sin(re) * (t_0 + 1.0) return tmp
function code(re, im) t_0 = Float64(0.5 * Float64(im * im)) tmp = 0.0 if (im <= 0.5) tmp = Float64(sin(re) + Float64(sin(re) * t_0)); elseif (im <= 1.35e+154) tmp = Float64(Float64(exp(Float64(-im)) + exp(im)) * Float64(0.5 * re)); else tmp = Float64(sin(re) * Float64(t_0 + 1.0)); end return tmp end
function tmp_2 = code(re, im) t_0 = 0.5 * (im * im); tmp = 0.0; if (im <= 0.5) tmp = sin(re) + (sin(re) * t_0); elseif (im <= 1.35e+154) tmp = (exp(-im) + exp(im)) * (0.5 * re); else tmp = sin(re) * (t_0 + 1.0); end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 0.5], N[(N[Sin[re], $MachinePrecision] + N[(N[Sin[re], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(t$95$0 + 1.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(im \cdot im\right)\\
\mathbf{if}\;im \leq 0.5:\\
\;\;\;\;\sin re + \sin re \cdot t_0\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{-im} + e^{im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(t_0 + 1\right)\\
\end{array}
\end{array}
if im < 0.5Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 84.0%
Simplified84.0%
if 0.5 < im < 1.35000000000000003e154Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 89.3%
Simplified89.3%
if 1.35000000000000003e154 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
Simplified100.0%
Final simplification86.7%
(FPCore (re im)
:precision binary64
(let* ((t_0 (* (sin re) (+ (* 0.5 (* im im)) 1.0))))
(if (<= im 8.6e+14)
t_0
(if (<= im 6.6e+47)
(pow re -512.0)
(if (<= im 1.35e+154)
(/ (* re (- 1.0 (* (pow im 4.0) 0.25))) (- 1.0 (* im (* 0.5 im))))
t_0)))))
double code(double re, double im) {
double t_0 = sin(re) * ((0.5 * (im * im)) + 1.0);
double tmp;
if (im <= 8.6e+14) {
tmp = t_0;
} else if (im <= 6.6e+47) {
tmp = pow(re, -512.0);
} else if (im <= 1.35e+154) {
tmp = (re * (1.0 - (pow(im, 4.0) * 0.25))) / (1.0 - (im * (0.5 * im)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: t_0
real(8) :: tmp
t_0 = sin(re) * ((0.5d0 * (im * im)) + 1.0d0)
if (im <= 8.6d+14) then
tmp = t_0
else if (im <= 6.6d+47) then
tmp = re ** (-512.0d0)
else if (im <= 1.35d+154) then
tmp = (re * (1.0d0 - ((im ** 4.0d0) * 0.25d0))) / (1.0d0 - (im * (0.5d0 * im)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double re, double im) {
double t_0 = Math.sin(re) * ((0.5 * (im * im)) + 1.0);
double tmp;
if (im <= 8.6e+14) {
tmp = t_0;
} else if (im <= 6.6e+47) {
tmp = Math.pow(re, -512.0);
} else if (im <= 1.35e+154) {
tmp = (re * (1.0 - (Math.pow(im, 4.0) * 0.25))) / (1.0 - (im * (0.5 * im)));
} else {
tmp = t_0;
}
return tmp;
}
def code(re, im): t_0 = math.sin(re) * ((0.5 * (im * im)) + 1.0) tmp = 0 if im <= 8.6e+14: tmp = t_0 elif im <= 6.6e+47: tmp = math.pow(re, -512.0) elif im <= 1.35e+154: tmp = (re * (1.0 - (math.pow(im, 4.0) * 0.25))) / (1.0 - (im * (0.5 * im))) else: tmp = t_0 return tmp
function code(re, im) t_0 = Float64(sin(re) * Float64(Float64(0.5 * Float64(im * im)) + 1.0)) tmp = 0.0 if (im <= 8.6e+14) tmp = t_0; elseif (im <= 6.6e+47) tmp = re ^ -512.0; elseif (im <= 1.35e+154) tmp = Float64(Float64(re * Float64(1.0 - Float64((im ^ 4.0) * 0.25))) / Float64(1.0 - Float64(im * Float64(0.5 * im)))); else tmp = t_0; end return tmp end
function tmp_2 = code(re, im) t_0 = sin(re) * ((0.5 * (im * im)) + 1.0); tmp = 0.0; if (im <= 8.6e+14) tmp = t_0; elseif (im <= 6.6e+47) tmp = re ^ -512.0; elseif (im <= 1.35e+154) tmp = (re * (1.0 - ((im ^ 4.0) * 0.25))) / (1.0 - (im * (0.5 * im))); else tmp = t_0; end tmp_2 = tmp; end
code[re_, im_] := Block[{t$95$0 = N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[im, 8.6e+14], t$95$0, If[LessEqual[im, 6.6e+47], N[Power[re, -512.0], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(re * N[(1.0 - N[(N[Power[im, 4.0], $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 - N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\mathbf{if}\;im \leq 8.6 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;im \leq 6.6 \cdot 10^{+47}:\\
\;\;\;\;{re}^{-512}\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{re \cdot \left(1 - {im}^{4} \cdot 0.25\right)}{1 - im \cdot \left(0.5 \cdot im\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if im < 8.6e14 or 1.35000000000000003e154 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 86.0%
Simplified86.0%
if 8.6e14 < im < 6.5999999999999998e47Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 75.0%
Simplified75.0%
Applied egg-rr38.3%
if 6.5999999999999998e47 < im < 1.35000000000000003e154Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 4.4%
Simplified4.4%
Taylor expanded in re around 0 18.8%
Simplified18.8%
Taylor expanded in re around 0 18.8%
distribute-lft-in18.8%
*-rgt-identity18.8%
unpow218.8%
*-commutative18.8%
associate-*r*18.8%
associate-*r*18.8%
*-commutative18.8%
+-commutative18.8%
associate-*r*18.8%
*-commutative18.8%
associate-*r*18.8%
*-commutative18.8%
associate-*r*18.8%
fma-def18.8%
Simplified18.8%
fma-udef18.8%
*-commutative18.8%
associate-*r*18.8%
associate-*r*18.8%
+-commutative18.8%
distribute-rgt1-in18.8%
+-commutative18.8%
flip-+64.1%
associate-*l/64.1%
Applied egg-rr64.1%
Final simplification82.9%
(FPCore (re im) :precision binary64 (if (or (<= im 8.6e+14) (not (<= im 1.35e+154))) (* (sin re) (+ (* 0.5 (* im im)) 1.0)) (pow re -512.0)))
double code(double re, double im) {
double tmp;
if ((im <= 8.6e+14) || !(im <= 1.35e+154)) {
tmp = sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = pow(re, -512.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 8.6d+14) .or. (.not. (im <= 1.35d+154))) then
tmp = sin(re) * ((0.5d0 * (im * im)) + 1.0d0)
else
tmp = re ** (-512.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 8.6e+14) || !(im <= 1.35e+154)) {
tmp = Math.sin(re) * ((0.5 * (im * im)) + 1.0);
} else {
tmp = Math.pow(re, -512.0);
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 8.6e+14) or not (im <= 1.35e+154): tmp = math.sin(re) * ((0.5 * (im * im)) + 1.0) else: tmp = math.pow(re, -512.0) return tmp
function code(re, im) tmp = 0.0 if ((im <= 8.6e+14) || !(im <= 1.35e+154)) tmp = Float64(sin(re) * Float64(Float64(0.5 * Float64(im * im)) + 1.0)); else tmp = re ^ -512.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 8.6e+14) || ~((im <= 1.35e+154))) tmp = sin(re) * ((0.5 * (im * im)) + 1.0); else tmp = re ^ -512.0; end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 8.6e+14], N[Not[LessEqual[im, 1.35e+154]], $MachinePrecision]], N[(N[Sin[re], $MachinePrecision] * N[(N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[Power[re, -512.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8.6 \cdot 10^{+14} \lor \neg \left(im \leq 1.35 \cdot 10^{+154}\right):\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot \left(im \cdot im\right) + 1\right)\\
\mathbf{else}:\\
\;\;\;\;{re}^{-512}\\
\end{array}
\end{array}
if im < 8.6e14 or 1.35000000000000003e154 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 86.0%
Simplified86.0%
if 8.6e14 < im < 1.35000000000000003e154Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 88.9%
Simplified88.9%
Applied egg-rr37.5%
Final simplification80.9%
(FPCore (re im) :precision binary64 (if (<= im 8.6e+14) (sin re) (if (<= im 1.55e+148) (pow re -512.0) (* re (+ 1.0 (* im (* 0.5 im)))))))
double code(double re, double im) {
double tmp;
if (im <= 8.6e+14) {
tmp = sin(re);
} else if (im <= 1.55e+148) {
tmp = pow(re, -512.0);
} else {
tmp = re * (1.0 + (im * (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 <= 8.6d+14) then
tmp = sin(re)
else if (im <= 1.55d+148) then
tmp = re ** (-512.0d0)
else
tmp = re * (1.0d0 + (im * (0.5d0 * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 8.6e+14) {
tmp = Math.sin(re);
} else if (im <= 1.55e+148) {
tmp = Math.pow(re, -512.0);
} else {
tmp = re * (1.0 + (im * (0.5 * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 8.6e+14: tmp = math.sin(re) elif im <= 1.55e+148: tmp = math.pow(re, -512.0) else: tmp = re * (1.0 + (im * (0.5 * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 8.6e+14) tmp = sin(re); elseif (im <= 1.55e+148) tmp = re ^ -512.0; else tmp = Float64(re * Float64(1.0 + Float64(im * Float64(0.5 * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 8.6e+14) tmp = sin(re); elseif (im <= 1.55e+148) tmp = re ^ -512.0; else tmp = re * (1.0 + (im * (0.5 * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 8.6e+14], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.55e+148], N[Power[re, -512.0], $MachinePrecision], N[(re * N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 8.6 \cdot 10^{+14}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.55 \cdot 10^{+148}:\\
\;\;\;\;{re}^{-512}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 8.6e14Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 66.5%
if 8.6e14 < im < 1.54999999999999988e148Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 88.0%
Simplified88.0%
Applied egg-rr36.4%
if 1.54999999999999988e148 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 94.9%
Simplified94.9%
Taylor expanded in re around 0 66.8%
Simplified41.0%
Taylor expanded in re around 0 66.8%
unpow266.8%
*-commutative66.8%
associate-*r*66.8%
Simplified66.8%
Final simplification63.6%
(FPCore (re im) :precision binary64 (if (<= im 5.1e-5) (sin re) (* re (+ 1.0 (* im (* 0.5 im))))))
double code(double re, double im) {
double tmp;
if (im <= 5.1e-5) {
tmp = sin(re);
} else {
tmp = re * (1.0 + (im * (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 <= 5.1d-5) then
tmp = sin(re)
else
tmp = re * (1.0d0 + (im * (0.5d0 * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.1e-5) {
tmp = Math.sin(re);
} else {
tmp = re * (1.0 + (im * (0.5 * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.1e-5: tmp = math.sin(re) else: tmp = re * (1.0 + (im * (0.5 * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.1e-5) tmp = sin(re); else tmp = Float64(re * Float64(1.0 + Float64(im * Float64(0.5 * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.1e-5) tmp = sin(re); else tmp = re * (1.0 + (im * (0.5 * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.1e-5], N[Sin[re], $MachinePrecision], N[(re * N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.1 \cdot 10^{-5}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 5.09999999999999996e-5Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 67.1%
if 5.09999999999999996e-5 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 57.3%
Simplified57.3%
Taylor expanded in re around 0 43.6%
Simplified29.1%
Taylor expanded in re around 0 43.6%
unpow243.6%
*-commutative43.6%
associate-*r*43.6%
Simplified43.6%
Final simplification61.2%
(FPCore (re im) :precision binary64 (if (<= im 450.0) re (* re (* 0.5 (* im im)))))
double code(double re, double im) {
double tmp;
if (im <= 450.0) {
tmp = re;
} else {
tmp = re * (0.5 * (im * im));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 450.0d0) then
tmp = re
else
tmp = re * (0.5d0 * (im * im))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 450.0) {
tmp = re;
} else {
tmp = re * (0.5 * (im * im));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 450.0: tmp = re else: tmp = re * (0.5 * (im * im)) return tmp
function code(re, im) tmp = 0.0 if (im <= 450.0) tmp = re; else tmp = Float64(re * Float64(0.5 * Float64(im * im))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 450.0) tmp = re; else tmp = re * (0.5 * (im * im)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 450.0], re, N[(re * N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 450:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 450Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 62.7%
Simplified62.7%
Taylor expanded in im around 0 36.6%
if 450 < im Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 56.7%
Simplified56.7%
Taylor expanded in re around 0 43.3%
Simplified28.4%
Taylor expanded in re around 0 43.3%
distribute-lft-in43.3%
*-rgt-identity43.3%
unpow243.3%
*-commutative43.3%
associate-*r*43.3%
associate-*r*28.4%
*-commutative28.4%
+-commutative28.4%
associate-*r*28.4%
*-commutative28.4%
associate-*r*43.3%
*-commutative43.3%
associate-*r*43.3%
fma-def43.3%
Simplified43.3%
Taylor expanded in im around inf 43.3%
*-commutative43.3%
unpow243.3%
*-commutative43.3%
associate-*r*43.3%
*-commutative43.3%
Simplified43.3%
Final simplification38.2%
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* im (* 0.5 im)))))
double code(double re, double im) {
return re * (1.0 + (im * (0.5 * im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (1.0d0 + (im * (0.5d0 * im)))
end function
public static double code(double re, double im) {
return re * (1.0 + (im * (0.5 * im)));
}
def code(re, im): return re * (1.0 + (im * (0.5 * im)))
function code(re, im) return Float64(re * Float64(1.0 + Float64(im * Float64(0.5 * im)))) end
function tmp = code(re, im) tmp = re * (1.0 + (im * (0.5 * im))); end
code[re_, im_] := N[(re * N[(1.0 + N[(im * N[(0.5 * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(1 + im \cdot \left(0.5 \cdot im\right)\right)
\end{array}
Initial program 100.0%
distribute-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in im around 0 77.3%
Simplified77.3%
Taylor expanded in re around 0 66.1%
Simplified58.8%
Taylor expanded in re around 0 50.9%
unpow250.9%
*-commutative50.9%
associate-*r*50.9%
Simplified50.9%
Final simplification50.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-lft-in100.0%
*-commutative100.0%
cancel-sign-sub100.0%
distribute-lft-neg-out100.0%
*-commutative100.0%
distribute-rgt-neg-out100.0%
neg-mul-1100.0%
associate-*r*100.0%
distribute-rgt-out--100.0%
sub-neg100.0%
neg-sub0100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in re around 0 66.3%
Simplified66.3%
Taylor expanded in im around 0 28.3%
Final simplification28.3%
herbie shell --seed 2023292
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))