1/256 sin(-2 PI n k / 256) (-sin(n/256 (2 PI) + 2 PI))

Percentage Accurate: 59.5% → 99.7%
Time: 5.0s
Alternatives: 8
Speedup: 108.2×

Specification

?
\[\left(0 \leq n \land n \leq 256\right) \land \left(0 \leq k \land k \leq 256\right)\]
\[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
(FPCore (n k)
  :precision binary64
  (*
 (/ 1.0 256.0)
 (*
  (sin (* (- 2.0) (* PI (* n (/ k 256.0)))))
  (- (sin (+ (* (/ n 256.0) (* 2.0 PI)) (* 2.0 PI)))))))
double code(double n, double k) {
	return (1.0 / 256.0) * (sin((-2.0 * (((double) M_PI) * (n * (k / 256.0))))) * -sin((((n / 256.0) * (2.0 * ((double) M_PI))) + (2.0 * ((double) M_PI)))));
}
public static double code(double n, double k) {
	return (1.0 / 256.0) * (Math.sin((-2.0 * (Math.PI * (n * (k / 256.0))))) * -Math.sin((((n / 256.0) * (2.0 * Math.PI)) + (2.0 * Math.PI))));
}
def code(n, k):
	return (1.0 / 256.0) * (math.sin((-2.0 * (math.pi * (n * (k / 256.0))))) * -math.sin((((n / 256.0) * (2.0 * math.pi)) + (2.0 * math.pi))))
function code(n, k)
	return Float64(Float64(1.0 / 256.0) * Float64(sin(Float64(Float64(-2.0) * Float64(pi * Float64(n * Float64(k / 256.0))))) * Float64(-sin(Float64(Float64(Float64(n / 256.0) * Float64(2.0 * pi)) + Float64(2.0 * pi))))))
end
function tmp = code(n, k)
	tmp = (1.0 / 256.0) * (sin((-2.0 * (pi * (n * (k / 256.0))))) * -sin((((n / 256.0) * (2.0 * pi)) + (2.0 * pi))));
end
code[n_, k_] := N[(N[(1.0 / 256.0), $MachinePrecision] * N[(N[Sin[N[((-2.0) * N[(Pi * N[(n * N[(k / 256.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sin[N[(N[(N[(n / 256.0), $MachinePrecision] * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision] + N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\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 8 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: 59.5% accurate, 1.0× speedup?

\[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
(FPCore (n k)
  :precision binary64
  (*
 (/ 1.0 256.0)
 (*
  (sin (* (- 2.0) (* PI (* n (/ k 256.0)))))
  (- (sin (+ (* (/ n 256.0) (* 2.0 PI)) (* 2.0 PI)))))))
double code(double n, double k) {
	return (1.0 / 256.0) * (sin((-2.0 * (((double) M_PI) * (n * (k / 256.0))))) * -sin((((n / 256.0) * (2.0 * ((double) M_PI))) + (2.0 * ((double) M_PI)))));
}
public static double code(double n, double k) {
	return (1.0 / 256.0) * (Math.sin((-2.0 * (Math.PI * (n * (k / 256.0))))) * -Math.sin((((n / 256.0) * (2.0 * Math.PI)) + (2.0 * Math.PI))));
}
def code(n, k):
	return (1.0 / 256.0) * (math.sin((-2.0 * (math.pi * (n * (k / 256.0))))) * -math.sin((((n / 256.0) * (2.0 * math.pi)) + (2.0 * math.pi))))
function code(n, k)
	return Float64(Float64(1.0 / 256.0) * Float64(sin(Float64(Float64(-2.0) * Float64(pi * Float64(n * Float64(k / 256.0))))) * Float64(-sin(Float64(Float64(Float64(n / 256.0) * Float64(2.0 * pi)) + Float64(2.0 * pi))))))
end
function tmp = code(n, k)
	tmp = (1.0 / 256.0) * (sin((-2.0 * (pi * (n * (k / 256.0))))) * -sin((((n / 256.0) * (2.0 * pi)) + (2.0 * pi))));
end
code[n_, k_] := N[(N[(1.0 / 256.0), $MachinePrecision] * N[(N[Sin[N[((-2.0) * N[(Pi * N[(n * N[(k / 256.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * (-N[Sin[N[(N[(N[(n / 256.0), $MachinePrecision] * N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision] + N[(2.0 * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]
\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right)

Alternative 1: 99.7% accurate, 2.1× speedup?

\[\left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \left(\sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right) \cdot \pi\right)\right) \cdot n \]
(FPCore (n k)
  :precision binary64
  (* (* (* 3.0517578125e-5 k) (* (sin (* (* 0.0078125 n) PI)) PI)) n))
double code(double n, double k) {
	return ((3.0517578125e-5 * k) * (sin(((0.0078125 * n) * ((double) M_PI))) * ((double) M_PI))) * n;
}
public static double code(double n, double k) {
	return ((3.0517578125e-5 * k) * (Math.sin(((0.0078125 * n) * Math.PI)) * Math.PI)) * n;
}
def code(n, k):
	return ((3.0517578125e-5 * k) * (math.sin(((0.0078125 * n) * math.pi)) * math.pi)) * n
function code(n, k)
	return Float64(Float64(Float64(3.0517578125e-5 * k) * Float64(sin(Float64(Float64(0.0078125 * n) * pi)) * pi)) * n)
end
function tmp = code(n, k)
	tmp = ((3.0517578125e-5 * k) * (sin(((0.0078125 * n) * pi)) * pi)) * n;
end
code[n_, k_] := N[(N[(N[(3.0517578125e-5 * k), $MachinePrecision] * N[(N[Sin[N[(N[(0.0078125 * n), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision] * n), $MachinePrecision]
\left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \left(\sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right) \cdot \pi\right)\right) \cdot n
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Applied rewrites99.8%

    \[\leadsto \frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(n \cdot 0.0078125\right) \cdot \pi\right), -1, \cos \left(\left(n \cdot -0.0078125\right) \cdot \pi\right) \cdot 0\right)}\right) \]
  3. Taylor expanded in k around 0

    \[\leadsto \color{blue}{\frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

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

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \color{blue}{\left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)}\right) \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)}\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    5. lower-PI.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \color{blue}{\left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    6. lower-sin.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    8. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    9. lower-PI.f6499.7%

      \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right) \]
  5. Applied rewrites99.7%

    \[\leadsto \color{blue}{3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \color{blue}{\left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \color{blue}{\left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)}\right) \]
    3. associate-*r*N/A

      \[\leadsto \left(\frac{1}{32768} \cdot k\right) \cdot \color{blue}{\left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)} \]
    4. lift-*.f64N/A

      \[\leadsto \left(\frac{1}{32768} \cdot k\right) \cdot \left(n \cdot \color{blue}{\left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)}\right) \]
    5. *-commutativeN/A

      \[\leadsto \left(\frac{1}{32768} \cdot k\right) \cdot \left(\left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right) \cdot \color{blue}{n}\right) \]
    6. associate-*r*N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right) \cdot \color{blue}{n} \]
    7. lower-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right) \cdot \color{blue}{n} \]
  7. Applied rewrites99.7%

    \[\leadsto \left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \left(\sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right) \cdot \pi\right)\right) \cdot \color{blue}{n} \]
  8. Add Preprocessing

Alternative 2: 99.7% accurate, 2.1× speedup?

\[\left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \pi\right) \cdot \left(\sin \left(\left(\pi \cdot n\right) \cdot 0.0078125\right) \cdot n\right) \]
(FPCore (n k)
  :precision binary64
  (* (* (* 3.0517578125e-5 k) PI) (* (sin (* (* PI n) 0.0078125)) n)))
double code(double n, double k) {
	return ((3.0517578125e-5 * k) * ((double) M_PI)) * (sin(((((double) M_PI) * n) * 0.0078125)) * n);
}
public static double code(double n, double k) {
	return ((3.0517578125e-5 * k) * Math.PI) * (Math.sin(((Math.PI * n) * 0.0078125)) * n);
}
def code(n, k):
	return ((3.0517578125e-5 * k) * math.pi) * (math.sin(((math.pi * n) * 0.0078125)) * n)
function code(n, k)
	return Float64(Float64(Float64(3.0517578125e-5 * k) * pi) * Float64(sin(Float64(Float64(pi * n) * 0.0078125)) * n))
end
function tmp = code(n, k)
	tmp = ((3.0517578125e-5 * k) * pi) * (sin(((pi * n) * 0.0078125)) * n);
end
code[n_, k_] := N[(N[(N[(3.0517578125e-5 * k), $MachinePrecision] * Pi), $MachinePrecision] * N[(N[Sin[N[(N[(Pi * n), $MachinePrecision] * 0.0078125), $MachinePrecision]], $MachinePrecision] * n), $MachinePrecision]), $MachinePrecision]
\left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \pi\right) \cdot \left(\sin \left(\left(\pi \cdot n\right) \cdot 0.0078125\right) \cdot n\right)
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Applied rewrites99.8%

    \[\leadsto \frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(n \cdot 0.0078125\right) \cdot \pi\right), -1, \cos \left(\left(n \cdot -0.0078125\right) \cdot \pi\right) \cdot 0\right)}\right) \]
  3. Taylor expanded in k around 0

    \[\leadsto \color{blue}{\frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

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

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \color{blue}{\left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)}\right) \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)}\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    5. lower-PI.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \color{blue}{\left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    6. lower-sin.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    8. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    9. lower-PI.f6499.7%

      \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right) \]
  5. Applied rewrites99.7%

    \[\leadsto \color{blue}{3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \color{blue}{\left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \color{blue}{\left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)}\right) \]
    3. associate-*r*N/A

      \[\leadsto \left(\frac{1}{32768} \cdot k\right) \cdot \color{blue}{\left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)} \]
    4. lift-*.f64N/A

      \[\leadsto \left(\frac{1}{32768} \cdot k\right) \cdot \left(n \cdot \color{blue}{\left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)}\right) \]
    5. *-commutativeN/A

      \[\leadsto \left(\frac{1}{32768} \cdot k\right) \cdot \left(\left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right) \cdot \color{blue}{n}\right) \]
    6. associate-*r*N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right) \cdot \color{blue}{n} \]
    7. lower-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right) \cdot \color{blue}{n} \]
  7. Applied rewrites99.7%

    \[\leadsto \left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \left(\sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right) \cdot \pi\right)\right) \cdot \color{blue}{n} \]
  8. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right) \cdot \pi\right)\right) \cdot \color{blue}{n} \]
    2. lift-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right) \cdot \pi\right)\right) \cdot n \]
    3. lift-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right) \cdot \pi\right)\right) \cdot n \]
    4. *-commutativeN/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \left(\pi \cdot \sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)\right)\right) \cdot n \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(\left(\frac{1}{32768} \cdot k\right) \cdot \pi\right) \cdot \sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)\right) \cdot n \]
    6. associate-*l*N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \pi\right) \cdot \color{blue}{\left(\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right) \cdot n\right)} \]
    7. *-commutativeN/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \pi\right) \cdot \left(n \cdot \color{blue}{\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)}\right) \]
    8. lift-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \pi\right) \cdot \left(n \cdot \color{blue}{\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)}\right) \]
    9. lower-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \pi\right) \cdot \color{blue}{\left(n \cdot \sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)\right)} \]
    10. lower-*.f6499.7%

      \[\leadsto \left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \pi\right) \cdot \left(\color{blue}{n} \cdot \sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right)\right) \]
    11. lift-*.f64N/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \pi\right) \cdot \left(n \cdot \color{blue}{\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)}\right) \]
    12. *-commutativeN/A

      \[\leadsto \left(\left(\frac{1}{32768} \cdot k\right) \cdot \pi\right) \cdot \left(\sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right) \cdot \color{blue}{n}\right) \]
    13. lower-*.f6499.7%

      \[\leadsto \left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \pi\right) \cdot \left(\sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right) \cdot \color{blue}{n}\right) \]
  9. Applied rewrites99.7%

    \[\leadsto \left(\left(3.0517578125 \cdot 10^{-5} \cdot k\right) \cdot \pi\right) \cdot \color{blue}{\left(\sin \left(\left(\pi \cdot n\right) \cdot 0.0078125\right) \cdot n\right)} \]
  10. Add Preprocessing

Alternative 3: 99.7% accurate, 2.1× speedup?

\[3.0517578125 \cdot 10^{-5} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right)\right) \cdot \pi\right) \]
(FPCore (n k)
  :precision binary64
  (* 3.0517578125e-5 (* (* (* k n) (sin (* (* 0.0078125 n) PI))) PI)))
double code(double n, double k) {
	return 3.0517578125e-5 * (((k * n) * sin(((0.0078125 * n) * ((double) M_PI)))) * ((double) M_PI));
}
public static double code(double n, double k) {
	return 3.0517578125e-5 * (((k * n) * Math.sin(((0.0078125 * n) * Math.PI))) * Math.PI);
}
def code(n, k):
	return 3.0517578125e-5 * (((k * n) * math.sin(((0.0078125 * n) * math.pi))) * math.pi)
function code(n, k)
	return Float64(3.0517578125e-5 * Float64(Float64(Float64(k * n) * sin(Float64(Float64(0.0078125 * n) * pi))) * pi))
end
function tmp = code(n, k)
	tmp = 3.0517578125e-5 * (((k * n) * sin(((0.0078125 * n) * pi))) * pi);
end
code[n_, k_] := N[(3.0517578125e-5 * N[(N[(N[(k * n), $MachinePrecision] * N[Sin[N[(N[(0.0078125 * n), $MachinePrecision] * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]
3.0517578125 \cdot 10^{-5} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right)\right) \cdot \pi\right)
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Applied rewrites99.8%

    \[\leadsto \frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(n \cdot 0.0078125\right) \cdot \pi\right), -1, \cos \left(\left(n \cdot -0.0078125\right) \cdot \pi\right) \cdot 0\right)}\right) \]
  3. Taylor expanded in k around 0

    \[\leadsto \color{blue}{\frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

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

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \color{blue}{\left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)}\right) \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)}\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    5. lower-PI.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \color{blue}{\left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    6. lower-sin.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    8. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    9. lower-PI.f6499.7%

      \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right) \]
  5. Applied rewrites99.7%

    \[\leadsto \color{blue}{3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \color{blue}{\left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \color{blue}{\left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)}\right)\right) \]
    3. associate-*r*N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(k \cdot n\right) \cdot \color{blue}{\left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)}\right) \]
    4. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(k \cdot n\right) \cdot \left(\pi \cdot \color{blue}{\sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)}\right)\right) \]
    5. *-commutativeN/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(k \cdot n\right) \cdot \left(\sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right) \cdot \color{blue}{\pi}\right)\right) \]
    6. associate-*r*N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right) \cdot \color{blue}{\pi}\right) \]
    7. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right) \cdot \color{blue}{\pi}\right) \]
    8. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right) \cdot \pi\right) \]
    9. lower-*.f6499.7%

      \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right) \cdot \pi\right) \]
    10. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right) \cdot \pi\right) \]
    11. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right) \cdot \pi\right) \]
    12. associate-*l*N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)\right) \cdot \pi\right) \]
    13. lift-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\left(\frac{1}{128} \cdot n\right) \cdot \pi\right)\right) \cdot \pi\right) \]
    14. lift-*.f6499.7%

      \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right)\right) \cdot \pi\right) \]
  7. Applied rewrites99.7%

    \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(\left(\left(k \cdot n\right) \cdot \sin \left(\left(0.0078125 \cdot n\right) \cdot \pi\right)\right) \cdot \color{blue}{\pi}\right) \]
  8. Add Preprocessing

Alternative 4: 99.7% accurate, 2.1× speedup?

\[3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right) \]
(FPCore (n k)
  :precision binary64
  (* 3.0517578125e-5 (* k (* n (* PI (sin (* 0.0078125 (* n PI))))))))
double code(double n, double k) {
	return 3.0517578125e-5 * (k * (n * (((double) M_PI) * sin((0.0078125 * (n * ((double) M_PI)))))));
}
public static double code(double n, double k) {
	return 3.0517578125e-5 * (k * (n * (Math.PI * Math.sin((0.0078125 * (n * Math.PI))))));
}
def code(n, k):
	return 3.0517578125e-5 * (k * (n * (math.pi * math.sin((0.0078125 * (n * math.pi))))))
function code(n, k)
	return Float64(3.0517578125e-5 * Float64(k * Float64(n * Float64(pi * sin(Float64(0.0078125 * Float64(n * pi)))))))
end
function tmp = code(n, k)
	tmp = 3.0517578125e-5 * (k * (n * (pi * sin((0.0078125 * (n * pi))))));
end
code[n_, k_] := N[(3.0517578125e-5 * N[(k * N[(n * N[(Pi * N[Sin[N[(0.0078125 * N[(n * Pi), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Applied rewrites99.8%

    \[\leadsto \frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(n \cdot 0.0078125\right) \cdot \pi\right), -1, \cos \left(\left(n \cdot -0.0078125\right) \cdot \pi\right) \cdot 0\right)}\right) \]
  3. Taylor expanded in k around 0

    \[\leadsto \color{blue}{\frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

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

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \color{blue}{\left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)}\right) \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \color{blue}{\left(\mathsf{PI}\left(\right) \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)}\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\mathsf{PI}\left(\right) \cdot \color{blue}{\sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    5. lower-PI.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \color{blue}{\left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)}\right)\right)\right) \]
    6. lower-sin.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    8. lower-*.f64N/A

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(\frac{1}{128} \cdot \left(n \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right) \]
    9. lower-PI.f6499.7%

      \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right) \]
  5. Applied rewrites99.7%

    \[\leadsto \color{blue}{3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(0.0078125 \cdot \left(n \cdot \pi\right)\right)\right)\right)\right)} \]
  6. Add Preprocessing

Alternative 5: 98.7% accurate, 6.8× speedup?

\[\left(\left(\pi \cdot \pi\right) \cdot n\right) \cdot \left(n \cdot \left(2.384185791015625 \cdot 10^{-7} \cdot k\right)\right) \]
(FPCore (n k)
  :precision binary64
  (* (* (* PI PI) n) (* n (* 2.384185791015625e-7 k))))
double code(double n, double k) {
	return ((((double) M_PI) * ((double) M_PI)) * n) * (n * (2.384185791015625e-7 * k));
}
public static double code(double n, double k) {
	return ((Math.PI * Math.PI) * n) * (n * (2.384185791015625e-7 * k));
}
def code(n, k):
	return ((math.pi * math.pi) * n) * (n * (2.384185791015625e-7 * k))
function code(n, k)
	return Float64(Float64(Float64(pi * pi) * n) * Float64(n * Float64(2.384185791015625e-7 * k)))
end
function tmp = code(n, k)
	tmp = ((pi * pi) * n) * (n * (2.384185791015625e-7 * k));
end
code[n_, k_] := N[(N[(N[(Pi * Pi), $MachinePrecision] * n), $MachinePrecision] * N[(n * N[(2.384185791015625e-7 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(\pi \cdot \pi\right) \cdot n\right) \cdot \left(n \cdot \left(2.384185791015625 \cdot 10^{-7} \cdot k\right)\right)
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Applied rewrites99.8%

    \[\leadsto \frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(n \cdot 0.0078125\right) \cdot \pi\right), -1, \cos \left(\left(n \cdot -0.0078125\right) \cdot \pi\right) \cdot 0\right)}\right) \]
  3. Taylor expanded in n around 0

    \[\leadsto \color{blue}{\frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right)} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \color{blue}{\left(k \cdot \left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \color{blue}{\left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)}\right) \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{2}}\right)\right) \]
    4. lower-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{2}\right)\right) \]
    5. lower-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right) \]
    6. lower-PI.f6498.7%

      \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right) \]
  5. Applied rewrites98.7%

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

      \[\leadsto \frac{1}{4194304} \cdot \color{blue}{\left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right)} \]
    2. *-commutativeN/A

      \[\leadsto \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right) \cdot \color{blue}{\frac{1}{4194304}} \]
    3. lift-*.f64N/A

      \[\leadsto \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right) \cdot \frac{1}{4194304} \]
    4. *-commutativeN/A

      \[\leadsto \left(\left({n}^{2} \cdot {\pi}^{2}\right) \cdot k\right) \cdot \frac{1}{4194304} \]
    5. associate-*l*N/A

      \[\leadsto \left({n}^{2} \cdot {\pi}^{2}\right) \cdot \color{blue}{\left(k \cdot \frac{1}{4194304}\right)} \]
    6. lift-*.f64N/A

      \[\leadsto \left({n}^{2} \cdot {\pi}^{2}\right) \cdot \left(\color{blue}{k} \cdot \frac{1}{4194304}\right) \]
    7. *-commutativeN/A

      \[\leadsto \left({\pi}^{2} \cdot {n}^{2}\right) \cdot \left(\color{blue}{k} \cdot \frac{1}{4194304}\right) \]
    8. lift-pow.f64N/A

      \[\leadsto \left({\pi}^{2} \cdot {n}^{2}\right) \cdot \left(k \cdot \frac{1}{4194304}\right) \]
    9. unpow2N/A

      \[\leadsto \left({\pi}^{2} \cdot \left(n \cdot n\right)\right) \cdot \left(k \cdot \frac{1}{4194304}\right) \]
    10. associate-*r*N/A

      \[\leadsto \left(\left({\pi}^{2} \cdot n\right) \cdot n\right) \cdot \left(\color{blue}{k} \cdot \frac{1}{4194304}\right) \]
    11. *-commutativeN/A

      \[\leadsto \left(\left({\pi}^{2} \cdot n\right) \cdot n\right) \cdot \left(\frac{1}{4194304} \cdot \color{blue}{k}\right) \]
    12. associate-*l*N/A

      \[\leadsto \left({\pi}^{2} \cdot n\right) \cdot \color{blue}{\left(n \cdot \left(\frac{1}{4194304} \cdot k\right)\right)} \]
    13. lower-*.f64N/A

      \[\leadsto \left({\pi}^{2} \cdot n\right) \cdot \color{blue}{\left(n \cdot \left(\frac{1}{4194304} \cdot k\right)\right)} \]
    14. lower-*.f64N/A

      \[\leadsto \left({\pi}^{2} \cdot n\right) \cdot \left(\color{blue}{n} \cdot \left(\frac{1}{4194304} \cdot k\right)\right) \]
    15. lift-pow.f64N/A

      \[\leadsto \left({\pi}^{2} \cdot n\right) \cdot \left(n \cdot \left(\frac{1}{4194304} \cdot k\right)\right) \]
    16. unpow2N/A

      \[\leadsto \left(\left(\pi \cdot \pi\right) \cdot n\right) \cdot \left(n \cdot \left(\frac{1}{4194304} \cdot k\right)\right) \]
    17. lower-*.f64N/A

      \[\leadsto \left(\left(\pi \cdot \pi\right) \cdot n\right) \cdot \left(n \cdot \left(\frac{1}{4194304} \cdot k\right)\right) \]
    18. lower-*.f64N/A

      \[\leadsto \left(\left(\pi \cdot \pi\right) \cdot n\right) \cdot \left(n \cdot \color{blue}{\left(\frac{1}{4194304} \cdot k\right)}\right) \]
    19. lower-*.f6498.7%

      \[\leadsto \left(\left(\pi \cdot \pi\right) \cdot n\right) \cdot \left(n \cdot \left(2.384185791015625 \cdot 10^{-7} \cdot \color{blue}{k}\right)\right) \]
  7. Applied rewrites98.7%

    \[\leadsto \left(\left(\pi \cdot \pi\right) \cdot n\right) \cdot \color{blue}{\left(n \cdot \left(2.384185791015625 \cdot 10^{-7} \cdot k\right)\right)} \]
  8. Add Preprocessing

Alternative 6: 98.7% accurate, 6.8× speedup?

\[2.384185791015625 \cdot 10^{-7} \cdot \left(n \cdot \left(n \cdot \left(\left(\pi \cdot \pi\right) \cdot k\right)\right)\right) \]
(FPCore (n k)
  :precision binary64
  (* 2.384185791015625e-7 (* n (* n (* (* PI PI) k)))))
double code(double n, double k) {
	return 2.384185791015625e-7 * (n * (n * ((((double) M_PI) * ((double) M_PI)) * k)));
}
public static double code(double n, double k) {
	return 2.384185791015625e-7 * (n * (n * ((Math.PI * Math.PI) * k)));
}
def code(n, k):
	return 2.384185791015625e-7 * (n * (n * ((math.pi * math.pi) * k)))
function code(n, k)
	return Float64(2.384185791015625e-7 * Float64(n * Float64(n * Float64(Float64(pi * pi) * k))))
end
function tmp = code(n, k)
	tmp = 2.384185791015625e-7 * (n * (n * ((pi * pi) * k)));
end
code[n_, k_] := N[(2.384185791015625e-7 * N[(n * N[(n * N[(N[(Pi * Pi), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
2.384185791015625 \cdot 10^{-7} \cdot \left(n \cdot \left(n \cdot \left(\left(\pi \cdot \pi\right) \cdot k\right)\right)\right)
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Applied rewrites99.8%

    \[\leadsto \frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(n \cdot 0.0078125\right) \cdot \pi\right), -1, \cos \left(\left(n \cdot -0.0078125\right) \cdot \pi\right) \cdot 0\right)}\right) \]
  3. Taylor expanded in n around 0

    \[\leadsto \color{blue}{\frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right)} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \color{blue}{\left(k \cdot \left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \color{blue}{\left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)}\right) \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{2}}\right)\right) \]
    4. lower-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{2}\right)\right) \]
    5. lower-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right) \]
    6. lower-PI.f6498.7%

      \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right) \]
  5. Applied rewrites98.7%

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

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \color{blue}{\left({n}^{2} \cdot {\pi}^{2}\right)}\right) \]
    2. *-commutativeN/A

      \[\leadsto \frac{1}{4194304} \cdot \left(\left({n}^{2} \cdot {\pi}^{2}\right) \cdot \color{blue}{k}\right) \]
    3. lift-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(\left({n}^{2} \cdot {\pi}^{2}\right) \cdot k\right) \]
    4. associate-*l*N/A

      \[\leadsto \frac{1}{4194304} \cdot \left({n}^{2} \cdot \color{blue}{\left({\pi}^{2} \cdot k\right)}\right) \]
    5. lift-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left({n}^{2} \cdot \left(\color{blue}{{\pi}^{2}} \cdot k\right)\right) \]
    6. unpow2N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(\left(n \cdot n\right) \cdot \left(\color{blue}{{\pi}^{2}} \cdot k\right)\right) \]
    7. associate-*l*N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(n \cdot \color{blue}{\left(n \cdot \left({\pi}^{2} \cdot k\right)\right)}\right) \]
    8. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(n \cdot \color{blue}{\left(n \cdot \left({\pi}^{2} \cdot k\right)\right)}\right) \]
    9. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(n \cdot \left(n \cdot \color{blue}{\left({\pi}^{2} \cdot k\right)}\right)\right) \]
    10. lower-*.f6498.7%

      \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(n \cdot \left(n \cdot \left({\pi}^{2} \cdot \color{blue}{k}\right)\right)\right) \]
    11. lift-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(n \cdot \left(n \cdot \left({\pi}^{2} \cdot k\right)\right)\right) \]
    12. unpow2N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(n \cdot \left(n \cdot \left(\left(\pi \cdot \pi\right) \cdot k\right)\right)\right) \]
    13. lower-*.f6498.7%

      \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(n \cdot \left(n \cdot \left(\left(\pi \cdot \pi\right) \cdot k\right)\right)\right) \]
  7. Applied rewrites98.7%

    \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(n \cdot \color{blue}{\left(n \cdot \left(\left(\pi \cdot \pi\right) \cdot k\right)\right)}\right) \]
  8. Add Preprocessing

Alternative 7: 98.6% accurate, 6.8× speedup?

\[2.384185791015625 \cdot 10^{-7} \cdot \left(k \cdot \left(\left(\pi \cdot n\right) \cdot \left(\pi \cdot n\right)\right)\right) \]
(FPCore (n k)
  :precision binary64
  (* 2.384185791015625e-7 (* k (* (* PI n) (* PI n)))))
double code(double n, double k) {
	return 2.384185791015625e-7 * (k * ((((double) M_PI) * n) * (((double) M_PI) * n)));
}
public static double code(double n, double k) {
	return 2.384185791015625e-7 * (k * ((Math.PI * n) * (Math.PI * n)));
}
def code(n, k):
	return 2.384185791015625e-7 * (k * ((math.pi * n) * (math.pi * n)))
function code(n, k)
	return Float64(2.384185791015625e-7 * Float64(k * Float64(Float64(pi * n) * Float64(pi * n))))
end
function tmp = code(n, k)
	tmp = 2.384185791015625e-7 * (k * ((pi * n) * (pi * n)));
end
code[n_, k_] := N[(2.384185791015625e-7 * N[(k * N[(N[(Pi * n), $MachinePrecision] * N[(Pi * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
2.384185791015625 \cdot 10^{-7} \cdot \left(k \cdot \left(\left(\pi \cdot n\right) \cdot \left(\pi \cdot n\right)\right)\right)
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Applied rewrites99.8%

    \[\leadsto \frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \color{blue}{\mathsf{fma}\left(\sin \left(\left(n \cdot 0.0078125\right) \cdot \pi\right), -1, \cos \left(\left(n \cdot -0.0078125\right) \cdot \pi\right) \cdot 0\right)}\right) \]
  3. Taylor expanded in n around 0

    \[\leadsto \color{blue}{\frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right)} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \color{blue}{\left(k \cdot \left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)\right)} \]
    2. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \color{blue}{\left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{2}\right)}\right) \]
    3. lower-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot \color{blue}{{\mathsf{PI}\left(\right)}^{2}}\right)\right) \]
    4. lower-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\color{blue}{\mathsf{PI}\left(\right)}}^{2}\right)\right) \]
    5. lower-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\mathsf{PI}\left(\right)}^{\color{blue}{2}}\right)\right) \]
    6. lower-PI.f6498.7%

      \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(k \cdot \left({n}^{2} \cdot {\pi}^{2}\right)\right) \]
  5. Applied rewrites98.7%

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

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot \color{blue}{{\pi}^{2}}\right)\right) \]
    2. lift-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\color{blue}{\pi}}^{2}\right)\right) \]
    3. lift-pow.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left({n}^{2} \cdot {\pi}^{\color{blue}{2}}\right)\right) \]
    4. pow-prod-downN/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot {\left(n \cdot \pi\right)}^{\color{blue}{2}}\right) \]
    5. *-commutativeN/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot {\left(\pi \cdot n\right)}^{2}\right) \]
    6. lift-*.f64N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot {\left(\pi \cdot n\right)}^{2}\right) \]
    7. unpow2N/A

      \[\leadsto \frac{1}{4194304} \cdot \left(k \cdot \left(\left(\pi \cdot n\right) \cdot \color{blue}{\left(\pi \cdot n\right)}\right)\right) \]
    8. lower-*.f6498.6%

      \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(k \cdot \left(\left(\pi \cdot n\right) \cdot \color{blue}{\left(\pi \cdot n\right)}\right)\right) \]
  7. Applied rewrites98.6%

    \[\leadsto 2.384185791015625 \cdot 10^{-7} \cdot \left(k \cdot \left(\left(\pi \cdot n\right) \cdot \color{blue}{\left(\pi \cdot n\right)}\right)\right) \]
  8. Add Preprocessing

Alternative 8: 75.8% accurate, 108.2× speedup?

\[0 \]
(FPCore (n k)
  :precision binary64
  0.0)
double code(double n, double k) {
	return 0.0;
}
real(8) function code(n, k)
    real(8), intent (in) :: n
    real(8), intent (in) :: k
    code = 0.0d0
end function
public static double code(double n, double k) {
	return 0.0;
}
def code(n, k):
	return 0.0
function code(n, k)
	return 0.0
end
function tmp = code(n, k)
	tmp = 0.0;
end
code[n_, k_] := 0.0
0
Derivation
  1. Initial program 59.5%

    \[\frac{1}{256} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{256}\right)\right)\right) \cdot \left(-\sin \left(\frac{n}{256} \cdot \left(2 \cdot \pi\right) + 2 \cdot \pi\right)\right)\right) \]
  2. Taylor expanded in n around 0

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{32768} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(2 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) \]
    8. lower-PI.f6456.6%

      \[\leadsto 3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)\right)\right) \]
  4. Applied rewrites56.6%

    \[\leadsto \color{blue}{3.0517578125 \cdot 10^{-5} \cdot \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)\right)\right)} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

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

      \[\leadsto \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)\right)\right) \cdot \color{blue}{\frac{1}{32768}} \]
    3. lift-*.f64N/A

      \[\leadsto \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)\right)\right) \cdot \frac{1}{32768} \]
    4. lift-*.f64N/A

      \[\leadsto \left(k \cdot \left(n \cdot \left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)\right)\right) \cdot \frac{1}{32768} \]
    5. associate-*r*N/A

      \[\leadsto \left(\left(k \cdot n\right) \cdot \left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)\right) \cdot \frac{1}{32768} \]
    6. lift-*.f64N/A

      \[\leadsto \left(\left(k \cdot n\right) \cdot \left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)\right) \cdot \frac{1}{32768} \]
    7. associate-*l*N/A

      \[\leadsto \left(k \cdot n\right) \cdot \color{blue}{\left(\left(\pi \cdot \sin \left(2 \cdot \pi\right)\right) \cdot \frac{1}{32768}\right)} \]
    8. lift-*.f64N/A

      \[\leadsto \left(k \cdot n\right) \cdot \left(\color{blue}{\left(\pi \cdot \sin \left(2 \cdot \pi\right)\right)} \cdot \frac{1}{32768}\right) \]
  6. Applied rewrites75.8%

    \[\leadsto \color{blue}{\left(0 \cdot n\right) \cdot k} \]
  7. Applied rewrites75.8%

    \[\leadsto \color{blue}{0} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore (n k)
  :name "1/256 sin(-2 PI n k / 256) (-sin(n/256 (2 PI) + 2 PI))"
  :precision binary64
  :pre (and (and (<= 0.0 n) (<= n 256.0)) (and (<= 0.0 k) (<= k 256.0)))
  (* (/ 1.0 256.0) (* (sin (* (- 2.0) (* PI (* n (/ k 256.0))))) (- (sin (+ (* (/ n 256.0) (* 2.0 PI)) (* 2.0 PI)))))))