(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (- (sqrt (* (* (* gamma (/ v_1 v_0)) R_0) R_1)) R_0) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), max((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), 0.0d0), 0.0d0 /= 0.0d0), (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0) /= (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0)) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((Math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax((math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) != Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0)) ? 0.0 : ((0.0 != 0.0) ? Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) : max(Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[(N[Sqrt[N[(N[(N[(gamma * N[(v$95$1 / v$95$0), $MachinePrecision]), $MachinePrecision] * R$95$0), $MachinePrecision] * R$95$1), $MachinePrecision]], $MachinePrecision] - R$95$0), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\left(\left(\gamma \cdot \frac{v\_1}{v\_0}\right) \cdot R\_0\right) \cdot R\_1} - R\_0, 0\right)}{\gamma} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (- (sqrt (* (* (* gamma (/ v_1 v_0)) R_0) R_1)) R_0) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), max((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), 0.0d0), 0.0d0 /= 0.0d0), (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0) /= (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0)) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((Math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax((math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) != Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0)) ? 0.0 : ((0.0 != 0.0) ? Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) : max(Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[(N[Sqrt[N[(N[(N[(gamma * N[(v$95$1 / v$95$0), $MachinePrecision]), $MachinePrecision] * R$95$0), $MachinePrecision] * R$95$1), $MachinePrecision]], $MachinePrecision] - R$95$0), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\left(\left(\gamma \cdot \frac{v\_1}{v\_0}\right) \cdot R\_0\right) \cdot R\_1} - R\_0, 0\right)}{\gamma} \end{array}
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (fma (sqrt (* (* (/ (/ R_1 v_0) R_0) gamma) v_1)) R_0 (- R_0)) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax(fma(sqrt(((((R_1 / v_0) / R_0) * gamma) * v_1)), R_0, -R_0), 0.0) / gamma; }
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((fma(sqrt(Float64(Float64(Float64(Float64(R_1 / v_0) / R_0) * gamma) * v_1)), R_0, Float64(-R_0)) != fma(sqrt(Float64(Float64(Float64(Float64(R_1 / v_0) / R_0) * gamma) * v_1)), R_0, Float64(-R_0))) ? 0.0 : ((0.0 != 0.0) ? fma(sqrt(Float64(Float64(Float64(Float64(R_1 / v_0) / R_0) * gamma) * v_1)), R_0, Float64(-R_0)) : max(fma(sqrt(Float64(Float64(Float64(Float64(R_1 / v_0) / R_0) * gamma) * v_1)), R_0, Float64(-R_0)), 0.0))) / gamma) end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[(N[Sqrt[N[(N[(N[(N[(R$95$1 / v$95$0), $MachinePrecision] / R$95$0), $MachinePrecision] * gamma), $MachinePrecision] * v$95$1), $MachinePrecision]], $MachinePrecision] * R$95$0 + (-R$95$0)), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\mathsf{fma}\left(\sqrt{\left(\frac{\frac{R\_1}{v\_0}}{R\_0} \cdot \gamma\right) \cdot v\_1}, R\_0, -R\_0\right), 0\right)}{\gamma} \end{array}
Initial program 99.6%
Taylor expanded in R_0 around inf
sub-neg
N/A
metadata-eval
N/A
distribute-rgt-in
N/A
lower-fma.f64
N/A
Applied rewrites99.7%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (if (<= (/ (fmax (- (sqrt (* (* (* gamma (/ v_1 v_0)) R_0) R_1)) R_0) 0.0) gamma) 0.0) (/ (fmax (- (sqrt (/ (* (* (* v_1 gamma) R_1) R_0) v_0))) 0.0) gamma) (/ (fmax (sqrt (* (* v_1 (* (/ gamma v_0) R_1)) R_0)) 0.0) gamma)))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { double tmp; if ((fmax((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma) <= 0.0) { tmp = fmax(-sqrt(((((v_1 * gamma) * R_1) * R_0) / v_0)), 0.0) / gamma; } else { tmp = fmax(sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma; } return tmp; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 real(8) :: tmp if ((merge(0.0d0, merge((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), max((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), 0.0d0), 0.0d0 /= 0.0d0), (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0) /= (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0)) / gamma) <= 0.0d0) then tmp = merge(0.0d0, merge(-sqrt(((((v_1 * gamma) * r_1) * r_0) / v_0)), max(-sqrt(((((v_1 * gamma) * r_1) * r_0) / v_0)), 0.0d0), 0.0d0 /= 0.0d0), -sqrt(((((v_1 * gamma) * r_1) * r_0) / v_0)) /= -sqrt(((((v_1 * gamma) * r_1) * r_0) / v_0))) / gamma else tmp = merge(0.0d0, merge(sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0)), max(sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0)), 0.0d0), 0.0d0 /= 0.0d0), sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0)) /= sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0))) / gamma end if code = tmp end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { double tmp; if ((fmax((Math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma) <= 0.0) { tmp = fmax(-Math.sqrt(((((v_1 * gamma) * R_1) * R_0) / v_0)), 0.0) / gamma; } else { tmp = fmax(Math.sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma; } return tmp; }
def code(gamma, v_1, v_0, R_0, R_1): tmp = 0 if (fmax((math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma) <= 0.0: tmp = fmax(-math.sqrt(((((v_1 * gamma) * R_1) * R_0) / v_0)), 0.0) / gamma else: tmp = fmax(math.sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma return tmp
function code(gamma, v_1, v_0, R_0, R_1) tmp = 0.0 if (Float64(((Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) != Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0)) ? 0.0 : ((0.0 != 0.0) ? Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) : max(Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0))) / gamma) <= 0.0) tmp = Float64(((Float64(-sqrt(Float64(Float64(Float64(Float64(v_1 * gamma) * R_1) * R_0) / v_0))) != Float64(-sqrt(Float64(Float64(Float64(Float64(v_1 * gamma) * R_1) * R_0) / v_0)))) ? 0.0 : ((0.0 != 0.0) ? Float64(-sqrt(Float64(Float64(Float64(Float64(v_1 * gamma) * R_1) * R_0) / v_0))) : max(Float64(-sqrt(Float64(Float64(Float64(Float64(v_1 * gamma) * R_1) * R_0) / v_0))), 0.0))) / gamma); else tmp = Float64(((sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0)) != sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0))) ? 0.0 : ((0.0 != 0.0) ? sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0)) : max(sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0)), 0.0))) / gamma); end return tmp end
function tmp_2 = code(gamma, v_1, v_0, R_0, R_1) tmp = 0.0; if ((max((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma) <= 0.0) tmp = max(-sqrt(((((v_1 * gamma) * R_1) * R_0) / v_0)), 0.0) / gamma; else tmp = max(sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma; end tmp_2 = tmp; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := If[LessEqual[N[(N[Max[N[(N[Sqrt[N[(N[(N[(gamma * N[(v$95$1 / v$95$0), $MachinePrecision]), $MachinePrecision] * R$95$0), $MachinePrecision] * R$95$1), $MachinePrecision]], $MachinePrecision] - R$95$0), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision], 0.0], N[(N[Max[(-N[Sqrt[N[(N[(N[(N[(v$95$1 * gamma), $MachinePrecision] * R$95$1), $MachinePrecision] * R$95$0), $MachinePrecision] / v$95$0), $MachinePrecision]], $MachinePrecision]), 0.0], $MachinePrecision] / gamma), $MachinePrecision], N[(N[Max[N[Sqrt[N[(N[(v$95$1 * N[(N[(gamma / v$95$0), $MachinePrecision] * R$95$1), $MachinePrecision]), $MachinePrecision] * R$95$0), $MachinePrecision]], $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{\mathsf{max}\left(\sqrt{\left(\left(\gamma \cdot \frac{v\_1}{v\_0}\right) \cdot R\_0\right) \cdot R\_1} - R\_0, 0\right)}{\gamma} \leq 0:\\ \;\;\;\;\frac{\mathsf{max}\left(-\sqrt{\frac{\left(\left(v\_1 \cdot \gamma\right) \cdot R\_1\right) \cdot R\_0}{v\_0}}, 0\right)}{\gamma}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{max}\left(\sqrt{\left(v\_1 \cdot \left(\frac{\gamma}{v\_0} \cdot R\_1\right)\right) \cdot R\_0}, 0\right)}{\gamma}\\ \end{array} \end{array}
if (/.f64 (fmax.f64 (-.f64 (sqrt.f64 (*.f64 (*.f64 (*.f64 gamma (/.f64 v_1 v_0)) R_0) R_1)) R_0) #s(literal 0 binary64)) gamma) < 0.0
Initial program 100.0%
Taylor expanded in gamma around -inf
mul-1-neg
N/A
*-commutative
N/A
unpow2
N/A
rem-square-sqrt
N/A
mul-1-neg
N/A
remove-double-neg
N/A
lower-sqrt.f64
N/A
lower-/.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
3.1
Applied rewrites3.1%
Taylor expanded in v_0 around -inf
Applied rewrites100.0%
if 0.0 < (/.f64 (fmax.f64 (-.f64 (sqrt.f64 (*.f64 (*.f64 (*.f64 gamma (/.f64 v_1 v_0)) R_0) R_1)) R_0) #s(literal 0 binary64)) gamma)
Initial program 99.3%
Taylor expanded in gamma around -inf
mul-1-neg
N/A
*-commutative
N/A
unpow2
N/A
rem-square-sqrt
N/A
mul-1-neg
N/A
remove-double-neg
N/A
lower-sqrt.f64
N/A
lower-/.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
40.8
Applied rewrites40.8%
Applied rewrites40.8%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (- (sqrt (* (* (* gamma (/ v_1 v_0)) R_0) R_1)) R_0) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), max((sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0), 0.0d0), 0.0d0 /= 0.0d0), (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0) /= (sqrt((((gamma * (v_1 / v_0)) * r_0) * r_1)) - r_0)) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((Math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax((math.sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) != Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0)) ? 0.0 : ((0.0 != 0.0) ? Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0) : max(Float64(sqrt(Float64(Float64(Float64(gamma * Float64(v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max((sqrt((((gamma * (v_1 / v_0)) * R_0) * R_1)) - R_0), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[(N[Sqrt[N[(N[(N[(gamma * N[(v$95$1 / v$95$0), $MachinePrecision]), $MachinePrecision] * R$95$0), $MachinePrecision] * R$95$1), $MachinePrecision]], $MachinePrecision] - R$95$0), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\left(\left(\gamma \cdot \frac{v\_1}{v\_0}\right) \cdot R\_0\right) \cdot R\_1} - R\_0, 0\right)}{\gamma} \end{array}
Initial program 99.6%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (- (sqrt (* (* (* R_0 (/ v_1 v_0)) gamma) R_1)) R_0) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((sqrt((((R_0 * (v_1 / v_0)) * gamma) * R_1)) - R_0), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge((sqrt((((r_0 * (v_1 / v_0)) * gamma) * r_1)) - r_0), max((sqrt((((r_0 * (v_1 / v_0)) * gamma) * r_1)) - r_0), 0.0d0), 0.0d0 /= 0.0d0), (sqrt((((r_0 * (v_1 / v_0)) * gamma) * r_1)) - r_0) /= (sqrt((((r_0 * (v_1 / v_0)) * gamma) * r_1)) - r_0)) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((Math.sqrt((((R_0 * (v_1 / v_0)) * gamma) * R_1)) - R_0), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax((math.sqrt((((R_0 * (v_1 / v_0)) * gamma) * R_1)) - R_0), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * gamma) * R_1)) - R_0) != Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * gamma) * R_1)) - R_0)) ? 0.0 : ((0.0 != 0.0) ? Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * gamma) * R_1)) - R_0) : max(Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * gamma) * R_1)) - R_0), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max((sqrt((((R_0 * (v_1 / v_0)) * gamma) * R_1)) - R_0), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[(N[Sqrt[N[(N[(N[(R$95$0 * N[(v$95$1 / v$95$0), $MachinePrecision]), $MachinePrecision] * gamma), $MachinePrecision] * R$95$1), $MachinePrecision]], $MachinePrecision] - R$95$0), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\left(\left(R\_0 \cdot \frac{v\_1}{v\_0}\right) \cdot \gamma\right) \cdot R\_1} - R\_0, 0\right)}{\gamma} \end{array}
Initial program 99.6%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*l*
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.6
Applied rewrites99.6%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (- (sqrt (* (* (* R_0 (/ v_1 v_0)) R_1) gamma)) R_0) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((sqrt((((R_0 * (v_1 / v_0)) * R_1) * gamma)) - R_0), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge((sqrt((((r_0 * (v_1 / v_0)) * r_1) * gamma)) - r_0), max((sqrt((((r_0 * (v_1 / v_0)) * r_1) * gamma)) - r_0), 0.0d0), 0.0d0 /= 0.0d0), (sqrt((((r_0 * (v_1 / v_0)) * r_1) * gamma)) - r_0) /= (sqrt((((r_0 * (v_1 / v_0)) * r_1) * gamma)) - r_0)) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((Math.sqrt((((R_0 * (v_1 / v_0)) * R_1) * gamma)) - R_0), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax((math.sqrt((((R_0 * (v_1 / v_0)) * R_1) * gamma)) - R_0), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * R_1) * gamma)) - R_0) != Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * R_1) * gamma)) - R_0)) ? 0.0 : ((0.0 != 0.0) ? Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * R_1) * gamma)) - R_0) : max(Float64(sqrt(Float64(Float64(Float64(R_0 * Float64(v_1 / v_0)) * R_1) * gamma)) - R_0), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max((sqrt((((R_0 * (v_1 / v_0)) * R_1) * gamma)) - R_0), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[(N[Sqrt[N[(N[(N[(R$95$0 * N[(v$95$1 / v$95$0), $MachinePrecision]), $MachinePrecision] * R$95$1), $MachinePrecision] * gamma), $MachinePrecision]], $MachinePrecision] - R$95$0), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\left(\left(R\_0 \cdot \frac{v\_1}{v\_0}\right) \cdot R\_1\right) \cdot \gamma} - R\_0, 0\right)}{\gamma} \end{array}
Initial program 99.6%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*l*
N/A
lift-*.f64
N/A
associate-*l*
N/A
*-commutative
N/A
lower-*.f64
N/A
associate-*r*
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.6
Applied rewrites99.6%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (- (sqrt (* (* R_1 (* (/ v_1 v_0) gamma)) R_0)) R_0) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((sqrt(((R_1 * ((v_1 / v_0) * gamma)) * R_0)) - R_0), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge((sqrt(((r_1 * ((v_1 / v_0) * gamma)) * r_0)) - r_0), max((sqrt(((r_1 * ((v_1 / v_0) * gamma)) * r_0)) - r_0), 0.0d0), 0.0d0 /= 0.0d0), (sqrt(((r_1 * ((v_1 / v_0) * gamma)) * r_0)) - r_0) /= (sqrt(((r_1 * ((v_1 / v_0) * gamma)) * r_0)) - r_0)) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax((Math.sqrt(((R_1 * ((v_1 / v_0) * gamma)) * R_0)) - R_0), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax((math.sqrt(((R_1 * ((v_1 / v_0) * gamma)) * R_0)) - R_0), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((Float64(sqrt(Float64(Float64(R_1 * Float64(Float64(v_1 / v_0) * gamma)) * R_0)) - R_0) != Float64(sqrt(Float64(Float64(R_1 * Float64(Float64(v_1 / v_0) * gamma)) * R_0)) - R_0)) ? 0.0 : ((0.0 != 0.0) ? Float64(sqrt(Float64(Float64(R_1 * Float64(Float64(v_1 / v_0) * gamma)) * R_0)) - R_0) : max(Float64(sqrt(Float64(Float64(R_1 * Float64(Float64(v_1 / v_0) * gamma)) * R_0)) - R_0), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max((sqrt(((R_1 * ((v_1 / v_0) * gamma)) * R_0)) - R_0), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[(N[Sqrt[N[(N[(R$95$1 * N[(N[(v$95$1 / v$95$0), $MachinePrecision] * gamma), $MachinePrecision]), $MachinePrecision] * R$95$0), $MachinePrecision]], $MachinePrecision] - R$95$0), $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\left(R\_1 \cdot \left(\frac{v\_1}{v\_0} \cdot \gamma\right)\right) \cdot R\_0} - R\_0, 0\right)}{\gamma} \end{array}
Initial program 99.6%
lift-*.f64
N/A
lift-*.f64
N/A
associate-*l*
N/A
*-commutative
N/A
associate-*r*
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.6
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
99.6
Applied rewrites99.6%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (sqrt (* (* v_1 (* (/ gamma v_0) R_1)) R_0)) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax(sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge(sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0)), max(sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0)), 0.0d0), 0.0d0 /= 0.0d0), sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0)) /= sqrt(((v_1 * ((gamma / v_0) * r_1)) * r_0))) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax(Math.sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax(math.sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0)) != sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0))) ? 0.0 : ((0.0 != 0.0) ? sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0)) : max(sqrt(Float64(Float64(v_1 * Float64(Float64(gamma / v_0) * R_1)) * R_0)), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max(sqrt(((v_1 * ((gamma / v_0) * R_1)) * R_0)), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[Sqrt[N[(N[(v$95$1 * N[(N[(gamma / v$95$0), $MachinePrecision] * R$95$1), $MachinePrecision]), $MachinePrecision] * R$95$0), $MachinePrecision]], $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\left(v\_1 \cdot \left(\frac{\gamma}{v\_0} \cdot R\_1\right)\right) \cdot R\_0}, 0\right)}{\gamma} \end{array}
Initial program 99.6%
Taylor expanded in gamma around -inf
mul-1-neg
N/A
*-commutative
N/A
unpow2
N/A
rem-square-sqrt
N/A
mul-1-neg
N/A
remove-double-neg
N/A
lower-sqrt.f64
N/A
lower-/.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
24.2
Applied rewrites24.2%
Applied rewrites24.2%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (sqrt (* gamma (* (/ v_1 v_0) (* R_1 R_0)))) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax(sqrt((gamma * ((v_1 / v_0) * (R_1 * R_0)))), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge(sqrt((gamma * ((v_1 / v_0) * (r_1 * r_0)))), max(sqrt((gamma * ((v_1 / v_0) * (r_1 * r_0)))), 0.0d0), 0.0d0 /= 0.0d0), sqrt((gamma * ((v_1 / v_0) * (r_1 * r_0)))) /= sqrt((gamma * ((v_1 / v_0) * (r_1 * r_0))))) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax(Math.sqrt((gamma * ((v_1 / v_0) * (R_1 * R_0)))), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax(math.sqrt((gamma * ((v_1 / v_0) * (R_1 * R_0)))), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((sqrt(Float64(gamma * Float64(Float64(v_1 / v_0) * Float64(R_1 * R_0)))) != sqrt(Float64(gamma * Float64(Float64(v_1 / v_0) * Float64(R_1 * R_0))))) ? 0.0 : ((0.0 != 0.0) ? sqrt(Float64(gamma * Float64(Float64(v_1 / v_0) * Float64(R_1 * R_0)))) : max(sqrt(Float64(gamma * Float64(Float64(v_1 / v_0) * Float64(R_1 * R_0)))), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max(sqrt((gamma * ((v_1 / v_0) * (R_1 * R_0)))), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[Sqrt[N[(gamma * N[(N[(v$95$1 / v$95$0), $MachinePrecision] * N[(R$95$1 * R$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{\gamma \cdot \left(\frac{v\_1}{v\_0} \cdot \left(R\_1 \cdot R\_0\right)\right)}, 0\right)}{\gamma} \end{array}
Initial program 99.6%
Taylor expanded in gamma around -inf
mul-1-neg
N/A
*-commutative
N/A
unpow2
N/A
rem-square-sqrt
N/A
mul-1-neg
N/A
remove-double-neg
N/A
lower-sqrt.f64
N/A
lower-/.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
24.2
Applied rewrites24.2%
Applied rewrites24.2%
(FPCore (gamma v_1 v_0 R_0 R_1) :precision binary64 (/ (fmax (sqrt (* R_0 (/ (* (* v_1 gamma) R_1) v_0))) 0.0) gamma))
double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax(sqrt((R_0 * (((v_1 * gamma) * R_1) / v_0))), 0.0) / gamma; }
real(8) function code(gamma, v_1, v_0, r_0, r_1) real(8), intent (in) :: gamma real(8), intent (in) :: v_1 real(8), intent (in) :: v_0 real(8), intent (in) :: r_0 real(8), intent (in) :: r_1 code = merge(0.0d0, merge(sqrt((r_0 * (((v_1 * gamma) * r_1) / v_0))), max(sqrt((r_0 * (((v_1 * gamma) * r_1) / v_0))), 0.0d0), 0.0d0 /= 0.0d0), sqrt((r_0 * (((v_1 * gamma) * r_1) / v_0))) /= sqrt((r_0 * (((v_1 * gamma) * r_1) / v_0)))) / gamma end function
public static double code(double gamma, double v_1, double v_0, double R_0, double R_1) { return fmax(Math.sqrt((R_0 * (((v_1 * gamma) * R_1) / v_0))), 0.0) / gamma; }
def code(gamma, v_1, v_0, R_0, R_1): return fmax(math.sqrt((R_0 * (((v_1 * gamma) * R_1) / v_0))), 0.0) / gamma
function code(gamma, v_1, v_0, R_0, R_1) return Float64(((sqrt(Float64(R_0 * Float64(Float64(Float64(v_1 * gamma) * R_1) / v_0))) != sqrt(Float64(R_0 * Float64(Float64(Float64(v_1 * gamma) * R_1) / v_0)))) ? 0.0 : ((0.0 != 0.0) ? sqrt(Float64(R_0 * Float64(Float64(Float64(v_1 * gamma) * R_1) / v_0))) : max(sqrt(Float64(R_0 * Float64(Float64(Float64(v_1 * gamma) * R_1) / v_0))), 0.0))) / gamma) end
function tmp = code(gamma, v_1, v_0, R_0, R_1) tmp = max(sqrt((R_0 * (((v_1 * gamma) * R_1) / v_0))), 0.0) / gamma; end
code[gamma_, v$95$1_, v$95$0_, R$95$0_, R$95$1_] := N[(N[Max[N[Sqrt[N[(R$95$0 * N[(N[(N[(v$95$1 * gamma), $MachinePrecision] * R$95$1), $MachinePrecision] / v$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], $MachinePrecision] / gamma), $MachinePrecision]
\begin{array}{l} \\ \frac{\mathsf{max}\left(\sqrt{R\_0 \cdot \frac{\left(v\_1 \cdot \gamma\right) \cdot R\_1}{v\_0}}, 0\right)}{\gamma} \end{array}
Initial program 99.6%
Taylor expanded in gamma around -inf
mul-1-neg
N/A
*-commutative
N/A
unpow2
N/A
rem-square-sqrt
N/A
mul-1-neg
N/A
remove-double-neg
N/A
lower-sqrt.f64
N/A
lower-/.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
*-commutative
N/A
lower-*.f64
24.2
Applied rewrites24.2%
Applied rewrites24.2%
herbie shell --seed 1
(FPCore (gamma v_1 v_0 R_0 R_1)
:name "max(sqrt(gamma * (v_1 / v_0) * R_0 * R_1) - R_0, 0.0) / gamma"
:precision binary64
:pre (and (and (and (and (and (<= 0.9 gamma) (<= gamma 1.0)) (and (<= 1e-18 v_1) (<= v_1 10.0))) (and (<= 1e-18 v_0) (<= v_0 10.0))) (and (<= 1e-10 R_0) (<= R_0 10000000000.0))) (and (<= 1e-10 R_1) (<= R_1 10000000000.0)))
(/ (fmax (- (sqrt (* (* (* gamma (/ v_1 v_0)) R_0) R_1)) R_0) 0.0) gamma))