1.0 / Ts * 8.2E-6 * fabs(omega_ist);

Percentage Accurate: 99.5% → 99.7%
Time: 2.5s
Alternatives: 1
Speedup: 1.3×

Specification

?
\[\left(-1.79 \cdot 10^{+308} \leq Ts \land Ts \leq 1.79 \cdot 10^{+308}\right) \land \left(-1.79 \cdot 10^{+308} \leq omega\_ist \land omega\_ist \leq 1.79 \cdot 10^{+308}\right)\]
\[\begin{array}{l} \\ \left(\frac{1}{Ts} \cdot 8.2 \cdot 10^{-6}\right) \cdot \left|omega\_ist\right| \end{array} \]
(FPCore (Ts omega_ist)
 :precision binary64
 (* (* (/ 1.0 Ts) 8.2e-6) (fabs omega_ist)))
double code(double Ts, double omega_ist) {
	return ((1.0 / Ts) * 8.2e-6) * fabs(omega_ist);
}
real(8) function code(ts, omega_ist)
    real(8), intent (in) :: ts
    real(8), intent (in) :: omega_ist
    code = ((1.0d0 / ts) * 8.2d-6) * abs(omega_ist)
end function
public static double code(double Ts, double omega_ist) {
	return ((1.0 / Ts) * 8.2e-6) * Math.abs(omega_ist);
}
def code(Ts, omega_ist):
	return ((1.0 / Ts) * 8.2e-6) * math.fabs(omega_ist)
function code(Ts, omega_ist)
	return Float64(Float64(Float64(1.0 / Ts) * 8.2e-6) * abs(omega_ist))
end
function tmp = code(Ts, omega_ist)
	tmp = ((1.0 / Ts) * 8.2e-6) * abs(omega_ist);
end
code[Ts_, omega$95$ist_] := N[(N[(N[(1.0 / Ts), $MachinePrecision] * 8.2e-6), $MachinePrecision] * N[Abs[omega$95$ist], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{1}{Ts} \cdot 8.2 \cdot 10^{-6}\right) \cdot \left|omega\_ist\right|
\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.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\frac{1}{Ts} \cdot 8.2 \cdot 10^{-6}\right) \cdot \left|omega\_ist\right| \end{array} \]
(FPCore (Ts omega_ist)
 :precision binary64
 (* (* (/ 1.0 Ts) 8.2e-6) (fabs omega_ist)))
double code(double Ts, double omega_ist) {
	return ((1.0 / Ts) * 8.2e-6) * fabs(omega_ist);
}
real(8) function code(ts, omega_ist)
    real(8), intent (in) :: ts
    real(8), intent (in) :: omega_ist
    code = ((1.0d0 / ts) * 8.2d-6) * abs(omega_ist)
end function
public static double code(double Ts, double omega_ist) {
	return ((1.0 / Ts) * 8.2e-6) * Math.abs(omega_ist);
}
def code(Ts, omega_ist):
	return ((1.0 / Ts) * 8.2e-6) * math.fabs(omega_ist)
function code(Ts, omega_ist)
	return Float64(Float64(Float64(1.0 / Ts) * 8.2e-6) * abs(omega_ist))
end
function tmp = code(Ts, omega_ist)
	tmp = ((1.0 / Ts) * 8.2e-6) * abs(omega_ist);
end
code[Ts_, omega$95$ist_] := N[(N[(N[(1.0 / Ts), $MachinePrecision] * 8.2e-6), $MachinePrecision] * N[Abs[omega$95$ist], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\frac{1}{Ts} \cdot 8.2 \cdot 10^{-6}\right) \cdot \left|omega\_ist\right|
\end{array}

Alternative 1: 99.7% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \left|omega\_ist\right| \cdot \frac{8.2 \cdot 10^{-6}}{Ts} \end{array} \]
(FPCore (Ts omega_ist) :precision binary64 (* (fabs omega_ist) (/ 8.2e-6 Ts)))
double code(double Ts, double omega_ist) {
	return fabs(omega_ist) * (8.2e-6 / Ts);
}
real(8) function code(ts, omega_ist)
    real(8), intent (in) :: ts
    real(8), intent (in) :: omega_ist
    code = abs(omega_ist) * (8.2d-6 / ts)
end function
public static double code(double Ts, double omega_ist) {
	return Math.abs(omega_ist) * (8.2e-6 / Ts);
}
def code(Ts, omega_ist):
	return math.fabs(omega_ist) * (8.2e-6 / Ts)
function code(Ts, omega_ist)
	return Float64(abs(omega_ist) * Float64(8.2e-6 / Ts))
end
function tmp = code(Ts, omega_ist)
	tmp = abs(omega_ist) * (8.2e-6 / Ts);
end
code[Ts_, omega$95$ist_] := N[(N[Abs[omega$95$ist], $MachinePrecision] * N[(8.2e-6 / Ts), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left|omega\_ist\right| \cdot \frac{8.2 \cdot 10^{-6}}{Ts}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\left(\frac{1}{Ts} \cdot 8.2 \cdot 10^{-6}\right) \cdot \left|omega\_ist\right| \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \color{blue}{\left(\frac{1}{Ts} \cdot \frac{2420212822470693}{295147905179352825856}\right)} \cdot \left|omega\_ist\right| \]
    2. lift-/.f64N/A

      \[\leadsto \left(\color{blue}{\frac{1}{Ts}} \cdot \frac{2420212822470693}{295147905179352825856}\right) \cdot \left|omega\_ist\right| \]
    3. associate-*l/N/A

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{2420212822470693}{295147905179352825856}}{Ts}} \cdot \left|omega\_ist\right| \]
    4. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\frac{2420212822470693}{295147905179352825856}}}{Ts} \cdot \left|omega\_ist\right| \]
    5. lower-/.f6499.6

      \[\leadsto \color{blue}{\frac{8.2 \cdot 10^{-6}}{Ts}} \cdot \left|omega\_ist\right| \]
  4. Applied rewrites99.6%

    \[\leadsto \color{blue}{\frac{8.2 \cdot 10^{-6}}{Ts}} \cdot \left|omega\_ist\right| \]
  5. Final simplification99.6%

    \[\leadsto \left|omega\_ist\right| \cdot \frac{8.2 \cdot 10^{-6}}{Ts} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 1 
(FPCore (Ts omega_ist)
  :name "1.0 / Ts * 8.2E-6 * fabs(omega_ist);"
  :precision binary64
  :pre (and (and (<= -1.79e+308 Ts) (<= Ts 1.79e+308)) (and (<= -1.79e+308 omega_ist) (<= omega_ist 1.79e+308)))
  (* (* (/ 1.0 Ts) 8.2e-6) (fabs omega_ist)))