
(FPCore (z0) :precision binary64 (sin (* (+ PI PI) z0)))
double code(double z0) {
return sin(((((double) M_PI) + ((double) M_PI)) * z0));
}
public static double code(double z0) {
return Math.sin(((Math.PI + Math.PI) * z0));
}
def code(z0): return math.sin(((math.pi + math.pi) * z0))
function code(z0) return sin(Float64(Float64(pi + pi) * z0)) end
function tmp = code(z0) tmp = sin(((pi + pi) * z0)); end
code[z0_] := N[Sin[N[(N[(Pi + Pi), $MachinePrecision] * z0), $MachinePrecision]], $MachinePrecision]
\sin \left(\left(\pi + \pi\right) \cdot z0\right)
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (z0) :precision binary64 (sin (* (+ PI PI) z0)))
double code(double z0) {
return sin(((((double) M_PI) + ((double) M_PI)) * z0));
}
public static double code(double z0) {
return Math.sin(((Math.PI + Math.PI) * z0));
}
def code(z0): return math.sin(((math.pi + math.pi) * z0))
function code(z0) return sin(Float64(Float64(pi + pi) * z0)) end
function tmp = code(z0) tmp = sin(((pi + pi) * z0)); end
code[z0_] := N[Sin[N[(N[(Pi + Pi), $MachinePrecision] * z0), $MachinePrecision]], $MachinePrecision]
\sin \left(\left(\pi + \pi\right) \cdot z0\right)
(FPCore (z0)
:precision binary64
(let* ((t_0 (* PI (+ 1/2 (fabs z0))))
(t_1 (+ t_0 t_0))
(t_2 (* PI (- (fabs z0) 1/2)))
(t_3 (- t_2 t_2))
(t_4 (* (+ (fabs z0) (fabs z0)) PI)))
(*
(copysign 1 z0)
(if (<= (fabs z0) 3602879701896397/72057594037927936)
(sin (* (* (* 2 (fabs z0)) (pow PI 2/3)) (pow (pow PI 1/6) 2)))
(304-z0z1z2z3z4
1/2
2
(* (sin (/ (+ t_3 t_4) 2)) (cos (/ (- t_3 t_4) 2)))
2
(* (sin (/ (- t_1 t_3) 2)) (cos (/ (+ t_1 t_3) 2))))))))\begin{array}{l}
t_0 := \pi \cdot \left(\frac{1}{2} + \left|z0\right|\right)\\
t_1 := t\_0 + t\_0\\
t_2 := \pi \cdot \left(\left|z0\right| - \frac{1}{2}\right)\\
t_3 := t\_2 - t\_2\\
t_4 := \left(\left|z0\right| + \left|z0\right|\right) \cdot \pi\\
\mathsf{copysign}\left(1, z0\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z0\right| \leq \frac{3602879701896397}{72057594037927936}:\\
\;\;\;\;\sin \left(\left(\left(2 \cdot \left|z0\right|\right) \cdot {\pi}^{\frac{2}{3}}\right) \cdot {\left({\pi}^{\frac{1}{6}}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{304\_z0z1z2z3z4}\left(\frac{1}{2}, 2, \left(\sin \left(\frac{t\_3 + t\_4}{2}\right) \cdot \cos \left(\frac{t\_3 - t\_4}{2}\right)\right), 2, \left(\sin \left(\frac{t\_1 - t\_3}{2}\right) \cdot \cos \left(\frac{t\_1 + t\_3}{2}\right)\right)\right)\\
\end{array}
\end{array}
if z0 < 0.050000000000000003Initial program 52.9%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
count-2N/A
associate-*r*N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64N/A
pow1/3N/A
lift-PI.f64N/A
pow1/3N/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
lift-PI.f64N/A
lower-cbrt.f6452.3%
Applied rewrites52.3%
lift-cbrt.f64N/A
pow1/3N/A
sqr-powN/A
lower-unsound-*.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-/.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-/.f6452.8%
Applied rewrites52.8%
lift-*.f64N/A
pow2N/A
lower-pow.f6452.8%
lower-unsound-/.f64N/A
lower-unsound-/.f6452.8%
lift-/.f64N/A
metadata-eval52.8%
Applied rewrites52.8%
if 0.050000000000000003 < z0 Initial program 52.9%
lift-sin.f64N/A
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
associate-*l*N/A
sin-2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6452.9%
Applied rewrites52.9%
Applied rewrites6.5%
Applied rewrites52.1%
(FPCore (z0)
:precision binary64
(*
(copysign 1 z0)
(if (<= (fabs z0) 3602879701896397/72057594037927936)
(sin (* (* (* 2 (fabs z0)) (pow PI 2/3)) (pow (pow PI 1/6) 2)))
(*
(-
(-
(sin (* (+ PI PI) (- (fabs z0) -1/2)))
(sin (* (+ (fabs z0) (fabs z0)) PI))))
1/2))))double code(double z0) {
double tmp;
if (fabs(z0) <= 0.05) {
tmp = sin((((2.0 * fabs(z0)) * pow(((double) M_PI), 0.6666666666666666)) * pow(pow(((double) M_PI), 0.16666666666666666), 2.0)));
} else {
tmp = -(sin(((((double) M_PI) + ((double) M_PI)) * (fabs(z0) - -0.5))) - sin(((fabs(z0) + fabs(z0)) * ((double) M_PI)))) * 0.5;
}
return copysign(1.0, z0) * tmp;
}
public static double code(double z0) {
double tmp;
if (Math.abs(z0) <= 0.05) {
tmp = Math.sin((((2.0 * Math.abs(z0)) * Math.pow(Math.PI, 0.6666666666666666)) * Math.pow(Math.pow(Math.PI, 0.16666666666666666), 2.0)));
} else {
tmp = -(Math.sin(((Math.PI + Math.PI) * (Math.abs(z0) - -0.5))) - Math.sin(((Math.abs(z0) + Math.abs(z0)) * Math.PI))) * 0.5;
}
return Math.copySign(1.0, z0) * tmp;
}
def code(z0): tmp = 0 if math.fabs(z0) <= 0.05: tmp = math.sin((((2.0 * math.fabs(z0)) * math.pow(math.pi, 0.6666666666666666)) * math.pow(math.pow(math.pi, 0.16666666666666666), 2.0))) else: tmp = -(math.sin(((math.pi + math.pi) * (math.fabs(z0) - -0.5))) - math.sin(((math.fabs(z0) + math.fabs(z0)) * math.pi))) * 0.5 return math.copysign(1.0, z0) * tmp
function code(z0) tmp = 0.0 if (abs(z0) <= 0.05) tmp = sin(Float64(Float64(Float64(2.0 * abs(z0)) * (pi ^ 0.6666666666666666)) * ((pi ^ 0.16666666666666666) ^ 2.0))); else tmp = Float64(Float64(-Float64(sin(Float64(Float64(pi + pi) * Float64(abs(z0) - -0.5))) - sin(Float64(Float64(abs(z0) + abs(z0)) * pi)))) * 0.5); end return Float64(copysign(1.0, z0) * tmp) end
function tmp_2 = code(z0) tmp = 0.0; if (abs(z0) <= 0.05) tmp = sin((((2.0 * abs(z0)) * (pi ^ 0.6666666666666666)) * ((pi ^ 0.16666666666666666) ^ 2.0))); else tmp = -(sin(((pi + pi) * (abs(z0) - -0.5))) - sin(((abs(z0) + abs(z0)) * pi))) * 0.5; end tmp_2 = (sign(z0) * abs(1.0)) * tmp; end
code[z0_] := N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[z0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z0], $MachinePrecision], 3602879701896397/72057594037927936], N[Sin[N[(N[(N[(2 * N[Abs[z0], $MachinePrecision]), $MachinePrecision] * N[Power[Pi, 2/3], $MachinePrecision]), $MachinePrecision] * N[Power[N[Power[Pi, 1/6], $MachinePrecision], 2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[((-N[(N[Sin[N[(N[(Pi + Pi), $MachinePrecision] * N[(N[Abs[z0], $MachinePrecision] - -1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sin[N[(N[(N[Abs[z0], $MachinePrecision] + N[Abs[z0], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) * 1/2), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, z0\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z0\right| \leq \frac{3602879701896397}{72057594037927936}:\\
\;\;\;\;\sin \left(\left(\left(2 \cdot \left|z0\right|\right) \cdot {\pi}^{\frac{2}{3}}\right) \cdot {\left({\pi}^{\frac{1}{6}}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\left(\sin \left(\left(\pi + \pi\right) \cdot \left(\left|z0\right| - \frac{-1}{2}\right)\right) - \sin \left(\left(\left|z0\right| + \left|z0\right|\right) \cdot \pi\right)\right)\right) \cdot \frac{1}{2}\\
\end{array}
if z0 < 0.050000000000000003Initial program 52.9%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
count-2N/A
associate-*r*N/A
lift-PI.f64N/A
add-cube-cbrtN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-PI.f64N/A
pow1/3N/A
lift-PI.f64N/A
pow1/3N/A
pow-prod-upN/A
lower-pow.f64N/A
metadata-evalN/A
lift-PI.f64N/A
lower-cbrt.f6452.3%
Applied rewrites52.3%
lift-cbrt.f64N/A
pow1/3N/A
sqr-powN/A
lower-unsound-*.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-/.f64N/A
lower-unsound-pow.f64N/A
lower-unsound-/.f6452.8%
Applied rewrites52.8%
lift-*.f64N/A
pow2N/A
lower-pow.f6452.8%
lower-unsound-/.f64N/A
lower-unsound-/.f6452.8%
lift-/.f64N/A
metadata-eval52.8%
Applied rewrites52.8%
if 0.050000000000000003 < z0 Initial program 52.9%
lift-sin.f64N/A
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
associate-*l*N/A
sin-2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6452.9%
Applied rewrites52.9%
Applied rewrites6.5%
Applied rewrites52.1%
Applied rewrites52.1%
(FPCore (z0)
:precision binary64
(let* ((t_0 (* (fabs z0) PI)))
(*
(copysign 1 z0)
(if (<= (fabs z0) 13500000)
(* 2 (* (sin t_0) (sin (+ (* PI 1/2) t_0))))
(*
(-
(-
(sin (* (+ PI PI) (- (fabs z0) -1/2)))
(sin (* (+ (fabs z0) (fabs z0)) PI))))
1/2)))))double code(double z0) {
double t_0 = fabs(z0) * ((double) M_PI);
double tmp;
if (fabs(z0) <= 13500000.0) {
tmp = 2.0 * (sin(t_0) * sin(((((double) M_PI) * 0.5) + t_0)));
} else {
tmp = -(sin(((((double) M_PI) + ((double) M_PI)) * (fabs(z0) - -0.5))) - sin(((fabs(z0) + fabs(z0)) * ((double) M_PI)))) * 0.5;
}
return copysign(1.0, z0) * tmp;
}
public static double code(double z0) {
double t_0 = Math.abs(z0) * Math.PI;
double tmp;
if (Math.abs(z0) <= 13500000.0) {
tmp = 2.0 * (Math.sin(t_0) * Math.sin(((Math.PI * 0.5) + t_0)));
} else {
tmp = -(Math.sin(((Math.PI + Math.PI) * (Math.abs(z0) - -0.5))) - Math.sin(((Math.abs(z0) + Math.abs(z0)) * Math.PI))) * 0.5;
}
return Math.copySign(1.0, z0) * tmp;
}
def code(z0): t_0 = math.fabs(z0) * math.pi tmp = 0 if math.fabs(z0) <= 13500000.0: tmp = 2.0 * (math.sin(t_0) * math.sin(((math.pi * 0.5) + t_0))) else: tmp = -(math.sin(((math.pi + math.pi) * (math.fabs(z0) - -0.5))) - math.sin(((math.fabs(z0) + math.fabs(z0)) * math.pi))) * 0.5 return math.copysign(1.0, z0) * tmp
function code(z0) t_0 = Float64(abs(z0) * pi) tmp = 0.0 if (abs(z0) <= 13500000.0) tmp = Float64(2.0 * Float64(sin(t_0) * sin(Float64(Float64(pi * 0.5) + t_0)))); else tmp = Float64(Float64(-Float64(sin(Float64(Float64(pi + pi) * Float64(abs(z0) - -0.5))) - sin(Float64(Float64(abs(z0) + abs(z0)) * pi)))) * 0.5); end return Float64(copysign(1.0, z0) * tmp) end
function tmp_2 = code(z0) t_0 = abs(z0) * pi; tmp = 0.0; if (abs(z0) <= 13500000.0) tmp = 2.0 * (sin(t_0) * sin(((pi * 0.5) + t_0))); else tmp = -(sin(((pi + pi) * (abs(z0) - -0.5))) - sin(((abs(z0) + abs(z0)) * pi))) * 0.5; end tmp_2 = (sign(z0) * abs(1.0)) * tmp; end
code[z0_] := Block[{t$95$0 = N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[z0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z0], $MachinePrecision], 13500000], N[(2 * N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[N[(N[(Pi * 1/2), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[((-N[(N[Sin[N[(N[(Pi + Pi), $MachinePrecision] * N[(N[Abs[z0], $MachinePrecision] - -1/2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Sin[N[(N[(N[Abs[z0], $MachinePrecision] + N[Abs[z0], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]) * 1/2), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|z0\right| \cdot \pi\\
\mathsf{copysign}\left(1, z0\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z0\right| \leq 13500000:\\
\;\;\;\;2 \cdot \left(\sin t\_0 \cdot \sin \left(\pi \cdot \frac{1}{2} + t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-\left(\sin \left(\left(\pi + \pi\right) \cdot \left(\left|z0\right| - \frac{-1}{2}\right)\right) - \sin \left(\left(\left|z0\right| + \left|z0\right|\right) \cdot \pi\right)\right)\right) \cdot \frac{1}{2}\\
\end{array}
\end{array}
if z0 < 1.35e7Initial program 52.9%
lift-sin.f64N/A
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
associate-*l*N/A
sin-2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6452.9%
Applied rewrites52.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-PI.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval52.8%
Applied rewrites52.8%
if 1.35e7 < z0 Initial program 52.9%
lift-sin.f64N/A
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
associate-*l*N/A
sin-2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6452.9%
Applied rewrites52.9%
Applied rewrites6.5%
Applied rewrites52.1%
Applied rewrites52.1%
(FPCore (z0) :precision binary64 (let* ((t_0 (* (fabs z0) PI))) (* (copysign 1 z0) (* 2 (* (sin t_0) (sin (+ (* PI 1/2) t_0)))))))
double code(double z0) {
double t_0 = fabs(z0) * ((double) M_PI);
return copysign(1.0, z0) * (2.0 * (sin(t_0) * sin(((((double) M_PI) * 0.5) + t_0))));
}
public static double code(double z0) {
double t_0 = Math.abs(z0) * Math.PI;
return Math.copySign(1.0, z0) * (2.0 * (Math.sin(t_0) * Math.sin(((Math.PI * 0.5) + t_0))));
}
def code(z0): t_0 = math.fabs(z0) * math.pi return math.copysign(1.0, z0) * (2.0 * (math.sin(t_0) * math.sin(((math.pi * 0.5) + t_0))))
function code(z0) t_0 = Float64(abs(z0) * pi) return Float64(copysign(1.0, z0) * Float64(2.0 * Float64(sin(t_0) * sin(Float64(Float64(pi * 0.5) + t_0))))) end
function tmp = code(z0) t_0 = abs(z0) * pi; tmp = (sign(z0) * abs(1.0)) * (2.0 * (sin(t_0) * sin(((pi * 0.5) + t_0)))); end
code[z0_] := Block[{t$95$0 = N[(N[Abs[z0], $MachinePrecision] * Pi), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1], TMP2 = Sign[z0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * N[(2 * N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[N[(N[(Pi * 1/2), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
t_0 := \left|z0\right| \cdot \pi\\
\mathsf{copysign}\left(1, z0\right) \cdot \left(2 \cdot \left(\sin t\_0 \cdot \sin \left(\pi \cdot \frac{1}{2} + t\_0\right)\right)\right)
\end{array}
Initial program 52.9%
lift-sin.f64N/A
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
associate-*l*N/A
sin-2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6452.9%
Applied rewrites52.9%
lift-cos.f64N/A
sin-+PI/2-revN/A
lower-sin.f64N/A
+-commutativeN/A
lower-+.f64N/A
lift-PI.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval52.8%
Applied rewrites52.8%
(FPCore (z0) :precision binary64 (* 2 (* (sin (* z0 PI)) (cos (* z0 PI)))))
double code(double z0) {
return 2.0 * (sin((z0 * ((double) M_PI))) * cos((z0 * ((double) M_PI))));
}
public static double code(double z0) {
return 2.0 * (Math.sin((z0 * Math.PI)) * Math.cos((z0 * Math.PI)));
}
def code(z0): return 2.0 * (math.sin((z0 * math.pi)) * math.cos((z0 * math.pi)))
function code(z0) return Float64(2.0 * Float64(sin(Float64(z0 * pi)) * cos(Float64(z0 * pi)))) end
function tmp = code(z0) tmp = 2.0 * (sin((z0 * pi)) * cos((z0 * pi))); end
code[z0_] := N[(2 * N[(N[Sin[N[(z0 * Pi), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(z0 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
2 \cdot \left(\sin \left(z0 \cdot \pi\right) \cdot \cos \left(z0 \cdot \pi\right)\right)
Initial program 52.9%
lift-sin.f64N/A
lift-*.f64N/A
lift-+.f64N/A
count-2N/A
associate-*l*N/A
sin-2N/A
lower-*.f64N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f6452.9%
Applied rewrites52.9%
herbie shell --seed 2025277 -o generate:taylor -o generate:evaluate
(FPCore (z0)
:name "(sin (* (+ PI PI) z0))"
:precision binary64
(sin (* (+ PI PI) z0)))