(sin (* z0 (- PI)))

Percentage Accurate: 53.5% → 98.6%
Time: 3.6s
Alternatives: 4
Speedup: 1.0×

Specification

?
\[\sin \left(z0 \cdot \left(-\pi\right)\right) \]
(FPCore (z0)
  :precision binary64
  (sin (* z0 (- PI))))
double code(double z0) {
	return sin((z0 * -((double) M_PI)));
}
public static double code(double z0) {
	return Math.sin((z0 * -Math.PI));
}
def code(z0):
	return math.sin((z0 * -math.pi))
function code(z0)
	return sin(Float64(z0 * Float64(-pi)))
end
function tmp = code(z0)
	tmp = sin((z0 * -pi));
end
code[z0_] := N[Sin[N[(z0 * (-Pi)), $MachinePrecision]], $MachinePrecision]
\sin \left(z0 \cdot \left(-\pi\right)\right)

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 4 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 53.5% accurate, 1.0× speedup?

\[\sin \left(z0 \cdot \left(-\pi\right)\right) \]
(FPCore (z0)
  :precision binary64
  (sin (* z0 (- PI))))
double code(double z0) {
	return sin((z0 * -((double) M_PI)));
}
public static double code(double z0) {
	return Math.sin((z0 * -Math.PI));
}
def code(z0):
	return math.sin((z0 * -math.pi))
function code(z0)
	return sin(Float64(z0 * Float64(-pi)))
end
function tmp = code(z0)
	tmp = sin((z0 * -pi));
end
code[z0_] := N[Sin[N[(z0 * (-Pi)), $MachinePrecision]], $MachinePrecision]
\sin \left(z0 \cdot \left(-\pi\right)\right)

Alternative 1: 98.6% accurate, 0.3× speedup?

\[\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 4 \cdot 10^{-5}:\\ \;\;\;\;\sin \left(\left|z0\right| \cdot -3.141592653589793\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \left(\sin \left(t\_0 - \pi\right) - \sin t\_0\right)\\ \end{array} \end{array} \]
(FPCore (z0)
  :precision binary64
  (let* ((t_0 (* (fabs z0) PI)))
  (*
   (copysign 1.0 z0)
   (if (<= (fabs z0) 4e-5)
     (sin (* (fabs z0) -3.141592653589793))
     (* 0.5 (- (sin (- t_0 PI)) (sin t_0)))))))
double code(double z0) {
	double t_0 = fabs(z0) * ((double) M_PI);
	double tmp;
	if (fabs(z0) <= 4e-5) {
		tmp = sin((fabs(z0) * -3.141592653589793));
	} else {
		tmp = 0.5 * (sin((t_0 - ((double) M_PI))) - sin(t_0));
	}
	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) <= 4e-5) {
		tmp = Math.sin((Math.abs(z0) * -3.141592653589793));
	} else {
		tmp = 0.5 * (Math.sin((t_0 - Math.PI)) - Math.sin(t_0));
	}
	return Math.copySign(1.0, z0) * tmp;
}
def code(z0):
	t_0 = math.fabs(z0) * math.pi
	tmp = 0
	if math.fabs(z0) <= 4e-5:
		tmp = math.sin((math.fabs(z0) * -3.141592653589793))
	else:
		tmp = 0.5 * (math.sin((t_0 - math.pi)) - math.sin(t_0))
	return math.copysign(1.0, z0) * tmp
function code(z0)
	t_0 = Float64(abs(z0) * pi)
	tmp = 0.0
	if (abs(z0) <= 4e-5)
		tmp = sin(Float64(abs(z0) * -3.141592653589793));
	else
		tmp = Float64(0.5 * Float64(sin(Float64(t_0 - pi)) - sin(t_0)));
	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) <= 4e-5)
		tmp = sin((abs(z0) * -3.141592653589793));
	else
		tmp = 0.5 * (sin((t_0 - pi)) - sin(t_0));
	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.0], TMP2 = Sign[z0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z0], $MachinePrecision], 4e-5], N[Sin[N[(N[Abs[z0], $MachinePrecision] * -3.141592653589793), $MachinePrecision]], $MachinePrecision], N[(0.5 * N[(N[Sin[N[(t$95$0 - Pi), $MachinePrecision]], $MachinePrecision] - N[Sin[t$95$0], $MachinePrecision]), $MachinePrecision]), $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 4 \cdot 10^{-5}:\\
\;\;\;\;\sin \left(\left|z0\right| \cdot -3.141592653589793\right)\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\sin \left(t\_0 - \pi\right) - \sin t\_0\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < 4.0000000000000003e-5

    1. Initial program 53.5%

      \[\sin \left(z0 \cdot \left(-\pi\right)\right) \]
    2. Evaluated real constant53.5%

      \[\leadsto \sin \left(z0 \cdot \color{blue}{-3.141592653589793}\right) \]

    if 4.0000000000000003e-5 < z0

    1. Initial program 53.5%

      \[\sin \left(z0 \cdot \left(-\pi\right)\right) \]
    2. Step-by-step derivation
      1. lift-sin.f64N/A

        \[\leadsto \color{blue}{\sin \left(z0 \cdot \left(-\pi\right)\right)} \]
      2. lift-*.f64N/A

        \[\leadsto \sin \color{blue}{\left(z0 \cdot \left(-\pi\right)\right)} \]
      3. lift-neg.f64N/A

        \[\leadsto \sin \left(z0 \cdot \color{blue}{\left(\mathsf{neg}\left(\pi\right)\right)}\right) \]
      4. distribute-rgt-neg-outN/A

        \[\leadsto \sin \color{blue}{\left(\mathsf{neg}\left(z0 \cdot \pi\right)\right)} \]
      5. sin-negN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\sin \left(z0 \cdot \pi\right)\right)} \]
      6. sin-+PI-revN/A

        \[\leadsto \color{blue}{\sin \left(z0 \cdot \pi + \mathsf{PI}\left(\right)\right)} \]
      7. lower-sin.f64N/A

        \[\leadsto \color{blue}{\sin \left(z0 \cdot \pi + \mathsf{PI}\left(\right)\right)} \]
      8. lift-PI.f64N/A

        \[\leadsto \sin \left(z0 \cdot \pi + \color{blue}{\pi}\right) \]
      9. lower-+.f64N/A

        \[\leadsto \sin \color{blue}{\left(z0 \cdot \pi + \pi\right)} \]
      10. *-commutativeN/A

        \[\leadsto \sin \left(\color{blue}{\pi \cdot z0} + \pi\right) \]
      11. lower-*.f646.4%

        \[\leadsto \sin \left(\color{blue}{\pi \cdot z0} + \pi\right) \]
    3. Applied rewrites6.4%

      \[\leadsto \color{blue}{\sin \left(\pi \cdot z0 + \pi\right)} \]
    4. Step-by-step derivation
      1. lift-sin.f64N/A

        \[\leadsto \color{blue}{\sin \left(\pi \cdot z0 + \pi\right)} \]
      2. lift-+.f64N/A

        \[\leadsto \sin \color{blue}{\left(\pi \cdot z0 + \pi\right)} \]
      3. lift-PI.f64N/A

        \[\leadsto \sin \left(\pi \cdot z0 + \color{blue}{\mathsf{PI}\left(\right)}\right) \]
      4. sin-+PIN/A

        \[\leadsto \color{blue}{\mathsf{neg}\left(\sin \left(\pi \cdot z0\right)\right)} \]
      5. mul-1-negN/A

        \[\leadsto \color{blue}{-1 \cdot \sin \left(\pi \cdot z0\right)} \]
      6. cos-PIN/A

        \[\leadsto \color{blue}{\cos \mathsf{PI}\left(\right)} \cdot \sin \left(\pi \cdot z0\right) \]
      7. lift-PI.f64N/A

        \[\leadsto \cos \color{blue}{\pi} \cdot \sin \left(\pi \cdot z0\right) \]
      8. cos-neg-revN/A

        \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(\pi\right)\right)} \cdot \sin \left(\pi \cdot z0\right) \]
      9. lift-neg.f64N/A

        \[\leadsto \cos \color{blue}{\left(-\pi\right)} \cdot \sin \left(\pi \cdot z0\right) \]
      10. sin-+PI/2-revN/A

        \[\leadsto \color{blue}{\sin \left(\left(-\pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \cdot \sin \left(\pi \cdot z0\right) \]
      11. sin-multN/A

        \[\leadsto \color{blue}{\frac{\cos \left(\left(\left(-\pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) - \pi \cdot z0\right) - \cos \left(\left(\left(-\pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) + \pi \cdot z0\right)}{2}} \]
      12. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(\left(\left(-\pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) - \pi \cdot z0\right) - \cos \left(\left(\left(-\pi\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) + \pi \cdot z0\right)}{2}} \]
    5. Applied rewrites52.4%

      \[\leadsto \color{blue}{\frac{\cos \left(\left(\left(-\pi\right) + \pi \cdot 0.5\right) - \pi \cdot z0\right) - \cos \left(\left(\left(-\pi\right) + \pi \cdot 0.5\right) + \pi \cdot z0\right)}{2}} \]
    6. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) - \pi \cdot z0\right) - \cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) + \pi \cdot z0\right)}{2}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) - \pi \cdot z0\right) - \cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) + \pi \cdot z0\right)}}{2} \]
      3. lift-cos.f64N/A

        \[\leadsto \frac{\color{blue}{\cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) - \pi \cdot z0\right)} - \cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) + \pi \cdot z0\right)}{2} \]
      4. lift--.f64N/A

        \[\leadsto \frac{\cos \color{blue}{\left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) - \pi \cdot z0\right)} - \cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) + \pi \cdot z0\right)}{2} \]
      5. lift-cos.f64N/A

        \[\leadsto \frac{\cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) - \pi \cdot z0\right) - \color{blue}{\cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) + \pi \cdot z0\right)}}{2} \]
      6. lift-+.f64N/A

        \[\leadsto \frac{\cos \left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) - \pi \cdot z0\right) - \cos \color{blue}{\left(\left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) + \pi \cdot z0\right)}}{2} \]
      7. sin-mult-revN/A

        \[\leadsto \color{blue}{\sin \left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right) \cdot \sin \left(\pi \cdot z0\right)} \]
      8. *-commutativeN/A

        \[\leadsto \color{blue}{\sin \left(\pi \cdot z0\right) \cdot \sin \left(\left(-\pi\right) + \pi \cdot \frac{1}{2}\right)} \]
    7. Applied rewrites51.6%

      \[\leadsto \color{blue}{\frac{\sin \left(z0 \cdot \pi - \pi\right) + \left(-\sin \left(z0 \cdot \pi\right)\right)}{2}} \]
    8. Taylor expanded in z0 around inf

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \left(\sin \left(z0 \cdot \pi - \pi\right) - \sin \left(z0 \cdot \pi\right)\right)} \]
    9. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \color{blue}{\left(\sin \left(z0 \cdot \mathsf{PI}\left(\right) - \mathsf{PI}\left(\right)\right) - \sin \left(z0 \cdot \mathsf{PI}\left(\right)\right)\right)} \]
      2. lower--.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \mathsf{PI}\left(\right) - \mathsf{PI}\left(\right)\right) - \color{blue}{\sin \left(z0 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
      3. lower-sin.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \mathsf{PI}\left(\right) - \mathsf{PI}\left(\right)\right) - \sin \color{blue}{\left(z0 \cdot \mathsf{PI}\left(\right)\right)}\right) \]
      4. lower--.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \mathsf{PI}\left(\right) - \mathsf{PI}\left(\right)\right) - \sin \left(\color{blue}{z0} \cdot \mathsf{PI}\left(\right)\right)\right) \]
      5. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \mathsf{PI}\left(\right) - \mathsf{PI}\left(\right)\right) - \sin \left(z0 \cdot \mathsf{PI}\left(\right)\right)\right) \]
      6. lower-PI.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \pi - \mathsf{PI}\left(\right)\right) - \sin \left(z0 \cdot \mathsf{PI}\left(\right)\right)\right) \]
      7. lower-PI.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \pi - \pi\right) - \sin \left(z0 \cdot \mathsf{PI}\left(\right)\right)\right) \]
      8. lower-sin.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \pi - \pi\right) - \sin \left(z0 \cdot \mathsf{PI}\left(\right)\right)\right) \]
      9. lower-*.f64N/A

        \[\leadsto \frac{1}{2} \cdot \left(\sin \left(z0 \cdot \pi - \pi\right) - \sin \left(z0 \cdot \mathsf{PI}\left(\right)\right)\right) \]
      10. lower-PI.f6451.6%

        \[\leadsto 0.5 \cdot \left(\sin \left(z0 \cdot \pi - \pi\right) - \sin \left(z0 \cdot \pi\right)\right) \]
    10. Applied rewrites51.6%

      \[\leadsto \color{blue}{0.5 \cdot \left(\sin \left(z0 \cdot \pi - \pi\right) - \sin \left(z0 \cdot \pi\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 53.5% accurate, 1.0× speedup?

\[\sin \left(z0 \cdot -3.141592653589793\right) \]
(FPCore (z0)
  :precision binary64
  (sin (* z0 -3.141592653589793)))
double code(double z0) {
	return sin((z0 * -3.141592653589793));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(z0)
use fmin_fmax_functions
    real(8), intent (in) :: z0
    code = sin((z0 * (-3.141592653589793d0)))
end function
public static double code(double z0) {
	return Math.sin((z0 * -3.141592653589793));
}
def code(z0):
	return math.sin((z0 * -3.141592653589793))
function code(z0)
	return sin(Float64(z0 * -3.141592653589793))
end
function tmp = code(z0)
	tmp = sin((z0 * -3.141592653589793));
end
code[z0_] := N[Sin[N[(z0 * -3.141592653589793), $MachinePrecision]], $MachinePrecision]
\sin \left(z0 \cdot -3.141592653589793\right)
Derivation
  1. Initial program 53.5%

    \[\sin \left(z0 \cdot \left(-\pi\right)\right) \]
  2. Evaluated real constant53.5%

    \[\leadsto \sin \left(z0 \cdot \color{blue}{-3.141592653589793}\right) \]
  3. Add Preprocessing

Alternative 3: 3.7% accurate, 1.0× speedup?

\[\cos \left(1.5707963267948966 - \pi\right) \]
(FPCore (z0)
  :precision binary64
  (cos (- 1.5707963267948966 PI)))
double code(double z0) {
	return cos((1.5707963267948966 - ((double) M_PI)));
}
public static double code(double z0) {
	return Math.cos((1.5707963267948966 - Math.PI));
}
def code(z0):
	return math.cos((1.5707963267948966 - math.pi))
function code(z0)
	return cos(Float64(1.5707963267948966 - pi))
end
function tmp = code(z0)
	tmp = cos((1.5707963267948966 - pi));
end
code[z0_] := N[Cos[N[(1.5707963267948966 - Pi), $MachinePrecision]], $MachinePrecision]
\cos \left(1.5707963267948966 - \pi\right)
Derivation
  1. Initial program 53.5%

    \[\sin \left(z0 \cdot \left(-\pi\right)\right) \]
  2. Step-by-step derivation
    1. lift-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(z0 \cdot \left(-\pi\right)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \sin \color{blue}{\left(z0 \cdot \left(-\pi\right)\right)} \]
    3. lift-neg.f64N/A

      \[\leadsto \sin \left(z0 \cdot \color{blue}{\left(\mathsf{neg}\left(\pi\right)\right)}\right) \]
    4. distribute-rgt-neg-outN/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{neg}\left(z0 \cdot \pi\right)\right)} \]
    5. sin-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\sin \left(z0 \cdot \pi\right)\right)} \]
    6. sin-+PI-revN/A

      \[\leadsto \color{blue}{\sin \left(z0 \cdot \pi + \mathsf{PI}\left(\right)\right)} \]
    7. lower-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(z0 \cdot \pi + \mathsf{PI}\left(\right)\right)} \]
    8. lift-PI.f64N/A

      \[\leadsto \sin \left(z0 \cdot \pi + \color{blue}{\pi}\right) \]
    9. lower-+.f64N/A

      \[\leadsto \sin \color{blue}{\left(z0 \cdot \pi + \pi\right)} \]
    10. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot z0} + \pi\right) \]
    11. lower-*.f646.4%

      \[\leadsto \sin \left(\color{blue}{\pi \cdot z0} + \pi\right) \]
  3. Applied rewrites6.4%

    \[\leadsto \color{blue}{\sin \left(\pi \cdot z0 + \pi\right)} \]
  4. Step-by-step derivation
    1. lift-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(\pi \cdot z0 + \pi\right)} \]
    2. lift-+.f64N/A

      \[\leadsto \sin \color{blue}{\left(\pi \cdot z0 + \pi\right)} \]
    3. add-flipN/A

      \[\leadsto \sin \color{blue}{\left(\pi \cdot z0 - \left(\mathsf{neg}\left(\pi\right)\right)\right)} \]
    4. lift-neg.f64N/A

      \[\leadsto \sin \left(\pi \cdot z0 - \color{blue}{\left(-\pi\right)}\right) \]
    5. sub-negate-revN/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{neg}\left(\left(\left(-\pi\right) - \pi \cdot z0\right)\right)\right)} \]
    6. sin-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\sin \left(\left(-\pi\right) - \pi \cdot z0\right)\right)} \]
    7. cos-+PI/2-revN/A

      \[\leadsto \color{blue}{\cos \left(\left(\left(-\pi\right) - \pi \cdot z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
    8. lower-cos.f64N/A

      \[\leadsto \color{blue}{\cos \left(\left(\left(-\pi\right) - \pi \cdot z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
    9. lower-+.f64N/A

      \[\leadsto \cos \color{blue}{\left(\left(\left(-\pi\right) - \pi \cdot z0\right) + \frac{\mathsf{PI}\left(\right)}{2}\right)} \]
    10. sub-negate-revN/A

      \[\leadsto \cos \left(\color{blue}{\left(\mathsf{neg}\left(\left(\pi \cdot z0 - \left(-\pi\right)\right)\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
    11. lift-neg.f64N/A

      \[\leadsto \cos \left(\left(\mathsf{neg}\left(\left(\pi \cdot z0 - \color{blue}{\left(\mathsf{neg}\left(\pi\right)\right)}\right)\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
    12. add-flipN/A

      \[\leadsto \cos \left(\left(\mathsf{neg}\left(\color{blue}{\left(\pi \cdot z0 + \pi\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
    13. lift-+.f64N/A

      \[\leadsto \cos \left(\left(\mathsf{neg}\left(\color{blue}{\left(\pi \cdot z0 + \pi\right)}\right)\right) + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
    14. lower-neg.f64N/A

      \[\leadsto \cos \left(\color{blue}{\left(-\left(\pi \cdot z0 + \pi\right)\right)} + \frac{\mathsf{PI}\left(\right)}{2}\right) \]
    15. lift-PI.f64N/A

      \[\leadsto \cos \left(\left(-\left(\pi \cdot z0 + \pi\right)\right) + \frac{\color{blue}{\pi}}{2}\right) \]
    16. mult-flipN/A

      \[\leadsto \cos \left(\left(-\left(\pi \cdot z0 + \pi\right)\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \]
    17. lower-*.f64N/A

      \[\leadsto \cos \left(\left(-\left(\pi \cdot z0 + \pi\right)\right) + \color{blue}{\pi \cdot \frac{1}{2}}\right) \]
    18. metadata-eval6.4%

      \[\leadsto \cos \left(\left(-\left(\pi \cdot z0 + \pi\right)\right) + \pi \cdot \color{blue}{0.5}\right) \]
  5. Applied rewrites6.4%

    \[\leadsto \color{blue}{\cos \left(\left(-\left(\pi \cdot z0 + \pi\right)\right) + \pi \cdot 0.5\right)} \]
  6. Evaluated real constant6.4%

    \[\leadsto \cos \left(\left(-\left(\pi \cdot z0 + \pi\right)\right) + \color{blue}{1.5707963267948966}\right) \]
  7. Taylor expanded in z0 around 0

    \[\leadsto \cos \color{blue}{\left(\frac{884279719003555}{562949953421312} - \pi\right)} \]
  8. Step-by-step derivation
    1. lower--.f64N/A

      \[\leadsto \cos \left(\frac{884279719003555}{562949953421312} - \color{blue}{\mathsf{PI}\left(\right)}\right) \]
    2. lower-PI.f643.7%

      \[\leadsto \cos \left(1.5707963267948966 - \pi\right) \]
  9. Applied rewrites3.7%

    \[\leadsto \cos \color{blue}{\left(1.5707963267948966 - \pi\right)} \]
  10. Add Preprocessing

Alternative 4: 3.7% accurate, 1.1× speedup?

\[\sin \pi \]
(FPCore (z0)
  :precision binary64
  (sin PI))
double code(double z0) {
	return sin(((double) M_PI));
}
public static double code(double z0) {
	return Math.sin(Math.PI);
}
def code(z0):
	return math.sin(math.pi)
function code(z0)
	return sin(pi)
end
function tmp = code(z0)
	tmp = sin(pi);
end
code[z0_] := N[Sin[Pi], $MachinePrecision]
\sin \pi
Derivation
  1. Initial program 53.5%

    \[\sin \left(z0 \cdot \left(-\pi\right)\right) \]
  2. Step-by-step derivation
    1. lift-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(z0 \cdot \left(-\pi\right)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \sin \color{blue}{\left(z0 \cdot \left(-\pi\right)\right)} \]
    3. lift-neg.f64N/A

      \[\leadsto \sin \left(z0 \cdot \color{blue}{\left(\mathsf{neg}\left(\pi\right)\right)}\right) \]
    4. distribute-rgt-neg-outN/A

      \[\leadsto \sin \color{blue}{\left(\mathsf{neg}\left(z0 \cdot \pi\right)\right)} \]
    5. sin-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\sin \left(z0 \cdot \pi\right)\right)} \]
    6. sin-+PI-revN/A

      \[\leadsto \color{blue}{\sin \left(z0 \cdot \pi + \mathsf{PI}\left(\right)\right)} \]
    7. lower-sin.f64N/A

      \[\leadsto \color{blue}{\sin \left(z0 \cdot \pi + \mathsf{PI}\left(\right)\right)} \]
    8. lift-PI.f64N/A

      \[\leadsto \sin \left(z0 \cdot \pi + \color{blue}{\pi}\right) \]
    9. lower-+.f64N/A

      \[\leadsto \sin \color{blue}{\left(z0 \cdot \pi + \pi\right)} \]
    10. *-commutativeN/A

      \[\leadsto \sin \left(\color{blue}{\pi \cdot z0} + \pi\right) \]
    11. lower-*.f646.4%

      \[\leadsto \sin \left(\color{blue}{\pi \cdot z0} + \pi\right) \]
  3. Applied rewrites6.4%

    \[\leadsto \color{blue}{\sin \left(\pi \cdot z0 + \pi\right)} \]
  4. Taylor expanded in z0 around 0

    \[\leadsto \sin \color{blue}{\pi} \]
  5. Step-by-step derivation
    1. lower-PI.f643.7%

      \[\leadsto \sin \pi \]
  6. Applied rewrites3.7%

    \[\leadsto \sin \color{blue}{\pi} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2025250 
(FPCore (z0)
  :name "(sin (* z0 (- PI)))"
  :precision binary64
  (sin (* z0 (- PI))))