(FPCore (x) :precision binary64 (- (* (+ 35000000.0 (* (* 0.401 (/ 1000.0 x)) (/ 1000.0 x))) (- x (* 1000.0 4.27e-5))) (* (* 1.3806503e-23 1000.0) 300.0)))
double code(double x) { return ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0); }
real(8) function code(x) real(8), intent (in) :: x code = ((35000000.0d0 + ((0.401d0 * (1000.0d0 / x)) * (1000.0d0 / x))) * (x - (1000.0d0 * 4.27d-5))) - ((1.3806503d-23 * 1000.0d0) * 300.0d0) end function
public static double code(double x) { return ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0); }
def code(x): return ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0)
function code(x) return Float64(Float64(Float64(35000000.0 + Float64(Float64(0.401 * Float64(1000.0 / x)) * Float64(1000.0 / x))) * Float64(x - Float64(1000.0 * 4.27e-5))) - Float64(Float64(1.3806503e-23 * 1000.0) * 300.0)) end
function tmp = code(x) tmp = ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0); end
code[x_] := N[(N[(N[(35000000.0 + N[(N[(0.401 * N[(1000.0 / x), $MachinePrecision]), $MachinePrecision] * N[(1000.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x - N[(1000.0 * 4.27e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(1.3806503e-23 * 1000.0), $MachinePrecision] * 300.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \left(35000000 + \left(0.401 \cdot \frac{1000}{x}\right) \cdot \frac{1000}{x}\right) \cdot \left(x - 1000 \cdot 4.27 \cdot 10^{-5}\right) - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (- (* (+ 35000000.0 (* (* 0.401 (/ 1000.0 x)) (/ 1000.0 x))) (- x (* 1000.0 4.27e-5))) (* (* 1.3806503e-23 1000.0) 300.0)))
double code(double x) { return ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0); }
real(8) function code(x) real(8), intent (in) :: x code = ((35000000.0d0 + ((0.401d0 * (1000.0d0 / x)) * (1000.0d0 / x))) * (x - (1000.0d0 * 4.27d-5))) - ((1.3806503d-23 * 1000.0d0) * 300.0d0) end function
public static double code(double x) { return ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0); }
def code(x): return ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0)
function code(x) return Float64(Float64(Float64(35000000.0 + Float64(Float64(0.401 * Float64(1000.0 / x)) * Float64(1000.0 / x))) * Float64(x - Float64(1000.0 * 4.27e-5))) - Float64(Float64(1.3806503e-23 * 1000.0) * 300.0)) end
function tmp = code(x) tmp = ((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0); end
code[x_] := N[(N[(N[(35000000.0 + N[(N[(0.401 * N[(1000.0 / x), $MachinePrecision]), $MachinePrecision] * N[(1000.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x - N[(1000.0 * 4.27e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(1.3806503e-23 * 1000.0), $MachinePrecision] * 300.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \left(35000000 + \left(0.401 \cdot \frac{1000}{x}\right) \cdot \frac{1000}{x}\right) \cdot \left(x - 1000 \cdot 4.27 \cdot 10^{-5}\right) - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \end{array}
(FPCore (x) :precision binary64 (- (fma x 35000000.0 (- -1494500.0 (/ (- (/ 17122.7 x) 401000.0) x))) 4.1419509000000004e-18))
double code(double x) { return fma(x, 35000000.0, (-1494500.0 - (((17122.7 / x) - 401000.0) / x))) - 4.1419509000000004e-18; }
function code(x) return Float64(fma(x, 35000000.0, Float64(-1494500.0 - Float64(Float64(Float64(17122.7 / x) - 401000.0) / x))) - 4.1419509000000004e-18) end
code[x_] := N[(N[(x * 35000000.0 + N[(-1494500.0 - N[(N[(N[(17122.7 / x), $MachinePrecision] - 401000.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.1419509000000004e-18), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(x, 35000000, -1494500 - \frac{\frac{17122.7}{x} - 401000}{x}\right) - 4.1419509000000004 \cdot 10^{-18} \end{array}
Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.8%
lift-*.f64
N/A
lift-*.f64
N/A
metadata-eval
N/A
metadata-eval
N/A
Applied rewrites99.8%
(FPCore (x) :precision binary64 (/ (- (fma (fma 35000000.0 x -1494500.0) x 401000.0) (/ 17122.7 x)) x))
double code(double x) { return (fma(fma(35000000.0, x, -1494500.0), x, 401000.0) - (17122.7 / x)) / x; }
function code(x) return Float64(Float64(fma(fma(35000000.0, x, -1494500.0), x, 401000.0) - Float64(17122.7 / x)) / x) end
code[x_] := N[(N[(N[(N[(35000000.0 * x + -1494500.0), $MachinePrecision] * x + 401000.0), $MachinePrecision] - N[(17122.7 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{fma}\left(\mathsf{fma}\left(35000000, x, -1494500\right), x, 401000\right) - \frac{17122.7}{x}}{x} \end{array}
Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.8%
Taylor expanded in x around 0
unpow2
N/A
associate-/r*
N/A
lower-/.f64
N/A
Applied rewrites99.4%
(FPCore (x) :precision binary64 (- (* (+ 35000000.0 (/ 401000.0 (* x x))) (- x (* 1000.0 4.27e-5))) 4.1419509000000004e-18))
double code(double x) { return ((35000000.0 + (401000.0 / (x * x))) * (x - (1000.0 * 4.27e-5))) - 4.1419509000000004e-18; }
real(8) function code(x) real(8), intent (in) :: x code = ((35000000.0d0 + (401000.0d0 / (x * x))) * (x - (1000.0d0 * 4.27d-5))) - 4.1419509000000004d-18 end function
public static double code(double x) { return ((35000000.0 + (401000.0 / (x * x))) * (x - (1000.0 * 4.27e-5))) - 4.1419509000000004e-18; }
def code(x): return ((35000000.0 + (401000.0 / (x * x))) * (x - (1000.0 * 4.27e-5))) - 4.1419509000000004e-18
function code(x) return Float64(Float64(Float64(35000000.0 + Float64(401000.0 / Float64(x * x))) * Float64(x - Float64(1000.0 * 4.27e-5))) - 4.1419509000000004e-18) end
function tmp = code(x) tmp = ((35000000.0 + (401000.0 / (x * x))) * (x - (1000.0 * 4.27e-5))) - 4.1419509000000004e-18; end
code[x_] := N[(N[(N[(35000000.0 + N[(401000.0 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x - N[(1000.0 * 4.27e-5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 4.1419509000000004e-18), $MachinePrecision]
\begin{array}{l} \\ \left(35000000 + \frac{401000}{x \cdot x}\right) \cdot \left(x - 1000 \cdot 4.27 \cdot 10^{-5}\right) - 4.1419509000000004 \cdot 10^{-18} \end{array}
Initial program 99.3%
lift-*.f64
N/A
*-commutative
N/A
lift-/.f64
N/A
lift-*.f64
N/A
lift-/.f64
N/A
associate-*r/
N/A
frac-times
N/A
lower-/.f64
N/A
metadata-eval
N/A
metadata-eval
N/A
lower-*.f64
99.3
Applied rewrites99.3%
lift-*.f64
N/A
lift-*.f64
N/A
metadata-eval
N/A
metadata-eval
99.3
Applied rewrites99.3%
(FPCore (x) :precision binary64 (fma 35000000.0 x (- (/ 401000.0 x) 1494500.0)))
double code(double x) { return fma(35000000.0, x, ((401000.0 / x) - 1494500.0)); }
function code(x) return fma(35000000.0, x, Float64(Float64(401000.0 / x) - 1494500.0)) end
code[x_] := N[(35000000.0 * x + N[(N[(401000.0 / x), $MachinePrecision] - 1494500.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(35000000, x, \frac{401000}{x} - 1494500\right) \end{array}
Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.8%
Taylor expanded in x around inf
associate--l+
N/A
distribute-rgt-in
N/A
lower-fma.f64
N/A
*-commutative
N/A
sub-neg
N/A
distribute-rgt-in
N/A
*-commutative
N/A
associate-/l*
N/A
*-commutative
N/A
associate-/l*
N/A
unpow2
N/A
associate-/r*
N/A
*-inverses
N/A
distribute-lft-neg-out
N/A
associate-*l*
N/A
lft-mult-inverse
N/A
metadata-eval
N/A
sub-neg
N/A
lower--.f64
N/A
Applied rewrites25.3%
(FPCore (x) :precision binary64 (- (* x 35000000.0) 4.1419509000000004e-18))
double code(double x) { return (x * 35000000.0) - 4.1419509000000004e-18; }
real(8) function code(x) real(8), intent (in) :: x code = (x * 35000000.0d0) - 4.1419509000000004d-18 end function
public static double code(double x) { return (x * 35000000.0) - 4.1419509000000004e-18; }
def code(x): return (x * 35000000.0) - 4.1419509000000004e-18
function code(x) return Float64(Float64(x * 35000000.0) - 4.1419509000000004e-18) end
function tmp = code(x) tmp = (x * 35000000.0) - 4.1419509000000004e-18; end
code[x_] := N[(N[(x * 35000000.0), $MachinePrecision] - 4.1419509000000004e-18), $MachinePrecision]
\begin{array}{l} \\ x \cdot 35000000 - 4.1419509000000004 \cdot 10^{-18} \end{array}
Initial program 99.3%
Taylor expanded in x around inf
lower-*.f64
25.3
Applied rewrites25.3%
lift-*.f64
N/A
lift-*.f64
N/A
metadata-eval
N/A
metadata-eval
N/A
Applied rewrites25.3%
(FPCore (x) :precision binary64 (fma 35000000.0 x -1494500.0))
double code(double x) { return fma(35000000.0, x, -1494500.0); }
function code(x) return fma(35000000.0, x, -1494500.0) end
code[x_] := N[(35000000.0 * x + -1494500.0), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(35000000, x, -1494500\right) \end{array}
Initial program 99.3%
Taylor expanded in x around inf
Applied rewrites99.8%
Taylor expanded in x around inf
sub-neg
N/A
distribute-rgt-in
N/A
distribute-lft-neg-in
N/A
metadata-eval
N/A
associate-*l*
N/A
lft-mult-inverse
N/A
metadata-eval
N/A
lower-fma.f64
21.6
Applied rewrites21.6%
herbie shell --seed 1
(FPCore (x)
:name "((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0)"
:precision binary64
:pre (and (<= 0.1 x) (<= x 0.5))
(- (* (+ 35000000.0 (* (* 0.401 (/ 1000.0 x)) (/ 1000.0 x))) (- x (* 1000.0 4.27e-5))) (* (* 1.3806503e-23 1000.0) 300.0)))