(sin (* (+ PI PI) z0))

Percentage Accurate: 53.4% → 98.7%
Time: 3.8s
Alternatives: 4
Speedup: 1.0×

Specification

?
\[\sin \left(\left(\pi + \pi\right) \cdot z0\right) \]
(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)

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.4% accurate, 1.0× speedup?

\[\sin \left(\left(\pi + \pi\right) \cdot z0\right) \]
(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)

Alternative 1: 98.7% accurate, 0.3× speedup?

\[\mathsf{copysign}\left(1, z0\right) \cdot \begin{array}{l} \mathbf{if}\;\left|z0\right| \leq 28000000000000:\\ \;\;\;\;\sin \left(2.1450293971110255 \cdot \left(2.9291837751230467 \cdot \left|z0\right|\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos \left(\pi \cdot \left(\left|z0\right| - 0.5\right)\right) - \cos \left(\left(0.5 + \left|z0\right|\right) \cdot \pi\right)\right) \cdot 1\\ \end{array} \]
(FPCore (z0)
  :precision binary64
  (*
 (copysign 1.0 z0)
 (if (<= (fabs z0) 28000000000000.0)
   (sin (* 2.1450293971110255 (* 2.9291837751230467 (fabs z0))))
   (*
    (- (cos (* PI (- (fabs z0) 0.5))) (cos (* (+ 0.5 (fabs z0)) PI)))
    1.0))))
double code(double z0) {
	double tmp;
	if (fabs(z0) <= 28000000000000.0) {
		tmp = sin((2.1450293971110255 * (2.9291837751230467 * fabs(z0))));
	} else {
		tmp = (cos((((double) M_PI) * (fabs(z0) - 0.5))) - cos(((0.5 + fabs(z0)) * ((double) M_PI)))) * 1.0;
	}
	return copysign(1.0, z0) * tmp;
}
public static double code(double z0) {
	double tmp;
	if (Math.abs(z0) <= 28000000000000.0) {
		tmp = Math.sin((2.1450293971110255 * (2.9291837751230467 * Math.abs(z0))));
	} else {
		tmp = (Math.cos((Math.PI * (Math.abs(z0) - 0.5))) - Math.cos(((0.5 + Math.abs(z0)) * Math.PI))) * 1.0;
	}
	return Math.copySign(1.0, z0) * tmp;
}
def code(z0):
	tmp = 0
	if math.fabs(z0) <= 28000000000000.0:
		tmp = math.sin((2.1450293971110255 * (2.9291837751230467 * math.fabs(z0))))
	else:
		tmp = (math.cos((math.pi * (math.fabs(z0) - 0.5))) - math.cos(((0.5 + math.fabs(z0)) * math.pi))) * 1.0
	return math.copysign(1.0, z0) * tmp
function code(z0)
	tmp = 0.0
	if (abs(z0) <= 28000000000000.0)
		tmp = sin(Float64(2.1450293971110255 * Float64(2.9291837751230467 * abs(z0))));
	else
		tmp = Float64(Float64(cos(Float64(pi * Float64(abs(z0) - 0.5))) - cos(Float64(Float64(0.5 + abs(z0)) * pi))) * 1.0);
	end
	return Float64(copysign(1.0, z0) * tmp)
end
function tmp_2 = code(z0)
	tmp = 0.0;
	if (abs(z0) <= 28000000000000.0)
		tmp = sin((2.1450293971110255 * (2.9291837751230467 * abs(z0))));
	else
		tmp = (cos((pi * (abs(z0) - 0.5))) - cos(((0.5 + abs(z0)) * pi))) * 1.0;
	end
	tmp_2 = (sign(z0) * abs(1.0)) * tmp;
end
code[z0_] := N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z0]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[N[Abs[z0], $MachinePrecision], 28000000000000.0], N[Sin[N[(2.1450293971110255 * N[(2.9291837751230467 * N[Abs[z0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[Cos[N[(Pi * N[(N[Abs[z0], $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Cos[N[(N[(0.5 + N[Abs[z0], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 1.0), $MachinePrecision]]), $MachinePrecision]
\mathsf{copysign}\left(1, z0\right) \cdot \begin{array}{l}
\mathbf{if}\;\left|z0\right| \leq 28000000000000:\\
\;\;\;\;\sin \left(2.1450293971110255 \cdot \left(2.9291837751230467 \cdot \left|z0\right|\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\cos \left(\pi \cdot \left(\left|z0\right| - 0.5\right)\right) - \cos \left(\left(0.5 + \left|z0\right|\right) \cdot \pi\right)\right) \cdot 1\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z0 < 2.8e13

    1. Initial program 53.4%

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

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

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

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

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

        \[\leadsto \sin \left(\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{PI}\left(\right)} + \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot z0\right) \]
      6. add-cube-cbrtN/A

        \[\leadsto \sin \left(\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{PI}\left(\right)} + \color{blue}{\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{PI}\left(\right)}}\right) \cdot z0\right) \]
      7. distribute-lft-outN/A

        \[\leadsto \sin \left(\color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right)\right)} \cdot z0\right) \]
      8. associate-*l*N/A

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

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

        \[\leadsto \sin \left(\left(\sqrt[3]{\color{blue}{\pi}} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
      11. pow1/3N/A

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

        \[\leadsto \sin \left(\left({\pi}^{\frac{1}{3}} \cdot \sqrt[3]{\color{blue}{\pi}}\right) \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
      13. pow1/3N/A

        \[\leadsto \sin \left(\left({\pi}^{\frac{1}{3}} \cdot \color{blue}{{\pi}^{\frac{1}{3}}}\right) \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
      14. pow-prod-upN/A

        \[\leadsto \sin \left(\color{blue}{{\pi}^{\left(\frac{1}{3} + \frac{1}{3}\right)}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
      15. lower-pow.f64N/A

        \[\leadsto \sin \left(\color{blue}{{\pi}^{\left(\frac{1}{3} + \frac{1}{3}\right)}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
      16. metadata-evalN/A

        \[\leadsto \sin \left({\pi}^{\color{blue}{\frac{2}{3}}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
      17. lower-*.f64N/A

        \[\leadsto \sin \left({\pi}^{\frac{2}{3}} \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)}\right) \]
    3. Applied rewrites52.9%

      \[\leadsto \sin \color{blue}{\left({\pi}^{0.6666666666666666} \cdot \left(\left(2 \cdot \sqrt[3]{\pi}\right) \cdot z0\right)\right)} \]
    4. Evaluated real constant53.4%

      \[\leadsto \sin \left({\pi}^{0.6666666666666666} \cdot \left(\color{blue}{2.9291837751230467} \cdot z0\right)\right) \]
    5. Evaluated real constant53.4%

      \[\leadsto \sin \left(\color{blue}{2.1450293971110255} \cdot \left(2.9291837751230467 \cdot z0\right)\right) \]

    if 2.8e13 < z0

    1. Initial program 53.4%

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

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

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

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

        \[\leadsto \sin \left(\color{blue}{\left(2 \cdot \pi\right)} \cdot z0\right) \]
      5. associate-*l*N/A

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

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

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

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

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

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

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

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

        \[\leadsto 2 \cdot \left(\sin \left(z0 \cdot \pi\right) \cdot \color{blue}{\cos \left(z0 \cdot \pi\right)}\right) \]
      14. lower-*.f6453.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 2 \cdot \frac{\cos \left(\pi \cdot \color{blue}{\frac{1}{2}} - \pi \cdot z0\right) - \cos \left(\pi \cdot \left(\left(-z0\right) + 0.5\right) + \pi \cdot z0\right)}{2} \]
    7. Step-by-step derivation
      1. Applied rewrites4.8%

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

        \[\leadsto 2 \cdot \frac{\cos \left(\pi \cdot 0.5 - \pi \cdot z0\right) - \cos \left(\pi \cdot \color{blue}{\frac{1}{2}} + \pi \cdot z0\right)}{2} \]
      3. Step-by-step derivation
        1. Applied rewrites50.7%

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

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

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

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

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

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

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

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

      Alternative 2: 53.4% accurate, 1.0× speedup?

      \[\sin \left(2.1450293971110255 \cdot \left(2.9291837751230467 \cdot z0\right)\right) \]
      (FPCore (z0)
        :precision binary64
        (sin (* 2.1450293971110255 (* 2.9291837751230467 z0))))
      double code(double z0) {
      	return sin((2.1450293971110255 * (2.9291837751230467 * z0)));
      }
      
      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((2.1450293971110255d0 * (2.9291837751230467d0 * z0)))
      end function
      
      public static double code(double z0) {
      	return Math.sin((2.1450293971110255 * (2.9291837751230467 * z0)));
      }
      
      def code(z0):
      	return math.sin((2.1450293971110255 * (2.9291837751230467 * z0)))
      
      function code(z0)
      	return sin(Float64(2.1450293971110255 * Float64(2.9291837751230467 * z0)))
      end
      
      function tmp = code(z0)
      	tmp = sin((2.1450293971110255 * (2.9291837751230467 * z0)));
      end
      
      code[z0_] := N[Sin[N[(2.1450293971110255 * N[(2.9291837751230467 * z0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
      
      \sin \left(2.1450293971110255 \cdot \left(2.9291837751230467 \cdot z0\right)\right)
      
      Derivation
      1. Initial program 53.4%

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

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

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

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

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

          \[\leadsto \sin \left(\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{PI}\left(\right)} + \color{blue}{\mathsf{PI}\left(\right)}\right) \cdot z0\right) \]
        6. add-cube-cbrtN/A

          \[\leadsto \sin \left(\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{PI}\left(\right)} + \color{blue}{\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \sqrt[3]{\mathsf{PI}\left(\right)}}\right) \cdot z0\right) \]
        7. distribute-lft-outN/A

          \[\leadsto \sin \left(\color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right)\right)} \cdot z0\right) \]
        8. associate-*l*N/A

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

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

          \[\leadsto \sin \left(\left(\sqrt[3]{\color{blue}{\pi}} \cdot \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
        11. pow1/3N/A

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

          \[\leadsto \sin \left(\left({\pi}^{\frac{1}{3}} \cdot \sqrt[3]{\color{blue}{\pi}}\right) \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
        13. pow1/3N/A

          \[\leadsto \sin \left(\left({\pi}^{\frac{1}{3}} \cdot \color{blue}{{\pi}^{\frac{1}{3}}}\right) \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
        14. pow-prod-upN/A

          \[\leadsto \sin \left(\color{blue}{{\pi}^{\left(\frac{1}{3} + \frac{1}{3}\right)}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
        15. lower-pow.f64N/A

          \[\leadsto \sin \left(\color{blue}{{\pi}^{\left(\frac{1}{3} + \frac{1}{3}\right)}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
        16. metadata-evalN/A

          \[\leadsto \sin \left({\pi}^{\color{blue}{\frac{2}{3}}} \cdot \left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)\right) \]
        17. lower-*.f64N/A

          \[\leadsto \sin \left({\pi}^{\frac{2}{3}} \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{PI}\left(\right)} + \sqrt[3]{\mathsf{PI}\left(\right)}\right) \cdot z0\right)}\right) \]
      3. Applied rewrites52.9%

        \[\leadsto \sin \color{blue}{\left({\pi}^{0.6666666666666666} \cdot \left(\left(2 \cdot \sqrt[3]{\pi}\right) \cdot z0\right)\right)} \]
      4. Evaluated real constant53.4%

        \[\leadsto \sin \left({\pi}^{0.6666666666666666} \cdot \left(\color{blue}{2.9291837751230467} \cdot z0\right)\right) \]
      5. Evaluated real constant53.4%

        \[\leadsto \sin \left(\color{blue}{2.1450293971110255} \cdot \left(2.9291837751230467 \cdot z0\right)\right) \]
      6. Add Preprocessing

      Alternative 3: 53.4% accurate, 1.0× speedup?

      \[\sin \left(6.283185307179586 \cdot z0\right) \]
      (FPCore (z0)
        :precision binary64
        (sin (* 6.283185307179586 z0)))
      double code(double z0) {
      	return sin((6.283185307179586 * z0));
      }
      
      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((6.283185307179586d0 * z0))
      end function
      
      public static double code(double z0) {
      	return Math.sin((6.283185307179586 * z0));
      }
      
      def code(z0):
      	return math.sin((6.283185307179586 * z0))
      
      function code(z0)
      	return sin(Float64(6.283185307179586 * z0))
      end
      
      function tmp = code(z0)
      	tmp = sin((6.283185307179586 * z0));
      end
      
      code[z0_] := N[Sin[N[(6.283185307179586 * z0), $MachinePrecision]], $MachinePrecision]
      
      \sin \left(6.283185307179586 \cdot z0\right)
      
      Derivation
      1. Initial program 53.4%

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

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

      Alternative 4: 51.1% accurate, 12.1× speedup?

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

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

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

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

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

          \[\leadsto \sin \left(\color{blue}{\left(2 \cdot \pi\right)} \cdot z0\right) \]
        5. associate-*l*N/A

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

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

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

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

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

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

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

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

          \[\leadsto 2 \cdot \left(\sin \left(z0 \cdot \pi\right) \cdot \color{blue}{\cos \left(z0 \cdot \pi\right)}\right) \]
        14. lower-*.f6453.4%

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

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

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

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

          \[\leadsto 2 \cdot \left(z0 \cdot \color{blue}{\mathsf{PI}\left(\right)}\right) \]
        3. lower-PI.f6451.1%

          \[\leadsto 2 \cdot \left(z0 \cdot \pi\right) \]
      6. Applied rewrites51.1%

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

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

          \[\leadsto 2 \cdot \left(z0 \cdot \color{blue}{\pi}\right) \]
        3. associate-*r*N/A

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

          \[\leadsto \left(2 \cdot z0\right) \cdot \pi \]
        5. lower-*.f6451.1%

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

          \[\leadsto \left(2 \cdot z0\right) \cdot \pi \]
        7. count-2-revN/A

          \[\leadsto \left(z0 + z0\right) \cdot \pi \]
        8. lower-+.f6451.1%

          \[\leadsto \left(z0 + z0\right) \cdot \pi \]
      8. Applied rewrites51.1%

        \[\leadsto \left(z0 + z0\right) \cdot \color{blue}{\pi} \]
      9. Add Preprocessing

      Reproduce

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