
(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 12 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%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (<= im 1.8)
(* (* 0.5 (sin re)) (fma im im 2.0))
(if (<= im 1.35e+154)
(* (* 0.5 re) (+ (exp (- im)) (exp im)))
(* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 1.8) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else if (im <= 1.35e+154) {
tmp = (0.5 * re) * (exp(-im) + exp(im));
} else {
tmp = sin(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 1.8) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); elseif (im <= 1.35e+154) tmp = Float64(Float64(0.5 * re) * Float64(exp(Float64(-im)) + exp(im))); else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 1.8], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(N[(0.5 * re), $MachinePrecision] * N[(N[Exp[(-im)], $MachinePrecision] + N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.8:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \left(e^{-im} + e^{im}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 1.80000000000000004Initial 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 81.7%
Simplified81.7%
if 1.80000000000000004 < im < 1.35000000000000003e154Initial 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 68.2%
Simplified68.2%
if 1.35000000000000003e154 < 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%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification83.3%
(FPCore (re im) :precision binary64 (if (<= im 550.0) (sin re) (if (<= im 1.35e+154) (pow re -4.0) (* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = pow(re, -4.0);
} else {
tmp = sin(re) * (0.5 * 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 <= 550.0d0) then
tmp = sin(re)
else if (im <= 1.35d+154) then
tmp = re ** (-4.0d0)
else
tmp = sin(re) * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = Math.pow(re, -4.0);
} else {
tmp = Math.sin(re) * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 550.0: tmp = math.sin(re) elif im <= 1.35e+154: tmp = math.pow(re, -4.0) else: tmp = math.sin(re) * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 550.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = re ^ -4.0; else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 550.0) tmp = sin(re); elseif (im <= 1.35e+154) tmp = re ^ -4.0; else tmp = sin(re) * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 550.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.35e+154], N[Power[re, -4.0], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 550:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 550Initial 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 66.9%
if 550 < im < 1.35000000000000003e154Initial 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 68.2%
Simplified68.2%
Applied egg-rr23.5%
if 1.35000000000000003e154 < 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%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification68.1%
(FPCore (re im) :precision binary64 (if (<= im 620.0) (* (* 0.5 (sin re)) (fma im im 2.0)) (if (<= im 1.35e+154) (pow re -4.0) (* (sin re) (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 620.0) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else if (im <= 1.35e+154) {
tmp = pow(re, -4.0);
} else {
tmp = sin(re) * (0.5 * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 620.0) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); elseif (im <= 1.35e+154) tmp = re ^ -4.0; else tmp = Float64(sin(re) * Float64(0.5 * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 620.0], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[Power[re, -4.0], $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 620:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 620Initial 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 81.7%
Simplified81.7%
if 620 < im < 1.35000000000000003e154Initial 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 68.2%
Simplified68.2%
Applied egg-rr23.5%
if 1.35000000000000003e154 < 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%
Simplified100.0%
Taylor expanded in im around inf 100.0%
associate-*r*100.0%
*-commutative100.0%
Simplified100.0%
Final simplification79.4%
(FPCore (re im)
:precision binary64
(if (<= im 550.0)
(sin re)
(if (<= im 1.75e+152)
(pow re -4.0)
(* re (* (fma im im 2.0) (+ 0.5 (* -0.08333333333333333 (* re re))))))))
double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = sin(re);
} else if (im <= 1.75e+152) {
tmp = pow(re, -4.0);
} else {
tmp = re * (fma(im, im, 2.0) * (0.5 + (-0.08333333333333333 * (re * re))));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 550.0) tmp = sin(re); elseif (im <= 1.75e+152) tmp = re ^ -4.0; else tmp = Float64(re * Float64(fma(im, im, 2.0) * Float64(0.5 + Float64(-0.08333333333333333 * Float64(re * re))))); end return tmp end
code[re_, im_] := If[LessEqual[im, 550.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.75e+152], N[Power[re, -4.0], $MachinePrecision], N[(re * N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 + N[(-0.08333333333333333 * N[(re * re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 550:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.75 \cdot 10^{+152}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 + -0.08333333333333333 \cdot \left(re \cdot re\right)\right)\right)\\
\end{array}
\end{array}
if im < 550Initial 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 66.9%
if 550 < im < 1.74999999999999991e152Initial 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 68.2%
Simplified68.2%
Applied egg-rr23.5%
if 1.74999999999999991e152 < 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%
Simplified100.0%
Taylor expanded in re around 0 0.0%
associate-*r*0.0%
distribute-rgt-out84.2%
+-commutative84.2%
unpow284.2%
fma-define84.2%
Simplified84.2%
unpow284.2%
Applied egg-rr84.2%
Final simplification65.7%
(FPCore (re im)
:precision binary64
(if (<= im 680.0)
(sin re)
(if (or (<= im 1.22e+238) (not (<= im 6.4e+255)))
(pow re -4.0)
(* (pow re 3.0) -0.16666666666666666))))
double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = sin(re);
} else if ((im <= 1.22e+238) || !(im <= 6.4e+255)) {
tmp = pow(re, -4.0);
} else {
tmp = pow(re, 3.0) * -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 <= 680.0d0) then
tmp = sin(re)
else if ((im <= 1.22d+238) .or. (.not. (im <= 6.4d+255))) then
tmp = re ** (-4.0d0)
else
tmp = (re ** 3.0d0) * (-0.16666666666666666d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 680.0) {
tmp = Math.sin(re);
} else if ((im <= 1.22e+238) || !(im <= 6.4e+255)) {
tmp = Math.pow(re, -4.0);
} else {
tmp = Math.pow(re, 3.0) * -0.16666666666666666;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 680.0: tmp = math.sin(re) elif (im <= 1.22e+238) or not (im <= 6.4e+255): tmp = math.pow(re, -4.0) else: tmp = math.pow(re, 3.0) * -0.16666666666666666 return tmp
function code(re, im) tmp = 0.0 if (im <= 680.0) tmp = sin(re); elseif ((im <= 1.22e+238) || !(im <= 6.4e+255)) tmp = re ^ -4.0; else tmp = Float64((re ^ 3.0) * -0.16666666666666666); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 680.0) tmp = sin(re); elseif ((im <= 1.22e+238) || ~((im <= 6.4e+255))) tmp = re ^ -4.0; else tmp = (re ^ 3.0) * -0.16666666666666666; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 680.0], N[Sin[re], $MachinePrecision], If[Or[LessEqual[im, 1.22e+238], N[Not[LessEqual[im, 6.4e+255]], $MachinePrecision]], N[Power[re, -4.0], $MachinePrecision], N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 680:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.22 \cdot 10^{+238} \lor \neg \left(im \leq 6.4 \cdot 10^{+255}\right):\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;{re}^{3} \cdot -0.16666666666666666\\
\end{array}
\end{array}
if im < 680Initial 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 66.9%
if 680 < im < 1.2200000000000001e238 or 6.3999999999999996e255 < 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 re around 0 73.2%
Simplified73.2%
Applied egg-rr25.9%
if 1.2200000000000001e238 < im < 6.3999999999999996e255Initial 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%
Simplified100.0%
Taylor expanded in re around 0 0.0%
associate-*r*0.0%
distribute-rgt-out100.0%
+-commutative100.0%
unpow2100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in re around inf 75.0%
+-commutative75.0%
unpow275.0%
fma-undefine75.0%
Simplified75.0%
Taylor expanded in im around 0 75.2%
*-commutative75.2%
Simplified75.2%
Final simplification58.1%
(FPCore (re im) :precision binary64 (if (<= im 550.0) (sin re) (if (<= im 4.3e+158) (pow re -4.0) (* (fma im im 2.0) (* 0.5 re)))))
double code(double re, double im) {
double tmp;
if (im <= 550.0) {
tmp = sin(re);
} else if (im <= 4.3e+158) {
tmp = pow(re, -4.0);
} else {
tmp = fma(im, im, 2.0) * (0.5 * re);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 550.0) tmp = sin(re); elseif (im <= 4.3e+158) tmp = re ^ -4.0; else tmp = Float64(fma(im, im, 2.0) * Float64(0.5 * re)); end return tmp end
code[re_, im_] := If[LessEqual[im, 550.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.3e+158], N[Power[re, -4.0], $MachinePrecision], N[(N[(im * im + 2.0), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 550:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 4.3 \cdot 10^{+158}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(im, im, 2\right) \cdot \left(0.5 \cdot re\right)\\
\end{array}
\end{array}
if im < 550Initial 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 66.9%
if 550 < im < 4.3e158Initial 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 62.5%
Simplified62.5%
Applied egg-rr21.7%
if 4.3e158 < 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 re around 0 75.0%
Simplified75.0%
Taylor expanded in im around 0 75.0%
+-commutative75.0%
unpow275.0%
fma-define75.0%
Simplified75.0%
Final simplification63.8%
(FPCore (re im) :precision binary64 (if (<= im 800.0) (sin re) (if (<= im 4.3e+158) (pow re -4.0) (* 0.5 (* re (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 800.0) {
tmp = sin(re);
} else if (im <= 4.3e+158) {
tmp = pow(re, -4.0);
} 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 <= 800.0d0) then
tmp = sin(re)
else if (im <= 4.3d+158) then
tmp = re ** (-4.0d0)
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 <= 800.0) {
tmp = Math.sin(re);
} else if (im <= 4.3e+158) {
tmp = Math.pow(re, -4.0);
} else {
tmp = 0.5 * (re * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 800.0: tmp = math.sin(re) elif im <= 4.3e+158: tmp = math.pow(re, -4.0) else: tmp = 0.5 * (re * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 800.0) tmp = sin(re); elseif (im <= 4.3e+158) tmp = re ^ -4.0; else tmp = Float64(0.5 * Float64(re * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 800.0) tmp = sin(re); elseif (im <= 4.3e+158) tmp = re ^ -4.0; else tmp = 0.5 * (re * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 800.0], N[Sin[re], $MachinePrecision], If[LessEqual[im, 4.3e+158], N[Power[re, -4.0], $MachinePrecision], N[(0.5 * N[(re * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 800:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 4.3 \cdot 10^{+158}:\\
\;\;\;\;{re}^{-4}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 800Initial 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 66.9%
if 800 < im < 4.3e158Initial 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 62.5%
Simplified62.5%
Applied egg-rr21.7%
if 4.3e158 < 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 re around 0 75.0%
Simplified75.0%
Taylor expanded in im around 0 75.0%
+-commutative75.0%
unpow275.0%
fma-define75.0%
Simplified75.0%
Taylor expanded in im around inf 75.0%
Final simplification63.8%
(FPCore (re im) :precision binary64 (if (<= im 650.0) (sin re) (pow re -4.0)))
double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = sin(re);
} else {
tmp = pow(re, -4.0);
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 650.0d0) then
tmp = sin(re)
else
tmp = re ** (-4.0d0)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 650.0) {
tmp = Math.sin(re);
} else {
tmp = Math.pow(re, -4.0);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 650.0: tmp = math.sin(re) else: tmp = math.pow(re, -4.0) return tmp
function code(re, im) tmp = 0.0 if (im <= 650.0) tmp = sin(re); else tmp = re ^ -4.0; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 650.0) tmp = sin(re); else tmp = re ^ -4.0; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 650.0], N[Sin[re], $MachinePrecision], N[Power[re, -4.0], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 650:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;{re}^{-4}\\
\end{array}
\end{array}
if im < 650Initial 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 66.9%
if 650 < 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 re around 0 70.0%
Simplified70.0%
Applied egg-rr24.3%
Final simplification56.9%
(FPCore (re im) :precision binary64 (sin re))
double code(double re, double im) {
return sin(re);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = sin(re)
end function
public static double code(double re, double im) {
return Math.sin(re);
}
def code(re, im): return math.sin(re)
function code(re, im) return sin(re) end
function tmp = code(re, im) tmp = sin(re); end
code[re_, im_] := N[Sin[re], $MachinePrecision]
\begin{array}{l}
\\
\sin 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 51.8%
Final simplification51.8%
(FPCore (re im) :precision binary64 (if (<= re 1.25e+20) re (/ re (+ re (- re re)))))
double code(double re, double im) {
double tmp;
if (re <= 1.25e+20) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (re <= 1.25d+20) then
tmp = re
else
tmp = re / (re + (re - re))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 1.25e+20) {
tmp = re;
} else {
tmp = re / (re + (re - re));
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 1.25e+20: tmp = re else: tmp = re / (re + (re - re)) return tmp
function code(re, im) tmp = 0.0 if (re <= 1.25e+20) tmp = re; else tmp = Float64(re / Float64(re + Float64(re - re))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 1.25e+20) tmp = re; else tmp = re / (re + (re - re)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 1.25e+20], re, N[(re / N[(re + N[(re - re), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 1.25 \cdot 10^{+20}:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;\frac{re}{re + \left(re - re\right)}\\
\end{array}
\end{array}
if re < 1.25e20Initial 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 72.9%
Simplified72.9%
Taylor expanded in im around 0 37.0%
if 1.25e20 < 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 re around 0 16.5%
Simplified16.5%
Applied egg-rr6.5%
Final simplification29.8%
(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 re around 0 59.6%
Simplified59.6%
Taylor expanded in im around 0 28.9%
Final simplification28.9%
herbie shell --seed 2024059
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))