((-2. * 3.14159265358979323846 * 9600000) * (1. / 300000000)) * distance;

Percentage Accurate: 99.4% → 99.4%
Time: 1.5s
Alternatives: 1
Speedup: 5.7×

Specification

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

\\
\left(\left(\left(\left(-2\right) \cdot 3.141592653589793\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right) \cdot distance
\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.4% accurate, 1.0× speedup?

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

\\
\left(\left(\left(\left(-2\right) \cdot 3.141592653589793\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right) \cdot distance
\end{array}

Alternative 1: 99.4% accurate, 5.7× speedup?

\[\begin{array}{l} \\ distance \cdot -0.20106192982974677 \end{array} \]
(FPCore (distance) :precision binary64 (* distance -0.20106192982974677))
double code(double distance) {
	return distance * -0.20106192982974677;
}
real(8) function code(distance)
    real(8), intent (in) :: distance
    code = distance * (-0.20106192982974677d0)
end function
public static double code(double distance) {
	return distance * -0.20106192982974677;
}
def code(distance):
	return distance * -0.20106192982974677
function code(distance)
	return Float64(distance * -0.20106192982974677)
end
function tmp = code(distance)
	tmp = distance * -0.20106192982974677;
end
code[distance_] := N[(distance * -0.20106192982974677), $MachinePrecision]
\begin{array}{l}

\\
distance \cdot -0.20106192982974677
\end{array}
Derivation
  1. Initial program 99.5%

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

      \[\leadsto \color{blue}{\left(\left(\left(\left(-2\right) \cdot \frac{884279719003555}{281474976710656}\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right) \cdot distance} \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{distance \cdot \left(\left(\left(\left(-2\right) \cdot \frac{884279719003555}{281474976710656}\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right)} \]
    3. lower-*.f6499.5

      \[\leadsto \color{blue}{distance \cdot \left(\left(\left(\left(-2\right) \cdot 3.141592653589793\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right)} \]
    4. lift-*.f64N/A

      \[\leadsto distance \cdot \color{blue}{\left(\left(\left(\left(-2\right) \cdot \frac{884279719003555}{281474976710656}\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right)} \]
    5. lift-*.f64N/A

      \[\leadsto distance \cdot \left(\color{blue}{\left(\left(\left(-2\right) \cdot \frac{884279719003555}{281474976710656}\right) \cdot 9600000\right)} \cdot \frac{1}{300000000}\right) \]
    6. lift-*.f64N/A

      \[\leadsto distance \cdot \left(\left(\color{blue}{\left(\left(-2\right) \cdot \frac{884279719003555}{281474976710656}\right)} \cdot 9600000\right) \cdot \frac{1}{300000000}\right) \]
    7. lift-neg.f64N/A

      \[\leadsto distance \cdot \left(\left(\left(\color{blue}{\left(\mathsf{neg}\left(2\right)\right)} \cdot \frac{884279719003555}{281474976710656}\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right) \]
    8. metadata-evalN/A

      \[\leadsto distance \cdot \left(\left(\left(\color{blue}{-2} \cdot \frac{884279719003555}{281474976710656}\right) \cdot 9600000\right) \cdot \frac{1}{300000000}\right) \]
    9. metadata-evalN/A

      \[\leadsto distance \cdot \left(\left(\color{blue}{\frac{-884279719003555}{140737488355328}} \cdot 9600000\right) \cdot \frac{1}{300000000}\right) \]
    10. metadata-evalN/A

      \[\leadsto distance \cdot \left(\color{blue}{\frac{-8290122365658328125}{137438953472}} \cdot \frac{1}{300000000}\right) \]
    11. lift-/.f64N/A

      \[\leadsto distance \cdot \left(\frac{-8290122365658328125}{137438953472} \cdot \color{blue}{\frac{1}{300000000}}\right) \]
    12. metadata-evalN/A

      \[\leadsto distance \cdot \left(\frac{-8290122365658328125}{137438953472} \cdot \color{blue}{\frac{1}{300000000}}\right) \]
    13. metadata-eval99.5

      \[\leadsto distance \cdot \color{blue}{-0.20106192982974677} \]
  4. Applied rewrites99.5%

    \[\leadsto \color{blue}{distance \cdot -0.20106192982974677} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore (distance)
  :name "((-2. * 3.14159265358979323846 * 9600000) * (1. / 300000000)) * distance;"
  :precision binary64
  :pre (and (<= 0.01 distance) (<= distance 1000.0))
  (* (* (* (* (- 2.0) 3.141592653589793) 9600000.0) (/ 1.0 300000000.0)) distance))