
(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 (* (* 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(im) + exp(Float64(-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%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (re im)
:precision binary64
(if (<= im 3.1e+19)
(sin re)
(if (<= im 1.15e+77)
(+ re (* (pow re 3.0) -0.16666666666666666))
(if (<= im 1.35e+154)
(* re (sqrt (* (pow im 4.0) 0.25)))
(* 0.5 (* (sin re) (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 3.1e+19) {
tmp = sin(re);
} else if (im <= 1.15e+77) {
tmp = re + (pow(re, 3.0) * -0.16666666666666666);
} else if (im <= 1.35e+154) {
tmp = re * sqrt((pow(im, 4.0) * 0.25));
} else {
tmp = 0.5 * (sin(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 <= 3.1d+19) then
tmp = sin(re)
else if (im <= 1.15d+77) then
tmp = re + ((re ** 3.0d0) * (-0.16666666666666666d0))
else if (im <= 1.35d+154) then
tmp = re * sqrt(((im ** 4.0d0) * 0.25d0))
else
tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 3.1e+19) {
tmp = Math.sin(re);
} else if (im <= 1.15e+77) {
tmp = re + (Math.pow(re, 3.0) * -0.16666666666666666);
} else if (im <= 1.35e+154) {
tmp = re * Math.sqrt((Math.pow(im, 4.0) * 0.25));
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 3.1e+19: tmp = math.sin(re) elif im <= 1.15e+77: tmp = re + (math.pow(re, 3.0) * -0.16666666666666666) elif im <= 1.35e+154: tmp = re * math.sqrt((math.pow(im, 4.0) * 0.25)) else: tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 3.1e+19) tmp = sin(re); elseif (im <= 1.15e+77) tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)); elseif (im <= 1.35e+154) tmp = Float64(re * sqrt(Float64((im ^ 4.0) * 0.25))); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 3.1e+19) tmp = sin(re); elseif (im <= 1.15e+77) tmp = re + ((re ^ 3.0) * -0.16666666666666666); elseif (im <= 1.35e+154) tmp = re * sqrt(((im ^ 4.0) * 0.25)); else tmp = 0.5 * (sin(re) * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 3.1e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 1.15e+77], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.35e+154], N[(re * N[Sqrt[N[(N[Power[im, 4.0], $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 3.1 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.15 \cdot 10^{+77}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 3.1e19Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.3%
if 3.1e19 < im < 1.14999999999999997e77Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.3%
+-commutative3.3%
unpow23.3%
fma-define3.3%
Simplified3.3%
Taylor expanded in re around 0 17.7%
associate-*r*17.7%
associate-*r*17.7%
*-commutative17.7%
distribute-rgt-out25.4%
+-commutative25.4%
unpow225.4%
fma-undefine25.4%
*-commutative25.4%
Simplified25.4%
Taylor expanded in im around 0 24.9%
+-commutative24.9%
*-commutative24.9%
distribute-rgt-in24.9%
associate-*l*24.9%
metadata-eval24.9%
*-rgt-identity24.9%
*-commutative24.9%
associate-*l*24.9%
metadata-eval24.9%
Simplified24.9%
if 1.14999999999999997e77 < im < 1.35000000000000003e154Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 73.7%
associate-*r*73.7%
Simplified73.7%
Taylor expanded in im around 0 13.0%
Taylor expanded in im around inf 13.0%
associate-*r*13.0%
*-commutative13.0%
Simplified13.0%
add-sqr-sqrt13.0%
sqrt-unprod73.7%
*-commutative73.7%
*-commutative73.7%
swap-sqr73.7%
pow-prod-up73.7%
metadata-eval73.7%
metadata-eval73.7%
Applied egg-rr73.7%
if 1.35000000000000003e154 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
unpow2100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification71.3%
(FPCore (re im)
:precision binary64
(if (<= im 5.2e+19)
(* (* 0.5 (sin re)) (fma im im 2.0))
(if (<= im 1.16e+77)
(+ re (* (pow re 3.0) -0.16666666666666666))
(if (<= im 5e+152)
(* re (sqrt (* (pow im 4.0) 0.25)))
(* 0.5 (* (sin re) (pow im 2.0)))))))
double code(double re, double im) {
double tmp;
if (im <= 5.2e+19) {
tmp = (0.5 * sin(re)) * fma(im, im, 2.0);
} else if (im <= 1.16e+77) {
tmp = re + (pow(re, 3.0) * -0.16666666666666666);
} else if (im <= 5e+152) {
tmp = re * sqrt((pow(im, 4.0) * 0.25));
} else {
tmp = 0.5 * (sin(re) * pow(im, 2.0));
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 5.2e+19) tmp = Float64(Float64(0.5 * sin(re)) * fma(im, im, 2.0)); elseif (im <= 1.16e+77) tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)); elseif (im <= 5e+152) tmp = Float64(re * sqrt(Float64((im ^ 4.0) * 0.25))); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
code[re_, im_] := If[LessEqual[im, 5.2e+19], N[(N[(0.5 * N[Sin[re], $MachinePrecision]), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 1.16e+77], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], If[LessEqual[im, 5e+152], N[(re * N[Sqrt[N[(N[Power[im, 4.0], $MachinePrecision] * 0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.2 \cdot 10^{+19}:\\
\;\;\;\;\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\mathbf{elif}\;im \leq 1.16 \cdot 10^{+77}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\
\mathbf{elif}\;im \leq 5 \cdot 10^{+152}:\\
\;\;\;\;re \cdot \sqrt{{im}^{4} \cdot 0.25}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 5.2e19Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 81.7%
+-commutative81.7%
unpow281.7%
fma-define81.7%
Simplified81.7%
if 5.2e19 < im < 1.1600000000000001e77Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.3%
+-commutative3.3%
unpow23.3%
fma-define3.3%
Simplified3.3%
Taylor expanded in re around 0 17.7%
associate-*r*17.7%
associate-*r*17.7%
*-commutative17.7%
distribute-rgt-out25.4%
+-commutative25.4%
unpow225.4%
fma-undefine25.4%
*-commutative25.4%
Simplified25.4%
Taylor expanded in im around 0 24.9%
+-commutative24.9%
*-commutative24.9%
distribute-rgt-in24.9%
associate-*l*24.9%
metadata-eval24.9%
*-rgt-identity24.9%
*-commutative24.9%
associate-*l*24.9%
metadata-eval24.9%
Simplified24.9%
if 1.1600000000000001e77 < im < 5e152Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 73.7%
associate-*r*73.7%
Simplified73.7%
Taylor expanded in im around 0 13.0%
Taylor expanded in im around inf 13.0%
associate-*r*13.0%
*-commutative13.0%
Simplified13.0%
add-sqr-sqrt13.0%
sqrt-unprod73.7%
*-commutative73.7%
*-commutative73.7%
swap-sqr73.7%
pow-prod-up73.7%
metadata-eval73.7%
metadata-eval73.7%
Applied egg-rr73.7%
if 5e152 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
unpow2100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification80.6%
(FPCore (re im)
:precision binary64
(if (<= im 5.6e-8)
(sin re)
(if (<= im 2e+51)
(* (+ (exp im) (exp (- im))) (* 0.5 re))
(+ 12.0 (* (sin re) (+ (* 0.001388888888888889 (pow im 6.0)) 1.0))))))
double code(double re, double im) {
double tmp;
if (im <= 5.6e-8) {
tmp = sin(re);
} else if (im <= 2e+51) {
tmp = (exp(im) + exp(-im)) * (0.5 * re);
} else {
tmp = 12.0 + (sin(re) * ((0.001388888888888889 * pow(im, 6.0)) + 1.0));
}
return tmp;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
real(8) :: tmp
if (im <= 5.6d-8) then
tmp = sin(re)
else if (im <= 2d+51) then
tmp = (exp(im) + exp(-im)) * (0.5d0 * re)
else
tmp = 12.0d0 + (sin(re) * ((0.001388888888888889d0 * (im ** 6.0d0)) + 1.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.6e-8) {
tmp = Math.sin(re);
} else if (im <= 2e+51) {
tmp = (Math.exp(im) + Math.exp(-im)) * (0.5 * re);
} else {
tmp = 12.0 + (Math.sin(re) * ((0.001388888888888889 * Math.pow(im, 6.0)) + 1.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.6e-8: tmp = math.sin(re) elif im <= 2e+51: tmp = (math.exp(im) + math.exp(-im)) * (0.5 * re) else: tmp = 12.0 + (math.sin(re) * ((0.001388888888888889 * math.pow(im, 6.0)) + 1.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.6e-8) tmp = sin(re); elseif (im <= 2e+51) tmp = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * re)); else tmp = Float64(12.0 + Float64(sin(re) * Float64(Float64(0.001388888888888889 * (im ^ 6.0)) + 1.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.6e-8) tmp = sin(re); elseif (im <= 2e+51) tmp = (exp(im) + exp(-im)) * (0.5 * re); else tmp = 12.0 + (sin(re) * ((0.001388888888888889 * (im ^ 6.0)) + 1.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.6e-8], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2e+51], N[(N[(N[Exp[im], $MachinePrecision] + N[Exp[(-im)], $MachinePrecision]), $MachinePrecision] * N[(0.5 * re), $MachinePrecision]), $MachinePrecision], N[(12.0 + N[(N[Sin[re], $MachinePrecision] * N[(N[(0.001388888888888889 * N[Power[im, 6.0], $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2 \cdot 10^{+51}:\\
\;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;12 + \sin re \cdot \left(0.001388888888888889 \cdot {im}^{6} + 1\right)\\
\end{array}
\end{array}
if im < 5.5999999999999999e-8Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 70.7%
if 5.5999999999999999e-8 < im < 2e51Initial program 99.7%
+-commutative99.7%
neg-sub099.7%
Simplified99.7%
Taylor expanded in re around 0 78.2%
associate-*r*78.2%
Simplified78.2%
if 2e51 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
associate-+r+100.0%
+-commutative100.0%
associate-*r*100.0%
associate-*r*100.0%
distribute-rgt-out100.0%
associate-*r*100.0%
distribute-rgt1-in100.0%
Simplified100.0%
Applied egg-rr100.0%
Final simplification77.9%
(FPCore (re im)
:precision binary64
(if (<= im 5.6e-8)
(sin re)
(if (<= im 1.35e+154)
(* (+ (exp im) (exp (- im))) (* 0.5 re))
(* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 5.6e-8) {
tmp = sin(re);
} else if (im <= 1.35e+154) {
tmp = (exp(im) + exp(-im)) * (0.5 * re);
} else {
tmp = 0.5 * (sin(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 <= 5.6d-8) then
tmp = sin(re)
else if (im <= 1.35d+154) then
tmp = (exp(im) + exp(-im)) * (0.5d0 * re)
else
tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 5.6e-8) {
tmp = Math.sin(re);
} else if (im <= 1.35e+154) {
tmp = (Math.exp(im) + Math.exp(-im)) * (0.5 * re);
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 5.6e-8: tmp = math.sin(re) elif im <= 1.35e+154: tmp = (math.exp(im) + math.exp(-im)) * (0.5 * re) else: tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 5.6e-8) tmp = sin(re); elseif (im <= 1.35e+154) tmp = Float64(Float64(exp(im) + exp(Float64(-im))) * Float64(0.5 * re)); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 5.6e-8) tmp = sin(re); elseif (im <= 1.35e+154) tmp = (exp(im) + exp(-im)) * (0.5 * re); else tmp = 0.5 * (sin(re) * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 5.6e-8], N[Sin[re], $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[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 5.6 \cdot 10^{-8}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 1.35 \cdot 10^{+154}:\\
\;\;\;\;\left(e^{im} + e^{-im}\right) \cdot \left(0.5 \cdot re\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 5.5999999999999999e-8Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 70.7%
if 5.5999999999999999e-8 < im < 1.35000000000000003e154Initial program 99.9%
+-commutative99.9%
neg-sub099.9%
Simplified99.9%
Taylor expanded in re around 0 77.4%
associate-*r*77.4%
Simplified77.4%
if 1.35000000000000003e154 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 100.0%
+-commutative100.0%
unpow2100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in im around inf 100.0%
Final simplification75.5%
(FPCore (re im)
:precision binary64
(if (<= im 2.7e+19)
(sin re)
(if (<= im 3.15e+149)
(+ re (* (pow re 3.0) -0.16666666666666666))
(* 0.5 (* (sin re) (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 2.7e+19) {
tmp = sin(re);
} else if (im <= 3.15e+149) {
tmp = re + (pow(re, 3.0) * -0.16666666666666666);
} else {
tmp = 0.5 * (sin(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 <= 2.7d+19) then
tmp = sin(re)
else if (im <= 3.15d+149) then
tmp = re + ((re ** 3.0d0) * (-0.16666666666666666d0))
else
tmp = 0.5d0 * (sin(re) * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.7e+19) {
tmp = Math.sin(re);
} else if (im <= 3.15e+149) {
tmp = re + (Math.pow(re, 3.0) * -0.16666666666666666);
} else {
tmp = 0.5 * (Math.sin(re) * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.7e+19: tmp = math.sin(re) elif im <= 3.15e+149: tmp = re + (math.pow(re, 3.0) * -0.16666666666666666) else: tmp = 0.5 * (math.sin(re) * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.7e+19) tmp = sin(re); elseif (im <= 3.15e+149) tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)); else tmp = Float64(0.5 * Float64(sin(re) * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.7e+19) tmp = sin(re); elseif (im <= 3.15e+149) tmp = re + ((re ^ 3.0) * -0.16666666666666666); else tmp = 0.5 * (sin(re) * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.7e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.15e+149], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[Sin[re], $MachinePrecision] * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.15 \cdot 10^{+149}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin re \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 2.7e19Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.3%
if 2.7e19 < im < 3.15e149Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 4.4%
+-commutative4.4%
unpow24.4%
fma-define4.4%
Simplified4.4%
Taylor expanded in re around 0 12.3%
associate-*r*12.3%
associate-*r*12.3%
*-commutative12.3%
distribute-rgt-out25.2%
+-commutative25.2%
unpow225.2%
fma-undefine25.2%
*-commutative25.2%
Simplified25.2%
Taylor expanded in im around 0 21.2%
+-commutative21.2%
*-commutative21.2%
distribute-rgt-in21.2%
associate-*l*21.2%
metadata-eval21.2%
*-rgt-identity21.2%
*-commutative21.2%
associate-*l*21.2%
metadata-eval21.2%
Simplified21.2%
if 3.15e149 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 97.2%
+-commutative97.2%
unpow297.2%
fma-define97.2%
Simplified97.2%
Taylor expanded in im around inf 97.2%
Final simplification67.2%
(FPCore (re im)
:precision binary64
(if (<= im 2.7e+19)
(sin re)
(if (<= im 2.5e+117)
(+ re (* (pow re 3.0) -0.16666666666666666))
(* (* 0.5 re) (fma im im 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 2.7e+19) {
tmp = sin(re);
} else if (im <= 2.5e+117) {
tmp = re + (pow(re, 3.0) * -0.16666666666666666);
} else {
tmp = (0.5 * re) * fma(im, im, 2.0);
}
return tmp;
}
function code(re, im) tmp = 0.0 if (im <= 2.7e+19) tmp = sin(re); elseif (im <= 2.5e+117) tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)); else tmp = Float64(Float64(0.5 * re) * fma(im, im, 2.0)); end return tmp end
code[re_, im_] := If[LessEqual[im, 2.7e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 2.5e+117], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 * re), $MachinePrecision] * N[(im * im + 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 2.5 \cdot 10^{+117}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot re\right) \cdot \mathsf{fma}\left(im, im, 2\right)\\
\end{array}
\end{array}
if im < 2.7e19Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.3%
if 2.7e19 < im < 2.49999999999999992e117Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.7%
+-commutative3.7%
unpow23.7%
fma-define3.7%
Simplified3.7%
Taylor expanded in re around 0 11.2%
associate-*r*11.2%
associate-*r*11.2%
*-commutative11.2%
distribute-rgt-out23.7%
+-commutative23.7%
unpow223.7%
fma-undefine23.7%
*-commutative23.7%
Simplified23.7%
Taylor expanded in im around 0 22.7%
+-commutative22.7%
*-commutative22.7%
distribute-rgt-in22.7%
associate-*l*22.7%
metadata-eval22.7%
*-rgt-identity22.7%
*-commutative22.7%
associate-*l*22.7%
metadata-eval22.7%
Simplified22.7%
if 2.49999999999999992e117 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 75.6%
associate-*r*75.6%
Simplified75.6%
Taylor expanded in im around 0 66.3%
+-commutative81.7%
unpow281.7%
fma-define81.7%
Simplified66.3%
Final simplification64.5%
(FPCore (re im)
:precision binary64
(if (<= im 2.7e+19)
(sin re)
(if (<= im 3.8e+118)
(+ re (* (pow re 3.0) -0.16666666666666666))
(* re (* 0.5 (pow im 2.0))))))
double code(double re, double im) {
double tmp;
if (im <= 2.7e+19) {
tmp = sin(re);
} else if (im <= 3.8e+118) {
tmp = re + (pow(re, 3.0) * -0.16666666666666666);
} else {
tmp = 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 <= 2.7d+19) then
tmp = sin(re)
else if (im <= 3.8d+118) then
tmp = re + ((re ** 3.0d0) * (-0.16666666666666666d0))
else
tmp = re * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 2.7e+19) {
tmp = Math.sin(re);
} else if (im <= 3.8e+118) {
tmp = re + (Math.pow(re, 3.0) * -0.16666666666666666);
} else {
tmp = re * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 2.7e+19: tmp = math.sin(re) elif im <= 3.8e+118: tmp = re + (math.pow(re, 3.0) * -0.16666666666666666) else: tmp = re * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 2.7e+19) tmp = sin(re); elseif (im <= 3.8e+118) tmp = Float64(re + Float64((re ^ 3.0) * -0.16666666666666666)); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 2.7e+19) tmp = sin(re); elseif (im <= 3.8e+118) tmp = re + ((re ^ 3.0) * -0.16666666666666666); else tmp = re * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 2.7e+19], N[Sin[re], $MachinePrecision], If[LessEqual[im, 3.8e+118], N[(re + N[(N[Power[re, 3.0], $MachinePrecision] * -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 2.7 \cdot 10^{+19}:\\
\;\;\;\;\sin re\\
\mathbf{elif}\;im \leq 3.8 \cdot 10^{+118}:\\
\;\;\;\;re + {re}^{3} \cdot -0.16666666666666666\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 2.7e19Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 69.3%
if 2.7e19 < im < 3.80000000000000016e118Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 3.7%
+-commutative3.7%
unpow23.7%
fma-define3.7%
Simplified3.7%
Taylor expanded in re around 0 11.2%
associate-*r*11.2%
associate-*r*11.2%
*-commutative11.2%
distribute-rgt-out23.7%
+-commutative23.7%
unpow223.7%
fma-undefine23.7%
*-commutative23.7%
Simplified23.7%
Taylor expanded in im around 0 22.7%
+-commutative22.7%
*-commutative22.7%
distribute-rgt-in22.7%
associate-*l*22.7%
metadata-eval22.7%
*-rgt-identity22.7%
*-commutative22.7%
associate-*l*22.7%
metadata-eval22.7%
Simplified22.7%
if 3.80000000000000016e118 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 75.6%
associate-*r*75.6%
Simplified75.6%
Taylor expanded in im around 0 66.3%
Taylor expanded in im around inf 66.3%
associate-*r*66.3%
*-commutative66.3%
Simplified66.3%
Final simplification64.5%
(FPCore (re im) :precision binary64 (if (<= im 6.4e+36) (sin re) (* re (* 0.5 (pow im 2.0)))))
double code(double re, double im) {
double tmp;
if (im <= 6.4e+36) {
tmp = sin(re);
} else {
tmp = 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 <= 6.4d+36) then
tmp = sin(re)
else
tmp = re * (0.5d0 * (im ** 2.0d0))
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (im <= 6.4e+36) {
tmp = Math.sin(re);
} else {
tmp = re * (0.5 * Math.pow(im, 2.0));
}
return tmp;
}
def code(re, im): tmp = 0 if im <= 6.4e+36: tmp = math.sin(re) else: tmp = re * (0.5 * math.pow(im, 2.0)) return tmp
function code(re, im) tmp = 0.0 if (im <= 6.4e+36) tmp = sin(re); else tmp = Float64(re * Float64(0.5 * (im ^ 2.0))); end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (im <= 6.4e+36) tmp = sin(re); else tmp = re * (0.5 * (im ^ 2.0)); end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[im, 6.4e+36], N[Sin[re], $MachinePrecision], N[(re * N[(0.5 * N[Power[im, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;im \leq 6.4 \cdot 10^{+36}:\\
\;\;\;\;\sin re\\
\mathbf{else}:\\
\;\;\;\;re \cdot \left(0.5 \cdot {im}^{2}\right)\\
\end{array}
\end{array}
if im < 6.3999999999999998e36Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 67.6%
if 6.3999999999999998e36 < im Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 76.7%
associate-*r*76.7%
Simplified76.7%
Taylor expanded in im around 0 47.8%
Taylor expanded in im around inf 47.8%
associate-*r*47.8%
*-commutative47.8%
Simplified47.8%
Final simplification63.0%
(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%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in im around 0 52.4%
Final simplification52.4%
(FPCore (re im) :precision binary64 (if (<= re 0.5) re 0.5))
double code(double re, double im) {
double tmp;
if (re <= 0.5) {
tmp = re;
} else {
tmp = 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 <= 0.5d0) then
tmp = re
else
tmp = 0.5d0
end if
code = tmp
end function
public static double code(double re, double im) {
double tmp;
if (re <= 0.5) {
tmp = re;
} else {
tmp = 0.5;
}
return tmp;
}
def code(re, im): tmp = 0 if re <= 0.5: tmp = re else: tmp = 0.5 return tmp
function code(re, im) tmp = 0.0 if (re <= 0.5) tmp = re; else tmp = 0.5; end return tmp end
function tmp_2 = code(re, im) tmp = 0.0; if (re <= 0.5) tmp = re; else tmp = 0.5; end tmp_2 = tmp; end
code[re_, im_] := If[LessEqual[re, 0.5], re, 0.5]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;re \leq 0.5:\\
\;\;\;\;re\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if re < 0.5Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Taylor expanded in re around 0 76.6%
associate-*r*76.6%
Simplified76.6%
Taylor expanded in im around 0 32.3%
if 0.5 < re Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr7.2%
Final simplification25.8%
(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%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr2.7%
Final simplification2.7%
(FPCore (re im) :precision binary64 0.25)
double code(double re, double im) {
return 0.25;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.25d0
end function
public static double code(double re, double im) {
return 0.25;
}
def code(re, im): return 0.25
function code(re, im) return 0.25 end
function tmp = code(re, im) tmp = 0.25; end
code[re_, im_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr4.6%
Final simplification4.6%
(FPCore (re im) :precision binary64 0.5)
double code(double re, double im) {
return 0.5;
}
real(8) function code(re, im)
real(8), intent (in) :: re
real(8), intent (in) :: im
code = 0.5d0
end function
public static double code(double re, double im) {
return 0.5;
}
def code(re, im): return 0.5
function code(re, im) return 0.5 end
function tmp = code(re, im) tmp = 0.5; end
code[re_, im_] := 0.5
\begin{array}{l}
\\
0.5
\end{array}
Initial program 100.0%
+-commutative100.0%
neg-sub0100.0%
Simplified100.0%
Applied egg-rr4.7%
Final simplification4.7%
herbie shell --seed 2024046
(FPCore (re im)
:name "math.sin on complex, real part"
:precision binary64
(* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))