Falkner and Boettcher, Equation (20:1,3)

Percentage Accurate: 99.3% → 99.4%
Time: 6.6s
Alternatives: 6
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \end{array} \]
(FPCore (v t)
 :precision binary64
 (/
  (- 1.0 (* 5.0 (* v v)))
  (* (* (* PI t) (sqrt (* 2.0 (- 1.0 (* 3.0 (* v v)))))) (- 1.0 (* v v)))))
double code(double v, double t) {
	return (1.0 - (5.0 * (v * v))) / (((((double) M_PI) * t) * sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)));
}
public static double code(double v, double t) {
	return (1.0 - (5.0 * (v * v))) / (((Math.PI * t) * Math.sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)));
}
def code(v, t):
	return (1.0 - (5.0 * (v * v))) / (((math.pi * t) * math.sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)))
function code(v, t)
	return Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(Float64(pi * t) * sqrt(Float64(2.0 * Float64(1.0 - Float64(3.0 * Float64(v * v)))))) * Float64(1.0 - Float64(v * v))))
end
function tmp = code(v, t)
	tmp = (1.0 - (5.0 * (v * v))) / (((pi * t) * sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)));
end
code[v_, t_] := N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(Pi * t), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(1.0 - N[(3.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\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 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} \\ \frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \end{array} \]
(FPCore (v t)
 :precision binary64
 (/
  (- 1.0 (* 5.0 (* v v)))
  (* (* (* PI t) (sqrt (* 2.0 (- 1.0 (* 3.0 (* v v)))))) (- 1.0 (* v v)))))
double code(double v, double t) {
	return (1.0 - (5.0 * (v * v))) / (((((double) M_PI) * t) * sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)));
}
public static double code(double v, double t) {
	return (1.0 - (5.0 * (v * v))) / (((Math.PI * t) * Math.sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)));
}
def code(v, t):
	return (1.0 - (5.0 * (v * v))) / (((math.pi * t) * math.sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)))
function code(v, t)
	return Float64(Float64(1.0 - Float64(5.0 * Float64(v * v))) / Float64(Float64(Float64(pi * t) * sqrt(Float64(2.0 * Float64(1.0 - Float64(3.0 * Float64(v * v)))))) * Float64(1.0 - Float64(v * v))))
end
function tmp = code(v, t)
	tmp = (1.0 - (5.0 * (v * v))) / (((pi * t) * sqrt((2.0 * (1.0 - (3.0 * (v * v)))))) * (1.0 - (v * v)));
end
code[v_, t_] := N[(N[(1.0 - N[(5.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(N[(Pi * t), $MachinePrecision] * N[Sqrt[N[(2.0 * N[(1.0 - N[(3.0 * N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)}
\end{array}

Alternative 1: 99.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}\right) \cdot \left(1 - v \cdot v\right)\right)} \end{array} \]
(FPCore (v t)
 :precision binary64
 (/
  (+ 1.0 (* (* v v) -5.0))
  (* t (* (* PI (sqrt (fma v (* v -6.0) 2.0))) (- 1.0 (* v v))))))
double code(double v, double t) {
	return (1.0 + ((v * v) * -5.0)) / (t * ((((double) M_PI) * sqrt(fma(v, (v * -6.0), 2.0))) * (1.0 - (v * v))));
}
function code(v, t)
	return Float64(Float64(1.0 + Float64(Float64(v * v) * -5.0)) / Float64(t * Float64(Float64(pi * sqrt(fma(v, Float64(v * -6.0), 2.0))) * Float64(1.0 - Float64(v * v)))))
end
code[v_, t_] := N[(N[(1.0 + N[(N[(v * v), $MachinePrecision] * -5.0), $MachinePrecision]), $MachinePrecision] / N[(t * N[(N[(Pi * N[Sqrt[N[(v * N[(v * -6.0), $MachinePrecision] + 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}\right) \cdot \left(1 - v \cdot v\right)\right)}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \]
  2. Simplified99.4%

    \[\leadsto \color{blue}{\frac{1 + \left(v \cdot v\right) \cdot -5}{\pi \cdot \left(t \cdot \left(\sqrt{2 \cdot \left(1 - v \cdot \left(v \cdot 3\right)\right)} \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
  3. Step-by-step derivation
    1. associate-*r*99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - v \cdot \left(v \cdot 3\right)\right)} \cdot \left(1 - v \cdot v\right)\right)}} \]
    2. associate-*r*99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - \color{blue}{\left(v \cdot v\right) \cdot 3}\right)} \cdot \left(1 - v \cdot v\right)\right)} \]
    3. *-commutative99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - \color{blue}{3 \cdot \left(v \cdot v\right)}\right)} \cdot \left(1 - v \cdot v\right)\right)} \]
    4. associate-*l*99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)}} \]
    5. expm1-log1p-u73.0%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
    6. expm1-udef27.1%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{e^{\mathsf{log1p}\left(\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)\right)} - 1}} \]
  4. Applied egg-rr27.1%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{e^{\mathsf{log1p}\left(\left(1 - v \cdot v\right) \cdot \left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)\right)} - 1}} \]
  5. Step-by-step derivation
    1. expm1-def73.0%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(1 - v \cdot v\right) \cdot \left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)\right)\right)}} \]
    2. expm1-log1p99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(1 - v \cdot v\right) \cdot \left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)}} \]
    3. *-commutative99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)}} \]
    4. associate-*l*99.5%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(t \cdot \left(\pi \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    5. associate-*l*99.6%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{t \cdot \left(\left(\pi \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)\right)}} \]
  6. Simplified99.6%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{t \cdot \left(\left(\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}\right) \cdot \left(1 - v \cdot v\right)\right)}} \]
  7. Final simplification99.6%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}\right) \cdot \left(1 - v \cdot v\right)\right)} \]

Alternative 2: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 + \left(v \cdot v\right) \cdot -6}\right)} \end{array} \]
(FPCore (v t)
 :precision binary64
 (/
  (+ 1.0 (* (* v v) -5.0))
  (* t (* (* PI (- 1.0 (* v v))) (sqrt (+ 2.0 (* (* v v) -6.0)))))))
double code(double v, double t) {
	return (1.0 + ((v * v) * -5.0)) / (t * ((((double) M_PI) * (1.0 - (v * v))) * sqrt((2.0 + ((v * v) * -6.0)))));
}
public static double code(double v, double t) {
	return (1.0 + ((v * v) * -5.0)) / (t * ((Math.PI * (1.0 - (v * v))) * Math.sqrt((2.0 + ((v * v) * -6.0)))));
}
def code(v, t):
	return (1.0 + ((v * v) * -5.0)) / (t * ((math.pi * (1.0 - (v * v))) * math.sqrt((2.0 + ((v * v) * -6.0)))))
function code(v, t)
	return Float64(Float64(1.0 + Float64(Float64(v * v) * -5.0)) / Float64(t * Float64(Float64(pi * Float64(1.0 - Float64(v * v))) * sqrt(Float64(2.0 + Float64(Float64(v * v) * -6.0))))))
end
function tmp = code(v, t)
	tmp = (1.0 + ((v * v) * -5.0)) / (t * ((pi * (1.0 - (v * v))) * sqrt((2.0 + ((v * v) * -6.0)))));
end
code[v_, t_] := N[(N[(1.0 + N[(N[(v * v), $MachinePrecision] * -5.0), $MachinePrecision]), $MachinePrecision] / N[(t * N[(N[(Pi * N[(1.0 - N[(v * v), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(2.0 + N[(N[(v * v), $MachinePrecision] * -6.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 + \left(v \cdot v\right) \cdot -6}\right)}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \]
  2. Simplified99.4%

    \[\leadsto \color{blue}{\frac{1 + \left(v \cdot v\right) \cdot -5}{\pi \cdot \left(t \cdot \left(\sqrt{2 \cdot \left(1 - v \cdot \left(v \cdot 3\right)\right)} \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
  3. Step-by-step derivation
    1. associate-*r*99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - v \cdot \left(v \cdot 3\right)\right)} \cdot \left(1 - v \cdot v\right)\right)}} \]
    2. associate-*r*99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - \color{blue}{\left(v \cdot v\right) \cdot 3}\right)} \cdot \left(1 - v \cdot v\right)\right)} \]
    3. *-commutative99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - \color{blue}{3 \cdot \left(v \cdot v\right)}\right)} \cdot \left(1 - v \cdot v\right)\right)} \]
    4. associate-*l*99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)}} \]
    5. expm1-log1p-u73.0%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
    6. expm1-udef27.1%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{e^{\mathsf{log1p}\left(\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)\right)} - 1}} \]
  4. Applied egg-rr27.1%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{e^{\mathsf{log1p}\left(\left(1 - v \cdot v\right) \cdot \left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)\right)} - 1}} \]
  5. Step-by-step derivation
    1. expm1-def73.0%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(1 - v \cdot v\right) \cdot \left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)\right)\right)}} \]
    2. expm1-log1p99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(1 - v \cdot v\right) \cdot \left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)}} \]
    3. *-commutative99.4%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(\left(t \cdot \pi\right) \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)}} \]
    4. associate-*l*99.5%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(t \cdot \left(\pi \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    5. associate-*l*99.6%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{t \cdot \left(\left(\pi \cdot \sqrt{2 \cdot \left(1 + -3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)\right)}} \]
  6. Simplified99.6%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{t \cdot \left(\left(\pi \cdot \sqrt{\mathsf{fma}\left(v, v \cdot -6, 2\right)}\right) \cdot \left(1 - v \cdot v\right)\right)}} \]
  7. Taylor expanded in t around 0 99.3%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{\left(t \cdot \left(\pi \cdot \left(1 - {v}^{2}\right)\right)\right) \cdot \sqrt{2 + -6 \cdot {v}^{2}}}} \]
  8. Step-by-step derivation
    1. associate-*l*99.5%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{t \cdot \left(\left(\pi \cdot \left(1 - {v}^{2}\right)\right) \cdot \sqrt{2 + -6 \cdot {v}^{2}}\right)}} \]
    2. unpow299.5%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \left(1 - \color{blue}{v \cdot v}\right)\right) \cdot \sqrt{2 + -6 \cdot {v}^{2}}\right)} \]
    3. *-commutative99.5%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 + \color{blue}{{v}^{2} \cdot -6}}\right)} \]
    4. unpow299.5%

      \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 + \color{blue}{\left(v \cdot v\right)} \cdot -6}\right)} \]
  9. Simplified99.5%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{\color{blue}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 + \left(v \cdot v\right) \cdot -6}\right)}} \]
  10. Final simplification99.5%

    \[\leadsto \frac{1 + \left(v \cdot v\right) \cdot -5}{t \cdot \left(\left(\pi \cdot \left(1 - v \cdot v\right)\right) \cdot \sqrt{2 + \left(v \cdot v\right) \cdot -6}\right)} \]

Alternative 3: 98.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \sqrt{0.5} \cdot \frac{1}{t \cdot \pi} \end{array} \]
(FPCore (v t) :precision binary64 (* (sqrt 0.5) (/ 1.0 (* t PI))))
double code(double v, double t) {
	return sqrt(0.5) * (1.0 / (t * ((double) M_PI)));
}
public static double code(double v, double t) {
	return Math.sqrt(0.5) * (1.0 / (t * Math.PI));
}
def code(v, t):
	return math.sqrt(0.5) * (1.0 / (t * math.pi))
function code(v, t)
	return Float64(sqrt(0.5) * Float64(1.0 / Float64(t * pi)))
end
function tmp = code(v, t)
	tmp = sqrt(0.5) * (1.0 / (t * pi));
end
code[v_, t_] := N[(N[Sqrt[0.5], $MachinePrecision] * N[(1.0 / N[(t * Pi), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt{0.5} \cdot \frac{1}{t \cdot \pi}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \]
  2. Step-by-step derivation
    1. associate-*l*99.4%

      \[\leadsto \frac{1 - 5 \cdot \left(v \cdot v\right)}{\color{blue}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)\right)}} \]
    2. associate-/r*99.4%

      \[\leadsto \color{blue}{\frac{\frac{1 - 5 \cdot \left(v \cdot v\right)}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)}} \]
    3. sub-neg99.4%

      \[\leadsto \frac{\frac{\color{blue}{1 + \left(-5 \cdot \left(v \cdot v\right)\right)}}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    4. +-commutative99.4%

      \[\leadsto \frac{\frac{\color{blue}{\left(-5 \cdot \left(v \cdot v\right)\right) + 1}}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    5. sqr-neg99.4%

      \[\leadsto \frac{\frac{\left(-5 \cdot \color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right)}\right) + 1}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    6. *-commutative99.4%

      \[\leadsto \frac{\frac{\left(-\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot 5}\right) + 1}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    7. distribute-rgt-neg-in99.4%

      \[\leadsto \frac{\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    8. fma-def99.4%

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(\left(-v\right) \cdot \left(-v\right), -5, 1\right)}}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    9. sqr-neg99.4%

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, -5, 1\right)}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    10. metadata-eval99.4%

      \[\leadsto \frac{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{-5}, 1\right)}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\pi \cdot t}}{\sqrt{2 + \left(v \cdot v\right) \cdot -6} \cdot \left(1 - v \cdot v\right)}} \]
  4. Taylor expanded in v around 0 97.6%

    \[\leadsto \color{blue}{\frac{\sqrt{0.5}}{t \cdot \pi}} \]
  5. Step-by-step derivation
    1. div-inv97.6%

      \[\leadsto \color{blue}{\sqrt{0.5} \cdot \frac{1}{t \cdot \pi}} \]
    2. *-commutative97.6%

      \[\leadsto \sqrt{0.5} \cdot \frac{1}{\color{blue}{\pi \cdot t}} \]
  6. Applied egg-rr97.6%

    \[\leadsto \color{blue}{\sqrt{0.5} \cdot \frac{1}{\pi \cdot t}} \]
  7. Final simplification97.6%

    \[\leadsto \sqrt{0.5} \cdot \frac{1}{t \cdot \pi} \]

Alternative 4: 98.6% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{1}{t \cdot \left(\pi \cdot \sqrt{2}\right)} \end{array} \]
(FPCore (v t) :precision binary64 (/ 1.0 (* t (* PI (sqrt 2.0)))))
double code(double v, double t) {
	return 1.0 / (t * (((double) M_PI) * sqrt(2.0)));
}
public static double code(double v, double t) {
	return 1.0 / (t * (Math.PI * Math.sqrt(2.0)));
}
def code(v, t):
	return 1.0 / (t * (math.pi * math.sqrt(2.0)))
function code(v, t)
	return Float64(1.0 / Float64(t * Float64(pi * sqrt(2.0))))
end
function tmp = code(v, t)
	tmp = 1.0 / (t * (pi * sqrt(2.0)));
end
code[v_, t_] := N[(1.0 / N[(t * N[(Pi * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{t \cdot \left(\pi \cdot \sqrt{2}\right)}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \]
  2. Simplified99.4%

    \[\leadsto \color{blue}{\frac{1 + \left(v \cdot v\right) \cdot -5}{\pi \cdot \left(t \cdot \left(\sqrt{2 \cdot \left(1 - v \cdot \left(v \cdot 3\right)\right)} \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
  3. Taylor expanded in v around 0 98.2%

    \[\leadsto \color{blue}{\frac{1}{t \cdot \left(\pi \cdot \sqrt{2}\right)}} \]
  4. Step-by-step derivation
    1. *-commutative98.2%

      \[\leadsto \frac{1}{t \cdot \color{blue}{\left(\sqrt{2} \cdot \pi\right)}} \]
  5. Simplified98.2%

    \[\leadsto \color{blue}{\frac{1}{t \cdot \left(\sqrt{2} \cdot \pi\right)}} \]
  6. Final simplification98.2%

    \[\leadsto \frac{1}{t \cdot \left(\pi \cdot \sqrt{2}\right)} \]

Alternative 5: 99.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{\pi \cdot \sqrt{2}}}{t} \end{array} \]
(FPCore (v t) :precision binary64 (/ (/ 1.0 (* PI (sqrt 2.0))) t))
double code(double v, double t) {
	return (1.0 / (((double) M_PI) * sqrt(2.0))) / t;
}
public static double code(double v, double t) {
	return (1.0 / (Math.PI * Math.sqrt(2.0))) / t;
}
def code(v, t):
	return (1.0 / (math.pi * math.sqrt(2.0))) / t
function code(v, t)
	return Float64(Float64(1.0 / Float64(pi * sqrt(2.0))) / t)
end
function tmp = code(v, t)
	tmp = (1.0 / (pi * sqrt(2.0))) / t;
end
code[v_, t_] := N[(N[(1.0 / N[(Pi * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{1}{\pi \cdot \sqrt{2}}}{t}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \]
  2. Simplified99.4%

    \[\leadsto \color{blue}{\frac{1 + \left(v \cdot v\right) \cdot -5}{\pi \cdot \left(t \cdot \left(\sqrt{2 \cdot \left(1 - v \cdot \left(v \cdot 3\right)\right)} \cdot \left(1 - v \cdot v\right)\right)\right)}} \]
  3. Taylor expanded in v around 0 98.2%

    \[\leadsto \color{blue}{\frac{1}{t \cdot \left(\pi \cdot \sqrt{2}\right)}} \]
  4. Step-by-step derivation
    1. associate-/r*98.1%

      \[\leadsto \color{blue}{\frac{\frac{1}{t}}{\pi \cdot \sqrt{2}}} \]
    2. *-commutative98.1%

      \[\leadsto \frac{\frac{1}{t}}{\color{blue}{\sqrt{2} \cdot \pi}} \]
  5. Simplified98.1%

    \[\leadsto \color{blue}{\frac{\frac{1}{t}}{\sqrt{2} \cdot \pi}} \]
  6. Step-by-step derivation
    1. div-inv98.2%

      \[\leadsto \color{blue}{\frac{1}{t} \cdot \frac{1}{\sqrt{2} \cdot \pi}} \]
    2. *-commutative98.2%

      \[\leadsto \frac{1}{t} \cdot \frac{1}{\color{blue}{\pi \cdot \sqrt{2}}} \]
  7. Applied egg-rr98.2%

    \[\leadsto \color{blue}{\frac{1}{t} \cdot \frac{1}{\pi \cdot \sqrt{2}}} \]
  8. Step-by-step derivation
    1. associate-*l/98.5%

      \[\leadsto \color{blue}{\frac{1 \cdot \frac{1}{\pi \cdot \sqrt{2}}}{t}} \]
    2. *-un-lft-identity98.5%

      \[\leadsto \frac{\color{blue}{\frac{1}{\pi \cdot \sqrt{2}}}}{t} \]
  9. Applied egg-rr98.5%

    \[\leadsto \color{blue}{\frac{\frac{1}{\pi \cdot \sqrt{2}}}{t}} \]
  10. Final simplification98.5%

    \[\leadsto \frac{\frac{1}{\pi \cdot \sqrt{2}}}{t} \]

Alternative 6: 98.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \frac{\sqrt{0.5}}{t \cdot \pi} \end{array} \]
(FPCore (v t) :precision binary64 (/ (sqrt 0.5) (* t PI)))
double code(double v, double t) {
	return sqrt(0.5) / (t * ((double) M_PI));
}
public static double code(double v, double t) {
	return Math.sqrt(0.5) / (t * Math.PI);
}
def code(v, t):
	return math.sqrt(0.5) / (t * math.pi)
function code(v, t)
	return Float64(sqrt(0.5) / Float64(t * pi))
end
function tmp = code(v, t)
	tmp = sqrt(0.5) / (t * pi);
end
code[v_, t_] := N[(N[Sqrt[0.5], $MachinePrecision] / N[(t * Pi), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\sqrt{0.5}}{t \cdot \pi}
\end{array}
Derivation
  1. Initial program 99.4%

    \[\frac{1 - 5 \cdot \left(v \cdot v\right)}{\left(\left(\pi \cdot t\right) \cdot \sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)}\right) \cdot \left(1 - v \cdot v\right)} \]
  2. Step-by-step derivation
    1. associate-*l*99.4%

      \[\leadsto \frac{1 - 5 \cdot \left(v \cdot v\right)}{\color{blue}{\left(\pi \cdot t\right) \cdot \left(\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)\right)}} \]
    2. associate-/r*99.4%

      \[\leadsto \color{blue}{\frac{\frac{1 - 5 \cdot \left(v \cdot v\right)}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)}} \]
    3. sub-neg99.4%

      \[\leadsto \frac{\frac{\color{blue}{1 + \left(-5 \cdot \left(v \cdot v\right)\right)}}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    4. +-commutative99.4%

      \[\leadsto \frac{\frac{\color{blue}{\left(-5 \cdot \left(v \cdot v\right)\right) + 1}}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    5. sqr-neg99.4%

      \[\leadsto \frac{\frac{\left(-5 \cdot \color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right)}\right) + 1}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    6. *-commutative99.4%

      \[\leadsto \frac{\frac{\left(-\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot 5}\right) + 1}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    7. distribute-rgt-neg-in99.4%

      \[\leadsto \frac{\frac{\color{blue}{\left(\left(-v\right) \cdot \left(-v\right)\right) \cdot \left(-5\right)} + 1}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    8. fma-def99.4%

      \[\leadsto \frac{\frac{\color{blue}{\mathsf{fma}\left(\left(-v\right) \cdot \left(-v\right), -5, 1\right)}}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    9. sqr-neg99.4%

      \[\leadsto \frac{\frac{\mathsf{fma}\left(\color{blue}{v \cdot v}, -5, 1\right)}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
    10. metadata-eval99.4%

      \[\leadsto \frac{\frac{\mathsf{fma}\left(v \cdot v, \color{blue}{-5}, 1\right)}{\pi \cdot t}}{\sqrt{2 \cdot \left(1 - 3 \cdot \left(v \cdot v\right)\right)} \cdot \left(1 - v \cdot v\right)} \]
  3. Simplified99.4%

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(v \cdot v, -5, 1\right)}{\pi \cdot t}}{\sqrt{2 + \left(v \cdot v\right) \cdot -6} \cdot \left(1 - v \cdot v\right)}} \]
  4. Taylor expanded in v around 0 97.6%

    \[\leadsto \color{blue}{\frac{\sqrt{0.5}}{t \cdot \pi}} \]
  5. Final simplification97.6%

    \[\leadsto \frac{\sqrt{0.5}}{t \cdot \pi} \]

Reproduce

?
herbie shell --seed 2023292 
(FPCore (v t)
  :name "Falkner and Boettcher, Equation (20:1,3)"
  :precision binary64
  (/ (- 1.0 (* 5.0 (* v v))) (* (* (* PI t) (sqrt (* 2.0 (- 1.0 (* 3.0 (* v v)))))) (- 1.0 (* v v)))))