((35000000.0 + ((0.401 * (1000.0 / x)) * (1000.0 / x))) * (x - (1000.0 * 4.27e-5))) - ((1.3806503e-23 * 1000.0) * 300.0)

Percentage Accurate: 99.3% → 99.9%
Time: 5.1s
Alternatives: 6
Speedup: 1.7×

Specification

?
\[0.1 \leq x \land x \leq 0.5\]
\[\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
 (-
  (*
   (+ 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:

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 6 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: 99.3% accurate, 1.0× speedup?

\[\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
 (-
  (*
   (+ 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}

Alternative 1: 99.9% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(x, 35000000, -1494500 - \frac{\frac{17122.7}{x} - 401000}{x}\right) - 4.1419509000000004 \cdot 10^{-18} \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}
Derivation
  1. Initial program 99.3%

    \[\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 \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x \cdot \left(\left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}}\right) - \left(\frac{430760297158733212890625}{288230376151711744} \cdot \frac{1}{x} + \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024} \cdot \frac{1}{{x}^{3}}\right)\right)} - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, -1494500 - \frac{\frac{17122.7}{x} - 401000}{x}\right)} - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-fma.f64, \left(\mathsf{fma}\left(x, 35000000, \frac{-430760297158733212890625}{288230376151711744} - \frac{\frac{\frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{x} - \frac{28217866415243265625}{70368744177664}}{x}\right)\right)\right) - \color{blue}{\left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-fma.f64, \left(\mathsf{fma}\left(x, 35000000, \frac{-430760297158733212890625}{288230376151711744} - \frac{\frac{\frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{x} - \frac{28217866415243265625}{70368744177664}}{x}\right)\right)\right) - \color{blue}{\left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right)} \cdot 300 \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-fma.f64, \left(\mathsf{fma}\left(x, 35000000, \frac{-430760297158733212890625}{288230376151711744} - \frac{\frac{\frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{x} - \frac{28217866415243265625}{70368744177664}}{x}\right)\right)\right) - \color{blue}{\frac{293631844983814875}{21267647932558653966460912964485513216}} \cdot 300 \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-fma.f64, \left(\mathsf{fma}\left(x, 35000000, \frac{-430760297158733212890625}{288230376151711744} - \frac{\frac{\frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{x} - \frac{28217866415243265625}{70368744177664}}{x}\right)\right)\right) - \color{blue}{\frac{22022388373786115625}{5316911983139663491615228241121378304}} \]
  6. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 35000000, -1494500 - \frac{\frac{17122.7}{x} - 401000}{x}\right) - 4.1419509000000004 \cdot 10^{-18}} \]
  7. Add Preprocessing

Alternative 2: 99.4% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(\mathsf{fma}\left(35000000, x, -1494500\right), x, 401000\right) - \frac{17122.7}{x}}{x} \end{array} \]
(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}
Derivation
  1. Initial program 99.3%

    \[\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 \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x \cdot \left(\left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}}\right) - \left(\frac{430760297158733212890625}{288230376151711744} \cdot \frac{1}{x} + \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024} \cdot \frac{1}{{x}^{3}}\right)\right)} - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, -1494500 - \frac{\frac{17122.7}{x} - 401000}{x}\right)} - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{\frac{x \cdot \left(\frac{28217866415243265625}{70368744177664} + x \cdot \left(35000000 \cdot x - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}\right)\right) - \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{{x}^{2}}} \]
  6. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \frac{x \cdot \left(\frac{28217866415243265625}{70368744177664} + x \cdot \left(35000000 \cdot x - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}\right)\right) - \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{\color{blue}{x \cdot x}} \]
    2. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{x \cdot \left(\frac{28217866415243265625}{70368744177664} + x \cdot \left(35000000 \cdot x - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}\right)\right) - \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{x}}{x}} \]
    3. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\frac{x \cdot \left(\frac{28217866415243265625}{70368744177664} + x \cdot \left(35000000 \cdot x - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}\right)\right) - \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024}}{x}}{x}} \]
  7. Applied rewrites99.4%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(35000000, x, -1494500\right), x, 401000\right) - \frac{17122.7}{x}}{x}} \]
  8. Add Preprocessing

Alternative 3: 99.3% accurate, 1.7× speedup?

\[\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} \]
(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}
Derivation
  1. Initial program 99.3%

    \[\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 \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left(35000000 + \color{blue}{\left(\frac{1805943450575569}{4503599627370496} \cdot \frac{1000}{x}\right) \cdot \frac{1000}{x}}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    2. *-commutativeN/A

      \[\leadsto \left(35000000 + \color{blue}{\frac{1000}{x} \cdot \left(\frac{1805943450575569}{4503599627370496} \cdot \frac{1000}{x}\right)}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    3. lift-/.f64N/A

      \[\leadsto \left(35000000 + \color{blue}{\frac{1000}{x}} \cdot \left(\frac{1805943450575569}{4503599627370496} \cdot \frac{1000}{x}\right)\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    4. lift-*.f64N/A

      \[\leadsto \left(35000000 + \frac{1000}{x} \cdot \color{blue}{\left(\frac{1805943450575569}{4503599627370496} \cdot \frac{1000}{x}\right)}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    5. lift-/.f64N/A

      \[\leadsto \left(35000000 + \frac{1000}{x} \cdot \left(\frac{1805943450575569}{4503599627370496} \cdot \color{blue}{\frac{1000}{x}}\right)\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    6. associate-*r/N/A

      \[\leadsto \left(35000000 + \frac{1000}{x} \cdot \color{blue}{\frac{\frac{1805943450575569}{4503599627370496} \cdot 1000}{x}}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    7. frac-timesN/A

      \[\leadsto \left(35000000 + \color{blue}{\frac{1000 \cdot \left(\frac{1805943450575569}{4503599627370496} \cdot 1000\right)}{x \cdot x}}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    8. lower-/.f64N/A

      \[\leadsto \left(35000000 + \color{blue}{\frac{1000 \cdot \left(\frac{1805943450575569}{4503599627370496} \cdot 1000\right)}{x \cdot x}}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    9. metadata-evalN/A

      \[\leadsto \left(35000000 + \frac{1000 \cdot \color{blue}{\frac{225742931321946125}{562949953421312}}}{x \cdot x}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    10. metadata-evalN/A

      \[\leadsto \left(35000000 + \frac{\color{blue}{\frac{28217866415243265625}{70368744177664}}}{x \cdot x}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
    11. lower-*.f6499.3

      \[\leadsto \left(35000000 + \frac{401000}{\color{blue}{x \cdot x}}\right) \cdot \left(x - 1000 \cdot 4.27 \cdot 10^{-5}\right) - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  4. Applied rewrites99.3%

    \[\leadsto \left(35000000 + \color{blue}{\frac{401000}{x \cdot x}}\right) \cdot \left(x - 1000 \cdot 4.27 \cdot 10^{-5}\right) - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{x \cdot x}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \color{blue}{\left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300} \]
    2. lift-*.f64N/A

      \[\leadsto \left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{x \cdot x}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \color{blue}{\left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right)} \cdot 300 \]
    3. metadata-evalN/A

      \[\leadsto \left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{x \cdot x}\right) \cdot \left(x - 1000 \cdot \frac{6301407775579183}{147573952589676412928}\right) - \color{blue}{\frac{293631844983814875}{21267647932558653966460912964485513216}} \cdot 300 \]
    4. metadata-eval99.3

      \[\leadsto \left(35000000 + \frac{401000}{x \cdot x}\right) \cdot \left(x - 1000 \cdot 4.27 \cdot 10^{-5}\right) - \color{blue}{4.1419509000000004 \cdot 10^{-18}} \]
  6. Applied rewrites99.3%

    \[\leadsto \left(35000000 + \frac{401000}{x \cdot x}\right) \cdot \left(x - 1000 \cdot 4.27 \cdot 10^{-5}\right) - \color{blue}{4.1419509000000004 \cdot 10^{-18}} \]
  7. Add Preprocessing

Alternative 4: 25.2% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(35000000, x, \frac{401000}{x} - 1494500\right) \end{array} \]
(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}
Derivation
  1. Initial program 99.3%

    \[\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 \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x \cdot \left(\left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}}\right) - \left(\frac{430760297158733212890625}{288230376151711744} \cdot \frac{1}{x} + \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024} \cdot \frac{1}{{x}^{3}}\right)\right)} - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, -1494500 - \frac{\frac{17122.7}{x} - 401000}{x}\right)} - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x \cdot \left(\left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}}\right) - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)} \]
  6. Step-by-step derivation
    1. associate--l+N/A

      \[\leadsto x \cdot \color{blue}{\left(35000000 + \left(\frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}} - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right)} \]
    2. distribute-rgt-inN/A

      \[\leadsto \color{blue}{35000000 \cdot x + \left(\frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}} - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right) \cdot x} \]
    3. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, \left(\frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}} - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right) \cdot x\right)} \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \color{blue}{x \cdot \left(\frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}} - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)}\right) \]
    5. sub-negN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, x \cdot \color{blue}{\left(\frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right)\right)}\right) \]
    6. distribute-rgt-inN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \color{blue}{\frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}} \cdot x + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x}\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \color{blue}{x \cdot \frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}}} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x\right) \]
    8. associate-/l*N/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \color{blue}{\frac{x \cdot \frac{28217866415243265625}{70368744177664}}{{x}^{2}}} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x\right) \]
    9. *-commutativeN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{\color{blue}{\frac{28217866415243265625}{70368744177664} \cdot x}}{{x}^{2}} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x\right) \]
    10. associate-/l*N/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \color{blue}{\frac{28217866415243265625}{70368744177664} \cdot \frac{x}{{x}^{2}}} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x\right) \]
    11. unpow2N/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{28217866415243265625}{70368744177664} \cdot \frac{x}{\color{blue}{x \cdot x}} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x\right) \]
    12. associate-/r*N/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{28217866415243265625}{70368744177664} \cdot \color{blue}{\frac{\frac{x}{x}}{x}} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x\right) \]
    13. *-inversesN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{28217866415243265625}{70368744177664} \cdot \frac{\color{blue}{1}}{x} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x\right) \]
    14. distribute-lft-neg-outN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{28217866415243265625}{70368744177664} \cdot \frac{1}{x} + \color{blue}{\left(\mathsf{neg}\left(\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right) \cdot x\right)\right)}\right) \]
    15. associate-*l*N/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{28217866415243265625}{70368744177664} \cdot \frac{1}{x} + \left(\mathsf{neg}\left(\color{blue}{\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \left(\frac{1}{x} \cdot x\right)}\right)\right)\right) \]
    16. lft-mult-inverseN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{28217866415243265625}{70368744177664} \cdot \frac{1}{x} + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \color{blue}{1}\right)\right)\right) \]
    17. metadata-evalN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \frac{28217866415243265625}{70368744177664} \cdot \frac{1}{x} + \left(\mathsf{neg}\left(\color{blue}{\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}}\right)\right)\right) \]
    18. sub-negN/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \color{blue}{\frac{28217866415243265625}{70368744177664} \cdot \frac{1}{x} - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}}\right) \]
    19. lower--.f64N/A

      \[\leadsto \mathsf{fma}\left(35000000, x, \color{blue}{\frac{28217866415243265625}{70368744177664} \cdot \frac{1}{x} - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}}\right) \]
  7. Applied rewrites25.3%

    \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, \frac{401000}{x} - 1494500\right)} \]
  8. Add Preprocessing

Alternative 5: 25.2% accurate, 6.9× speedup?

\[\begin{array}{l} \\ x \cdot 35000000 - 4.1419509000000004 \cdot 10^{-18} \end{array} \]
(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}
Derivation
  1. Initial program 99.3%

    \[\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 \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{35000000 \cdot x} - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
  4. Step-by-step derivation
    1. lower-*.f6425.3

      \[\leadsto \color{blue}{35000000 \cdot x} - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  5. Applied rewrites25.3%

    \[\leadsto \color{blue}{35000000 \cdot x} - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-*.f64, \left(x \cdot 35000000\right)\right) - \color{blue}{\left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300} \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-*.f64, \left(x \cdot 35000000\right)\right) - \color{blue}{\left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right)} \cdot 300 \]
    3. metadata-evalN/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-*.f64, \left(x \cdot 35000000\right)\right) - \color{blue}{\frac{293631844983814875}{21267647932558653966460912964485513216}} \cdot 300 \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{Rewrite=>}\left(lower-*.f64, \left(x \cdot 35000000\right)\right) - \color{blue}{\frac{22022388373786115625}{5316911983139663491615228241121378304}} \]
  7. Applied rewrites25.3%

    \[\leadsto \color{blue}{x \cdot 35000000 - 4.1419509000000004 \cdot 10^{-18}} \]
  8. Add Preprocessing

Alternative 6: 21.6% accurate, 8.9× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(35000000, x, -1494500\right) \end{array} \]
(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}
Derivation
  1. Initial program 99.3%

    \[\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 \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x \cdot \left(\left(35000000 + \frac{\frac{28217866415243265625}{70368744177664}}{{x}^{2}}\right) - \left(\frac{430760297158733212890625}{288230376151711744} \cdot \frac{1}{x} + \frac{22226535354908575131218134336185546875}{1298074214633706907132624082305024} \cdot \frac{1}{{x}^{3}}\right)\right)} - \left(\frac{2349054759870519}{170141183460469231731687303715884105728} \cdot 1000\right) \cdot 300 \]
  4. Applied rewrites99.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, -1494500 - \frac{\frac{17122.7}{x} - 401000}{x}\right)} - \left(1.3806503 \cdot 10^{-23} \cdot 1000\right) \cdot 300 \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{x \cdot \left(35000000 - \frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)} \]
  6. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto x \cdot \color{blue}{\left(35000000 + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right)\right)} \]
    2. distribute-rgt-inN/A

      \[\leadsto \color{blue}{35000000 \cdot x + \left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \frac{1}{x}\right)\right) \cdot x} \]
    3. distribute-lft-neg-inN/A

      \[\leadsto 35000000 \cdot x + \color{blue}{\left(\left(\mathsf{neg}\left(\frac{7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}\right)\right) \cdot \frac{1}{x}\right)} \cdot x \]
    4. metadata-evalN/A

      \[\leadsto 35000000 \cdot x + \left(\color{blue}{\frac{-7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}} \cdot \frac{1}{x}\right) \cdot x \]
    5. associate-*l*N/A

      \[\leadsto 35000000 \cdot x + \color{blue}{\frac{-7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \left(\frac{1}{x} \cdot x\right)} \]
    6. lft-mult-inverseN/A

      \[\leadsto 35000000 \cdot x + \frac{-7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304} \cdot \color{blue}{1} \]
    7. metadata-evalN/A

      \[\leadsto 35000000 \cdot x + \color{blue}{\frac{-7946124958802227300036025298123413786115625}{5316911983139663491615228241121378304}} \]
    8. lower-fma.f6421.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, -1494500\right)} \]
  7. Applied rewrites21.6%

    \[\leadsto \color{blue}{\mathsf{fma}\left(35000000, x, -1494500\right)} \]
  8. Add Preprocessing

Reproduce

?
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)))