speed * time / 3600000

Percentage Accurate: 99.6% → 99.6%
Time: 2.0s
Alternatives: 3
Speedup: 1.0×

Specification

?
\[\left(5 \leq speed \land speed \leq 150\right) \land \left(1000 \leq time \land time \leq 100000\right)\]
\[\begin{array}{l} \\ \frac{speed \cdot time}{3600000} \end{array} \]
(FPCore (speed time) :precision binary64 (/ (* speed time) 3600000.0))
double code(double speed, double time) {
	return (speed * time) / 3600000.0;
}
real(8) function code(speed, time)
    real(8), intent (in) :: speed
    real(8), intent (in) :: time
    code = (speed * time) / 3600000.0d0
end function
public static double code(double speed, double time) {
	return (speed * time) / 3600000.0;
}
def code(speed, time):
	return (speed * time) / 3600000.0
function code(speed, time)
	return Float64(Float64(speed * time) / 3600000.0)
end
function tmp = code(speed, time)
	tmp = (speed * time) / 3600000.0;
end
code[speed_, time_] := N[(N[(speed * time), $MachinePrecision] / 3600000.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{speed \cdot time}{3600000}
\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 3 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{speed \cdot time}{3600000} \end{array} \]
(FPCore (speed time) :precision binary64 (/ (* speed time) 3600000.0))
double code(double speed, double time) {
	return (speed * time) / 3600000.0;
}
real(8) function code(speed, time)
    real(8), intent (in) :: speed
    real(8), intent (in) :: time
    code = (speed * time) / 3600000.0d0
end function
public static double code(double speed, double time) {
	return (speed * time) / 3600000.0;
}
def code(speed, time):
	return (speed * time) / 3600000.0
function code(speed, time)
	return Float64(Float64(speed * time) / 3600000.0)
end
function tmp = code(speed, time)
	tmp = (speed * time) / 3600000.0;
end
code[speed_, time_] := N[(N[(speed * time), $MachinePrecision] / 3600000.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{speed \cdot time}{3600000}
\end{array}

Alternative 1: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{speed \cdot time}{3600000} \end{array} \]
(FPCore (speed time) :precision binary64 (/ (* speed time) 3600000.0))
double code(double speed, double time) {
	return (speed * time) / 3600000.0;
}
real(8) function code(speed, time)
    real(8), intent (in) :: speed
    real(8), intent (in) :: time
    code = (speed * time) / 3600000.0d0
end function
public static double code(double speed, double time) {
	return (speed * time) / 3600000.0;
}
def code(speed, time):
	return (speed * time) / 3600000.0
function code(speed, time)
	return Float64(Float64(speed * time) / 3600000.0)
end
function tmp = code(speed, time)
	tmp = (speed * time) / 3600000.0;
end
code[speed_, time_] := N[(N[(speed * time), $MachinePrecision] / 3600000.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{speed \cdot time}{3600000}
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{speed \cdot time}{3600000} \]
  2. Add Preprocessing
  3. Add Preprocessing

Alternative 2: 99.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{speed}{3600000} \cdot time \end{array} \]
(FPCore (speed time) :precision binary64 (* (/ speed 3600000.0) time))
double code(double speed, double time) {
	return (speed / 3600000.0) * time;
}
real(8) function code(speed, time)
    real(8), intent (in) :: speed
    real(8), intent (in) :: time
    code = (speed / 3600000.0d0) * time
end function
public static double code(double speed, double time) {
	return (speed / 3600000.0) * time;
}
def code(speed, time):
	return (speed / 3600000.0) * time
function code(speed, time)
	return Float64(Float64(speed / 3600000.0) * time)
end
function tmp = code(speed, time)
	tmp = (speed / 3600000.0) * time;
end
code[speed_, time_] := N[(N[(speed / 3600000.0), $MachinePrecision] * time), $MachinePrecision]
\begin{array}{l}

\\
\frac{speed}{3600000} \cdot time
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{speed \cdot time}{3600000} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{speed \cdot time}{3600000}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{speed \cdot time}}{3600000} \]
    3. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{speed}{3600000} \cdot time} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{speed}{3600000} \cdot time} \]
    5. div-invN/A

      \[\leadsto \color{blue}{\left(speed \cdot \frac{1}{3600000}\right)} \cdot time \]
    6. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\frac{1}{3600000} \cdot speed\right)} \cdot time \]
    7. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{3600000} \cdot speed\right)} \cdot time \]
    8. metadata-eval99.2

      \[\leadsto \left(\color{blue}{2.7777777777777776 \cdot 10^{-7}} \cdot speed\right) \cdot time \]
  4. Applied rewrites99.2%

    \[\leadsto \color{blue}{\left(2.7777777777777776 \cdot 10^{-7} \cdot speed\right) \cdot time} \]
  5. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{3600000} \cdot speed\right)} \cdot time \]
    2. *-commutativeN/A

      \[\leadsto \color{blue}{\left(speed \cdot \frac{1}{3600000}\right)} \cdot time \]
    3. metadata-evalN/A

      \[\leadsto \left(speed \cdot \color{blue}{\frac{1}{3600000}}\right) \cdot time \]
    4. div-invN/A

      \[\leadsto \color{blue}{\frac{speed}{3600000}} \cdot time \]
    5. lower-/.f6499.6

      \[\leadsto \color{blue}{\frac{speed}{3600000}} \cdot time \]
  6. Applied rewrites99.6%

    \[\leadsto \color{blue}{\frac{speed}{3600000}} \cdot time \]
  7. Add Preprocessing

Alternative 3: 99.3% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \left(2.7777777777777776 \cdot 10^{-7} \cdot speed\right) \cdot time \end{array} \]
(FPCore (speed time)
 :precision binary64
 (* (* 2.7777777777777776e-7 speed) time))
double code(double speed, double time) {
	return (2.7777777777777776e-7 * speed) * time;
}
real(8) function code(speed, time)
    real(8), intent (in) :: speed
    real(8), intent (in) :: time
    code = (2.7777777777777776d-7 * speed) * time
end function
public static double code(double speed, double time) {
	return (2.7777777777777776e-7 * speed) * time;
}
def code(speed, time):
	return (2.7777777777777776e-7 * speed) * time
function code(speed, time)
	return Float64(Float64(2.7777777777777776e-7 * speed) * time)
end
function tmp = code(speed, time)
	tmp = (2.7777777777777776e-7 * speed) * time;
end
code[speed_, time_] := N[(N[(2.7777777777777776e-7 * speed), $MachinePrecision] * time), $MachinePrecision]
\begin{array}{l}

\\
\left(2.7777777777777776 \cdot 10^{-7} \cdot speed\right) \cdot time
\end{array}
Derivation
  1. Initial program 99.6%

    \[\frac{speed \cdot time}{3600000} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{speed \cdot time}{3600000}} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{speed \cdot time}}{3600000} \]
    3. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{speed}{3600000} \cdot time} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{speed}{3600000} \cdot time} \]
    5. div-invN/A

      \[\leadsto \color{blue}{\left(speed \cdot \frac{1}{3600000}\right)} \cdot time \]
    6. *-commutativeN/A

      \[\leadsto \color{blue}{\left(\frac{1}{3600000} \cdot speed\right)} \cdot time \]
    7. lower-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{3600000} \cdot speed\right)} \cdot time \]
    8. metadata-eval99.2

      \[\leadsto \left(\color{blue}{2.7777777777777776 \cdot 10^{-7}} \cdot speed\right) \cdot time \]
  4. Applied rewrites99.2%

    \[\leadsto \color{blue}{\left(2.7777777777777776 \cdot 10^{-7} \cdot speed\right) \cdot time} \]
  5. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore (speed time)
  :name "speed * time / 3600000"
  :precision binary64
  :pre (and (and (<= 5.0 speed) (<= speed 150.0)) (and (<= 1000.0 time) (<= time 100000.0)))
  (/ (* speed time) 3600000.0))