
(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 14 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 (* (sin re) (fma 0.5 (exp im) (/ 0.5 (exp im)))))
double code(double re, double im) {
return sin(re) * fma(0.5, exp(im), (0.5 / exp(im)));
}
function code(re, im) return Float64(sin(re) * fma(0.5, exp(im), Float64(0.5 / exp(im)))) end
code[re_, im_] := N[(N[Sin[re], $MachinePrecision] * N[(0.5 * N[Exp[im], $MachinePrecision] + N[(0.5 / N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sin re \cdot \mathsf{fma}\left(0.5, e^{im}, \frac{0.5}{e^{im}}\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im) :precision binary64 (* (* (sin re) 0.5) (+ (exp im) (exp (- im)))))
double code(double re, double im) {
return (sin(re) * 0.5) * (exp(im) + exp(-im));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = (sin(re) * 0.5d0) * (exp(im) + exp(-im))
end function
public static double code(double re, double im) {
return (Math.sin(re) * 0.5) * (Math.exp(im) + Math.exp(-im));
}
def code(re, im): return (math.sin(re) * 0.5) * (math.exp(im) + math.exp(-im))
function code(re, im) return Float64(Float64(sin(re) * 0.5) * Float64(exp(im) + exp(Float64(-im)))) end
function tmp = code(re, im) tmp = (sin(re) * 0.5) * (exp(im) + exp(-im)); end
code[re_, im_] := N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\sin re \cdot 0.5\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 (<= im 1.35) (+ (sin re) (* 0.5 (* (sin re) (* im im)))) (* (sin re) (+ 0.001953125 (* 0.5 (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= 1.35) {
tmp = sin(re) + (0.5 * (sin(re) * (im * im)));
} else {
tmp = sin(re) * (0.001953125 + (0.5 * exp(im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.35d0) then
tmp = sin(re) + (0.5d0 * (sin(re) * (im * im)))
else
tmp = sin(re) * (0.001953125d0 + (0.5d0 * exp(im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.35) {
tmp = Math.sin(re) + (0.5 * (Math.sin(re) * (im * im)));
} else {
tmp = Math.sin(re) * (0.001953125 + (0.5 * Math.exp(im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.35: tmp = math.sin(re) + (0.5 * (math.sin(re) * (im * im))) else: tmp = math.sin(re) * (0.001953125 + (0.5 * math.exp(im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.35) tmp = Float64(sin(re) + Float64(0.5 * Float64(sin(re) * Float64(im * im)))); else tmp = Float64(sin(re) * Float64(0.001953125 + Float64(0.5 * exp(im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.35) tmp = sin(re) + (0.5 * (sin(re) * (im * im))); else tmp = sin(re) * (0.001953125 + (0.5 * exp(im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.35], N[(N[Sin[re], $MachinePrecision] + N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.001953125 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.35:\\
\;\;\;\;\sin re + 0.5 \cdot \left(\sin re \cdot \left(im \cdot im\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.001953125 + 0.5 \cdot e^{im}\right)\\
\end{array}
\end{array}
if im < 1.3500000000000001Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 84.4%
unpow284.4%
Simplified84.4%
if 1.3500000000000001 < im Initial program 99.9%
distribute-rgt-in99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
cancel-sign-sub99.9%
distribute-lft-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
distribute-rgt-in99.9%
distribute-lft-in99.9%
Simplified99.9%
Applied egg-rr99.1%
Taylor expanded in re around inf 99.1%
Final simplification88.1%
(FPCore (re im) :precision binary64 (if (<= im 1.35) (* (* (sin re) 0.5) (+ (* im im) 2.0)) (* (sin re) (+ 0.001953125 (* 0.5 (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= 1.35) {
tmp = (sin(re) * 0.5) * ((im * im) + 2.0);
} else {
tmp = sin(re) * (0.001953125 + (0.5 * exp(im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 1.35d0) then
tmp = (sin(re) * 0.5d0) * ((im * im) + 2.0d0)
else
tmp = sin(re) * (0.001953125d0 + (0.5d0 * exp(im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1.35) {
tmp = (Math.sin(re) * 0.5) * ((im * im) + 2.0);
} else {
tmp = Math.sin(re) * (0.001953125 + (0.5 * Math.exp(im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1.35: tmp = (math.sin(re) * 0.5) * ((im * im) + 2.0) else: tmp = math.sin(re) * (0.001953125 + (0.5 * math.exp(im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 1.35) tmp = Float64(Float64(sin(re) * 0.5) * Float64(Float64(im * im) + 2.0)); else tmp = Float64(sin(re) * Float64(0.001953125 + Float64(0.5 * exp(im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1.35) tmp = (sin(re) * 0.5) * ((im * im) + 2.0); else tmp = sin(re) * (0.001953125 + (0.5 * exp(im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1.35], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(N[Sin[re], $MachinePrecision] * N[(0.001953125 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1.35:\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(im \cdot im + 2\right)\\
\mathbf{else}:\\
\;\;\;\;\sin re \cdot \left(0.001953125 + 0.5 \cdot e^{im}\right)\\
\end{array}
\end{array}
if im < 1.3500000000000001Initial 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.4%
unpow284.4%
Simplified84.4%
if 1.3500000000000001 < im Initial program 99.9%
distribute-rgt-in99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
cancel-sign-sub99.9%
distribute-lft-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
distribute-rgt-in99.9%
distribute-lft-in99.9%
Simplified99.9%
Applied egg-rr99.1%
Taylor expanded in re around inf 99.1%
Final simplification88.1%
(FPCore (re im) :precision binary64 (if (or (<= im 6.2) (not (<= im 6.4e+150))) (* (* (sin re) 0.5) (+ (* im im) 2.0)) (* re (+ 0.001953125 (* 0.5 (exp im))))))
double code(double re, double im) {
double tmp;
if ((im <= 6.2) || !(im <= 6.4e+150)) {
tmp = (sin(re) * 0.5) * ((im * im) + 2.0);
} else {
tmp = re * (0.001953125 + (0.5 * exp(im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if ((im <= 6.2d0) .or. (.not. (im <= 6.4d+150))) then
tmp = (sin(re) * 0.5d0) * ((im * im) + 2.0d0)
else
tmp = re * (0.001953125d0 + (0.5d0 * exp(im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if ((im <= 6.2) || !(im <= 6.4e+150)) {
tmp = (Math.sin(re) * 0.5) * ((im * im) + 2.0);
} else {
tmp = re * (0.001953125 + (0.5 * Math.exp(im)));
}
return tmp;
}
def code(re, im): tmp = 0 if (im <= 6.2) or not (im <= 6.4e+150): tmp = (math.sin(re) * 0.5) * ((im * im) + 2.0) else: tmp = re * (0.001953125 + (0.5 * math.exp(im))) return tmp
function code(re, im) tmp = 0.0 if ((im <= 6.2) || !(im <= 6.4e+150)) tmp = Float64(Float64(sin(re) * 0.5) * Float64(Float64(im * im) + 2.0)); else tmp = Float64(re * Float64(0.001953125 + Float64(0.5 * exp(im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if ((im <= 6.2) || ~((im <= 6.4e+150))) tmp = (sin(re) * 0.5) * ((im * im) + 2.0); else tmp = re * (0.001953125 + (0.5 * exp(im))); end tmp_2 = tmp; end
code[re_, im_] := If[Or[LessEqual[im, 6.2], N[Not[LessEqual[im, 6.4e+150]], $MachinePrecision]], N[(N[(N[Sin[re], $MachinePrecision] * 0.5), $MachinePrecision] * N[(N[(im * im), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.001953125 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.2 \lor \neg \left(im \leq 6.4 \cdot 10^{+150}\right):\\
\;\;\;\;\left(\sin re \cdot 0.5\right) \cdot \left(im \cdot im + 2\right)\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.001953125 + 0.5 \cdot e^{im}\right)\\
\end{array}
\end{array}
if im < 6.20000000000000018 or 6.40000000000000031e150 < 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.2%
unpow286.2%
Simplified86.2%
if 6.20000000000000018 < im < 6.40000000000000031e150Initial program 99.9%
distribute-rgt-in99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
cancel-sign-sub99.9%
distribute-lft-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
distribute-rgt-in99.9%
distribute-lft-in99.9%
Simplified99.9%
Applied egg-rr99.9%
Taylor expanded in re around 0 88.2%
Final simplification86.4%
(FPCore (re im) :precision binary64 (if (<= im 6.2) (sin re) (* re (+ 0.001953125 (* 0.5 (exp im))))))
double code(double re, double im) {
double tmp;
if (im <= 6.2) {
tmp = sin(re);
} else {
tmp = re * (0.001953125 + (0.5 * exp(im)));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 6.2d0) then
tmp = sin(re)
else
tmp = re * (0.001953125d0 + (0.5d0 * exp(im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 6.2) {
tmp = Math.sin(re);
} else {
tmp = re * (0.001953125 + (0.5 * Math.exp(im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 6.2: tmp = math.sin(re) else: tmp = re * (0.001953125 + (0.5 * math.exp(im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 6.2) tmp = sin(re); else tmp = Float64(re * Float64(0.001953125 + Float64(0.5 * exp(im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 6.2) tmp = sin(re); else tmp = re * (0.001953125 + (0.5 * exp(im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 6.2], N[Sin[re], $MachinePrecision], N[(re * N[(0.001953125 + N[(0.5 * N[Exp[im], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.2:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.001953125 + 0.5 \cdot e^{im}\right)\\
\end{array}
\end{array}
if im < 6.20000000000000018Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 64.4%
if 6.20000000000000018 < im Initial program 99.9%
distribute-rgt-in99.9%
+-commutative99.9%
associate-*r*99.9%
associate-*r*99.9%
distribute-rgt-out99.9%
cancel-sign-sub99.9%
distribute-lft-neg-in99.9%
neg-mul-199.9%
*-commutative99.9%
sub-neg99.9%
*-commutative99.9%
neg-mul-199.9%
remove-double-neg99.9%
distribute-rgt-in99.9%
distribute-lft-in99.9%
Simplified99.9%
Applied egg-rr99.9%
Taylor expanded in re around 0 79.7%
Final simplification68.2%
(FPCore (re im) :precision binary64 (if (<= im 240000000000.0) (sin re) (* re (+ 1.0 (* 0.5 (* im im))))))
double code(double re, double im) {
double tmp;
if (im <= 240000000000.0) {
tmp = sin(re);
} else {
tmp = re * (1.0 + (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 <= 240000000000.0d0) then
tmp = sin(re)
else
tmp = re * (1.0d0 + (0.5d0 * (im * im)))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 240000000000.0) {
tmp = Math.sin(re);
} else {
tmp = re * (1.0 + (0.5 * (im * im)));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 240000000000.0: tmp = math.sin(re) else: tmp = re * (1.0 + (0.5 * (im * im))) return tmp
function code(re, im) tmp = 0.0 if (im <= 240000000000.0) tmp = sin(re); else tmp = Float64(re * Float64(1.0 + Float64(0.5 * Float64(im * im)))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 240000000000.0) tmp = sin(re); else tmp = re * (1.0 + (0.5 * (im * im))); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 240000000000.0], N[Sin[re], $MachinePrecision], N[(re * N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 240000000000:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)\\
\end{array}
\end{array}
if im < 2.4e11Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 62.6%
if 2.4e11 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 53.6%
unpow253.6%
Simplified53.6%
Taylor expanded in im around 0 53.6%
unpow253.6%
associate-*r*39.0%
associate-*r*39.0%
*-commutative39.0%
associate-*r*39.0%
*-commutative39.0%
Simplified39.0%
Taylor expanded in re around 0 43.2%
unpow243.2%
Simplified43.2%
Final simplification58.2%
(FPCore (re im) :precision binary64 (if (<= im 1050.0) (* 0.5 (* re 2.0)) (+ 0.08333333333333333 (/ (/ 0.25 re) re))))
double code(double re, double im) {
double tmp;
if (im <= 1050.0) {
tmp = 0.5 * (re * 2.0);
} else {
tmp = 0.08333333333333333 + ((0.25 / 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 <= 1050.0d0) then
tmp = 0.5d0 * (re * 2.0d0)
else
tmp = 0.08333333333333333d0 + ((0.25d0 / re) / re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1050.0) {
tmp = 0.5 * (re * 2.0);
} else {
tmp = 0.08333333333333333 + ((0.25 / re) / re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1050.0: tmp = 0.5 * (re * 2.0) else: tmp = 0.08333333333333333 + ((0.25 / re) / re) return tmp
function code(re, im) tmp = 0.0 if (im <= 1050.0) tmp = Float64(0.5 * Float64(re * 2.0)); else tmp = Float64(0.08333333333333333 + Float64(Float64(0.25 / re) / re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1050.0) tmp = 0.5 * (re * 2.0); else tmp = 0.08333333333333333 + ((0.25 / re) / re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1050.0], N[(0.5 * N[(re * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.08333333333333333 + N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1050:\\
\;\;\;\;0.5 \cdot \left(re \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;0.08333333333333333 + \frac{\frac{0.25}{re}}{re}\\
\end{array}
\end{array}
if im < 1050Initial 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 64.1%
Taylor expanded in im around 0 35.9%
if 1050 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Applied egg-rr14.9%
Taylor expanded in re around 0 14.9%
associate-*r/14.9%
metadata-eval14.9%
unpow214.9%
associate-/r*14.9%
Simplified14.9%
Final simplification31.0%
(FPCore (re im) :precision binary64 (* re (+ 1.0 (* 0.5 (* im im)))))
double code(double re, double im) {
return re * (1.0 + (0.5 * (im * im)));
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = re * (1.0d0 + (0.5d0 * (im * im)))
end function
public static double code(double re, double im) {
return re * (1.0 + (0.5 * (im * im)));
}
def code(re, im): return re * (1.0 + (0.5 * (im * im)))
function code(re, im) return Float64(re * Float64(1.0 + Float64(0.5 * Float64(im * im)))) end
function tmp = code(re, im) tmp = re * (1.0 + (0.5 * (im * im))); end
code[re_, im_] := N[(re * N[(1.0 + N[(0.5 * N[(im * im), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
re \cdot \left(1 + 0.5 \cdot \left(im \cdot im\right)\right)
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 75.3%
unpow275.3%
Simplified75.3%
Taylor expanded in im around 0 75.3%
unpow275.3%
associate-*r*68.0%
associate-*r*68.0%
*-commutative68.0%
associate-*r*68.0%
*-commutative68.0%
Simplified68.0%
Taylor expanded in re around 0 50.8%
unpow250.8%
Simplified50.8%
Final simplification50.8%
(FPCore (re im) :precision binary64 (if (<= im 1060.0) (* 0.5 (* re 2.0)) (/ 0.25 (* re re))))
double code(double re, double im) {
double tmp;
if (im <= 1060.0) {
tmp = 0.5 * (re * 2.0);
} else {
tmp = 0.25 / (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 <= 1060.0d0) then
tmp = 0.5d0 * (re * 2.0d0)
else
tmp = 0.25d0 / (re * re)
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 1060.0) {
tmp = 0.5 * (re * 2.0);
} else {
tmp = 0.25 / (re * re);
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 1060.0: tmp = 0.5 * (re * 2.0) else: tmp = 0.25 / (re * re) return tmp
function code(re, im) tmp = 0.0 if (im <= 1060.0) tmp = Float64(0.5 * Float64(re * 2.0)); else tmp = Float64(0.25 / Float64(re * re)); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 1060.0) tmp = 0.5 * (re * 2.0); else tmp = 0.25 / (re * re); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 1060.0], N[(0.5 * N[(re * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.25 / N[(re * re), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 1060:\\
\;\;\;\;0.5 \cdot \left(re \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{re \cdot re}\\
\end{array}
\end{array}
if im < 1060Initial 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 64.1%
Taylor expanded in im around 0 35.9%
if 1060 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Applied egg-rr14.9%
Taylor expanded in re around 0 14.8%
unpow214.8%
Simplified14.8%
Final simplification31.0%
(FPCore (re im) :precision binary64 (if (<= im 720.0) (* 0.5 (* re 2.0)) (/ (/ 0.25 re) re)))
double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = 0.5 * (re * 2.0);
} else {
tmp = (0.25 / 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 <= 720.0d0) then
tmp = 0.5d0 * (re * 2.0d0)
else
tmp = (0.25d0 / re) / re
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 720.0) {
tmp = 0.5 * (re * 2.0);
} else {
tmp = (0.25 / re) / re;
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 720.0: tmp = 0.5 * (re * 2.0) else: tmp = (0.25 / re) / re return tmp
function code(re, im) tmp = 0.0 if (im <= 720.0) tmp = Float64(0.5 * Float64(re * 2.0)); else tmp = Float64(Float64(0.25 / re) / re); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 720.0) tmp = 0.5 * (re * 2.0); else tmp = (0.25 / re) / re; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 720.0], N[(0.5 * N[(re * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 / re), $MachinePrecision] / re), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 720:\\
\;\;\;\;0.5 \cdot \left(re \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.25}{re}}{re}\\
\end{array}
\end{array}
if im < 720Initial 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 64.1%
Taylor expanded in im around 0 35.9%
if 720 < im Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Applied egg-rr14.9%
Taylor expanded in re around 0 14.8%
unpow214.8%
associate-/r*14.8%
Simplified14.8%
Final simplification31.0%
(FPCore (re im) :precision binary64 (* 0.5 (* re 2.0)))
double code(double re, double im) {
return 0.5 * (re * 2.0);
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0 * (re * 2.0d0)
end function
public static double code(double re, double im) {
return 0.5 * (re * 2.0);
}
def code(re, im): return 0.5 * (re * 2.0)
function code(re, im) return Float64(0.5 * Float64(re * 2.0)) end
function tmp = code(re, im) tmp = 0.5 * (re * 2.0); end
code[re_, im_] := N[(0.5 * N[(re * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(re \cdot 2\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 re around 0 67.8%
Taylor expanded in im around 0 28.1%
Final simplification28.1%
(FPCore (re im) :precision binary64 -2.0)
double code(double re, double im) {
return -2.0;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = -2.0d0
end function
public static double code(double re, double im) {
return -2.0;
}
def code(re, im): return -2.0
function code(re, im) return -2.0 end
function tmp = code(re, im) tmp = -2.0; end
code[re_, im_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Taylor expanded in im around 0 75.3%
unpow275.3%
Simplified75.3%
Taylor expanded in im around 0 75.3%
unpow275.3%
associate-*r*68.0%
associate-*r*68.0%
*-commutative68.0%
associate-*r*68.0%
*-commutative68.0%
Simplified68.0%
Applied egg-rr3.9%
Taylor expanded in re around 0 4.0%
Final simplification4.0%
(FPCore (re im) :precision binary64 0.08333333333333333)
double code(double re, double im) {
return 0.08333333333333333;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.08333333333333333d0
end function
public static double code(double re, double im) {
return 0.08333333333333333;
}
def code(re, im): return 0.08333333333333333
function code(re, im) return 0.08333333333333333 end
function tmp = code(re, im) tmp = 0.08333333333333333; end
code[re_, im_] := 0.08333333333333333
\begin{array}{l}
\\
0.08333333333333333
\end{array}
Initial program 100.0%
distribute-rgt-in100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
cancel-sign-sub100.0%
distribute-lft-neg-in100.0%
neg-mul-1100.0%
*-commutative100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
remove-double-neg100.0%
distribute-rgt-in100.0%
distribute-lft-in100.0%
Simplified100.0%
Applied egg-rr11.9%
Taylor expanded in re around 0 11.7%
associate-*r/11.7%
metadata-eval11.7%
unpow211.7%
associate-/r*11.7%
Simplified11.7%
Taylor expanded in re around inf 4.2%
Final simplification4.2%
herbie shell --seed 2023293
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))