(-2.0 * 3.14 * 9000000) / (1.0 / 300000000) * k

Percentage Accurate: 99.6% → 99.6%
Time: 2.0s
Alternatives: 1
Speedup: 6.7×

Specification

?
\[0.01 \leq k \land k \leq 10000\]
\[\begin{array}{l} \\ \frac{\left(\left(-2\right) \cdot 3.14\right) \cdot 9000000}{\frac{1}{300000000}} \cdot k \end{array} \]
(FPCore (k)
 :precision binary64
 (* (/ (* (* (- 2.0) 3.14) 9000000.0) (/ 1.0 300000000.0)) k))
double code(double k) {
	return (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k;
}
real(8) function code(k)
    real(8), intent (in) :: k
    code = (((-2.0d0 * 3.14d0) * 9000000.0d0) / (1.0d0 / 300000000.0d0)) * k
end function
public static double code(double k) {
	return (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k;
}
def code(k):
	return (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k
function code(k)
	return Float64(Float64(Float64(Float64(Float64(-2.0) * 3.14) * 9000000.0) / Float64(1.0 / 300000000.0)) * k)
end
function tmp = code(k)
	tmp = (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k;
end
code[k_] := N[(N[(N[(N[((-2.0) * 3.14), $MachinePrecision] * 9000000.0), $MachinePrecision] / N[(1.0 / 300000000.0), $MachinePrecision]), $MachinePrecision] * k), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(\left(-2\right) \cdot 3.14\right) \cdot 9000000}{\frac{1}{300000000}} \cdot k
\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 1 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.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(\left(-2\right) \cdot 3.14\right) \cdot 9000000}{\frac{1}{300000000}} \cdot k \end{array} \]
(FPCore (k)
 :precision binary64
 (* (/ (* (* (- 2.0) 3.14) 9000000.0) (/ 1.0 300000000.0)) k))
double code(double k) {
	return (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k;
}
real(8) function code(k)
    real(8), intent (in) :: k
    code = (((-2.0d0 * 3.14d0) * 9000000.0d0) / (1.0d0 / 300000000.0d0)) * k
end function
public static double code(double k) {
	return (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k;
}
def code(k):
	return (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k
function code(k)
	return Float64(Float64(Float64(Float64(Float64(-2.0) * 3.14) * 9000000.0) / Float64(1.0 / 300000000.0)) * k)
end
function tmp = code(k)
	tmp = (((-2.0 * 3.14) * 9000000.0) / (1.0 / 300000000.0)) * k;
end
code[k_] := N[(N[(N[(N[((-2.0) * 3.14), $MachinePrecision] * 9000000.0), $MachinePrecision] / N[(1.0 / 300000000.0), $MachinePrecision]), $MachinePrecision] * k), $MachinePrecision]
\begin{array}{l}

\\
\frac{\left(\left(-2\right) \cdot 3.14\right) \cdot 9000000}{\frac{1}{300000000}} \cdot k
\end{array}

Alternative 1: 99.6% accurate, 6.7× speedup?

\[\begin{array}{l} \\ k \cdot -1.6956 \cdot 10^{+16} \end{array} \]
(FPCore (k) :precision binary64 (* k -1.6956e+16))
double code(double k) {
	return k * -1.6956e+16;
}
real(8) function code(k)
    real(8), intent (in) :: k
    code = k * (-1.6956d+16)
end function
public static double code(double k) {
	return k * -1.6956e+16;
}
def code(k):
	return k * -1.6956e+16
function code(k)
	return Float64(k * -1.6956e+16)
end
function tmp = code(k)
	tmp = k * -1.6956e+16;
end
code[k_] := N[(k * -1.6956e+16), $MachinePrecision]
\begin{array}{l}

\\
k \cdot -1.6956 \cdot 10^{+16}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{\left(\left(-2\right) \cdot 3.14\right) \cdot 9000000}{\frac{1}{300000000}} \cdot k \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\frac{\left(\left(-2\right) \cdot \frac{7070651414971679}{2251799813685248}\right) \cdot 9000000}{\frac{1}{300000000}} \cdot k} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{k \cdot \frac{\left(\left(-2\right) \cdot \frac{7070651414971679}{2251799813685248}\right) \cdot 9000000}{\frac{1}{300000000}}} \]
    3. lower-*.f6499.5

      \[\leadsto \color{blue}{k \cdot \frac{\left(\left(-2\right) \cdot 3.14\right) \cdot 9000000}{\frac{1}{300000000}}} \]
    4. lift-/.f64N/A

      \[\leadsto k \cdot \color{blue}{\frac{\left(\left(-2\right) \cdot \frac{7070651414971679}{2251799813685248}\right) \cdot 9000000}{\frac{1}{300000000}}} \]
    5. lift-*.f64N/A

      \[\leadsto k \cdot \frac{\color{blue}{\left(\left(-2\right) \cdot \frac{7070651414971679}{2251799813685248}\right) \cdot 9000000}}{\frac{1}{300000000}} \]
    6. lift-*.f64N/A

      \[\leadsto k \cdot \frac{\color{blue}{\left(\left(-2\right) \cdot \frac{7070651414971679}{2251799813685248}\right)} \cdot 9000000}{\frac{1}{300000000}} \]
    7. lift-neg.f64N/A

      \[\leadsto k \cdot \frac{\left(\color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \cdot \frac{7070651414971679}{2251799813685248}\right) \cdot 9000000}{\frac{1}{300000000}} \]
    8. metadata-evalN/A

      \[\leadsto k \cdot \frac{\left(\color{blue}{-2} \cdot \frac{7070651414971679}{2251799813685248}\right) \cdot 9000000}{\frac{1}{300000000}} \]
    9. metadata-evalN/A

      \[\leadsto k \cdot \frac{\color{blue}{\frac{-7070651414971679}{1125899906842624}} \cdot 9000000}{\frac{1}{300000000}} \]
    10. metadata-evalN/A

      \[\leadsto k \cdot \frac{\color{blue}{\frac{-994310355230392359375}{17592186044416}}}{\frac{1}{300000000}} \]
    11. lift-/.f64N/A

      \[\leadsto k \cdot \frac{\frac{-994310355230392359375}{17592186044416}}{\color{blue}{\frac{1}{300000000}}} \]
    12. metadata-evalN/A

      \[\leadsto k \cdot \frac{\frac{-994310355230392359375}{17592186044416}}{\color{blue}{\frac{1}{300000000}}} \]
    13. metadata-eval99.5

      \[\leadsto k \cdot \color{blue}{-1.6956 \cdot 10^{+16}} \]
  4. Applied rewrites99.5%

    \[\leadsto \color{blue}{k \cdot -1.6956 \cdot 10^{+16}} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore (k)
  :name "(-2.0 * 3.14 * 9000000) / (1.0 / 300000000)  * k"
  :precision binary64
  :pre (and (<= 0.01 k) (<= k 10000.0))
  (* (/ (* (* (- 2.0) 3.14) 9000000.0) (/ 1.0 300000000.0)) k))