(FPCore (n k t) :precision binary64 (* (/ 1.0 4096.0) (* (sin (* (- 2.0) (* PI (* n (/ k 4096.0))))) (* t (/ n 4096.0)))))
double code(double n, double k, double t) { return (1.0 / 4096.0) * (sin((-2.0 * (((double) M_PI) * (n * (k / 4096.0))))) * (t * (n / 4096.0))); }
public static double code(double n, double k, double t) { return (1.0 / 4096.0) * (Math.sin((-2.0 * (Math.PI * (n * (k / 4096.0))))) * (t * (n / 4096.0))); }
def code(n, k, t): return (1.0 / 4096.0) * (math.sin((-2.0 * (math.pi * (n * (k / 4096.0))))) * (t * (n / 4096.0)))
function code(n, k, t) return Float64(Float64(1.0 / 4096.0) * Float64(sin(Float64(Float64(-2.0) * Float64(pi * Float64(n * Float64(k / 4096.0))))) * Float64(t * Float64(n / 4096.0)))) end
function tmp = code(n, k, t) tmp = (1.0 / 4096.0) * (sin((-2.0 * (pi * (n * (k / 4096.0))))) * (t * (n / 4096.0))); end
code[n_, k_, t_] := N[(N[(1.0 / 4096.0), $MachinePrecision] * N[(N[Sin[N[((-2.0) * N[(Pi * N[(n * N[(k / 4096.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t * N[(n / 4096.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{4096} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{4096}\right)\right)\right) \cdot \left(t \cdot \frac{n}{4096}\right)\right)
Herbie found 4 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (n k t) :precision binary64 (* (/ 1.0 4096.0) (* (sin (* (- 2.0) (* PI (* n (/ k 4096.0))))) (* t (/ n 4096.0)))))
double code(double n, double k, double t) { return (1.0 / 4096.0) * (sin((-2.0 * (((double) M_PI) * (n * (k / 4096.0))))) * (t * (n / 4096.0))); }
public static double code(double n, double k, double t) { return (1.0 / 4096.0) * (Math.sin((-2.0 * (Math.PI * (n * (k / 4096.0))))) * (t * (n / 4096.0))); }
def code(n, k, t): return (1.0 / 4096.0) * (math.sin((-2.0 * (math.pi * (n * (k / 4096.0))))) * (t * (n / 4096.0)))
function code(n, k, t) return Float64(Float64(1.0 / 4096.0) * Float64(sin(Float64(Float64(-2.0) * Float64(pi * Float64(n * Float64(k / 4096.0))))) * Float64(t * Float64(n / 4096.0)))) end
function tmp = code(n, k, t) tmp = (1.0 / 4096.0) * (sin((-2.0 * (pi * (n * (k / 4096.0))))) * (t * (n / 4096.0))); end
code[n_, k_, t_] := N[(N[(1.0 / 4096.0), $MachinePrecision] * N[(N[Sin[N[((-2.0) * N[(Pi * N[(n * N[(k / 4096.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(t * N[(n / 4096.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{4096} \cdot \left(\sin \left(\left(-2\right) \cdot \left(\pi \cdot \left(n \cdot \frac{k}{4096}\right)\right)\right) \cdot \left(t \cdot \frac{n}{4096}\right)\right)
(FPCore (n k t) :precision binary64 (* (* (* (* PI t) k) -2.9103830456733704e-11) (* n n)))
double code(double n, double k, double t) { return (((((double) M_PI) * t) * k) * -2.9103830456733704e-11) * (n * n); }
public static double code(double n, double k, double t) { return (((Math.PI * t) * k) * -2.9103830456733704e-11) * (n * n); }
def code(n, k, t): return (((math.pi * t) * k) * -2.9103830456733704e-11) * (n * n)
function code(n, k, t) return Float64(Float64(Float64(Float64(pi * t) * k) * -2.9103830456733704e-11) * Float64(n * n)) end
function tmp = code(n, k, t) tmp = (((pi * t) * k) * -2.9103830456733704e-11) * (n * n); end
code[n_, k_, t_] := N[(N[(N[(N[(Pi * t), $MachinePrecision] * k), $MachinePrecision] * -2.9103830456733704e-11), $MachinePrecision] * N[(n * n), $MachinePrecision]), $MachinePrecision]
\left(\left(\left(\pi \cdot t\right) \cdot k\right) \cdot -2.9103830456733704 \cdot 10^{-11}\right) \cdot \left(n \cdot n\right)
Initial program 99.8%
Taylor expanded in n around 0
lower-*.f64
N/A
lower-*.f64
N/A
lower-*.f64
N/A
lower-pow.f64
N/A
lower-*.f64
N/A
lower-PI.f64
99.8%
Applied rewrites99.8%
lift-*.f64
N/A
lift-*.f64
N/A
lift-*.f64
N/A
*-commutative
N/A
associate-*r*
N/A
lift-*.f64
N/A
associate-*l*
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.8%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.8%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.8%
lift-pow.f64
N/A
unpow2
N/A
lower-*.f64
99.8%
Applied rewrites99.8%
(FPCore (n k t) :precision binary64 (* (* (* (* PI k) t) -2.9103830456733704e-11) (* n n)))
double code(double n, double k, double t) { return (((((double) M_PI) * k) * t) * -2.9103830456733704e-11) * (n * n); }
public static double code(double n, double k, double t) { return (((Math.PI * k) * t) * -2.9103830456733704e-11) * (n * n); }
def code(n, k, t): return (((math.pi * k) * t) * -2.9103830456733704e-11) * (n * n)
function code(n, k, t) return Float64(Float64(Float64(Float64(pi * k) * t) * -2.9103830456733704e-11) * Float64(n * n)) end
function tmp = code(n, k, t) tmp = (((pi * k) * t) * -2.9103830456733704e-11) * (n * n); end
code[n_, k_, t_] := N[(N[(N[(N[(Pi * k), $MachinePrecision] * t), $MachinePrecision] * -2.9103830456733704e-11), $MachinePrecision] * N[(n * n), $MachinePrecision]), $MachinePrecision]
\left(\left(\left(\pi \cdot k\right) \cdot t\right) \cdot -2.9103830456733704 \cdot 10^{-11}\right) \cdot \left(n \cdot n\right)
Initial program 99.8%
Taylor expanded in n around 0
lower-*.f64
N/A
lower-*.f64
N/A
lower-*.f64
N/A
lower-pow.f64
N/A
lower-*.f64
N/A
lower-PI.f64
99.8%
Applied rewrites99.8%
lift-*.f64
N/A
lift-*.f64
N/A
lift-*.f64
N/A
*-commutative
N/A
associate-*r*
N/A
lift-*.f64
N/A
associate-*l*
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.8%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.8%
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.8%
lift-pow.f64
N/A
unpow2
N/A
lower-*.f64
99.8%
Applied rewrites99.8%
lift-*.f64
N/A
*-commutative
N/A
lift-*.f64
N/A
associate-*r*
N/A
*-commutative
N/A
lift-*.f64
N/A
lower-*.f64
99.8%
Applied rewrites99.8%
(FPCore (n k t) :precision binary64 (* -2.9103830456733704e-11 (* (* (* (* k n) n) t) PI)))
double code(double n, double k, double t) { return -2.9103830456733704e-11 * ((((k * n) * n) * t) * ((double) M_PI)); }
public static double code(double n, double k, double t) { return -2.9103830456733704e-11 * ((((k * n) * n) * t) * Math.PI); }
def code(n, k, t): return -2.9103830456733704e-11 * ((((k * n) * n) * t) * math.pi)
function code(n, k, t) return Float64(-2.9103830456733704e-11 * Float64(Float64(Float64(Float64(k * n) * n) * t) * pi)) end
function tmp = code(n, k, t) tmp = -2.9103830456733704e-11 * ((((k * n) * n) * t) * pi); end
code[n_, k_, t_] := N[(-2.9103830456733704e-11 * N[(N[(N[(N[(k * n), $MachinePrecision] * n), $MachinePrecision] * t), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]
-2.9103830456733704 \cdot 10^{-11} \cdot \left(\left(\left(\left(k \cdot n\right) \cdot n\right) \cdot t\right) \cdot \pi\right)
Initial program 99.8%
Taylor expanded in n around 0
lower-*.f64
N/A
lower-*.f64
N/A
lower-*.f64
N/A
lower-pow.f64
N/A
lower-*.f64
N/A
lower-PI.f64
99.8%
Applied rewrites99.8%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*r*
N/A
lift-*.f64
N/A
associate-*r*
N/A
lower-*.f64
N/A
lower-*.f64
N/A
lift-pow.f64
N/A
unpow2
N/A
associate-*r*
N/A
lift-*.f64
N/A
lower-*.f64
99.8%
Applied rewrites99.8%
(FPCore (n k t) :precision binary64 (* -2.9103830456733704e-11 (* k (* (* (* n n) t) PI))))
double code(double n, double k, double t) { return -2.9103830456733704e-11 * (k * (((n * n) * t) * ((double) M_PI))); }
public static double code(double n, double k, double t) { return -2.9103830456733704e-11 * (k * (((n * n) * t) * Math.PI)); }
def code(n, k, t): return -2.9103830456733704e-11 * (k * (((n * n) * t) * math.pi))
function code(n, k, t) return Float64(-2.9103830456733704e-11 * Float64(k * Float64(Float64(Float64(n * n) * t) * pi))) end
function tmp = code(n, k, t) tmp = -2.9103830456733704e-11 * (k * (((n * n) * t) * pi)); end
code[n_, k_, t_] := N[(-2.9103830456733704e-11 * N[(k * N[(N[(N[(n * n), $MachinePrecision] * t), $MachinePrecision] * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
-2.9103830456733704 \cdot 10^{-11} \cdot \left(k \cdot \left(\left(\left(n \cdot n\right) \cdot t\right) \cdot \pi\right)\right)
Initial program 99.8%
Taylor expanded in n around 0
lower-*.f64
N/A
lower-*.f64
N/A
lower-*.f64
N/A
lower-pow.f64
N/A
lower-*.f64
N/A
lower-PI.f64
99.8%
Applied rewrites99.8%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*r*
N/A
lower-*.f64
N/A
lower-*.f64
99.8%
lift-pow.f64
N/A
unpow2
N/A
lower-*.f64
99.8%
Applied rewrites99.8%
herbie shell --seed 1
(FPCore (n k t)
:name "1/4096 sin(-2 PI n k / 4096) t n/4096"
:precision binary64
:pre (and (and (and (<= 0.0 n) (<= n 4096.0)) (and (<= 0.0 k) (<= k 4096.0))) (and (<= 6.28318530718 t) (<= t 12.5663706144)))
(* (/ 1.0 4096.0) (* (sin (* (- 2.0) (* PI (* n (/ k 4096.0))))) (* t (/ n 4096.0)))))