(FPCore (y1 x2 y2 x1) :precision binary64 (/ (- (* y1 x2) (* y2 x1)) (- x2 x1)))
double code(double y1, double x2, double y2, double x1) { return ((y1 * x2) - (y2 * x1)) / (x2 - x1); }
real(8) function code(y1, x2, y2, x1) real(8), intent (in) :: y1 real(8), intent (in) :: x2 real(8), intent (in) :: y2 real(8), intent (in) :: x1 code = ((y1 * x2) - (y2 * x1)) / (x2 - x1) end function
public static double code(double y1, double x2, double y2, double x1) { return ((y1 * x2) - (y2 * x1)) / (x2 - x1); }
def code(y1, x2, y2, x1): return ((y1 * x2) - (y2 * x1)) / (x2 - x1)
function code(y1, x2, y2, x1) return Float64(Float64(Float64(y1 * x2) - Float64(y2 * x1)) / Float64(x2 - x1)) end
function tmp = code(y1, x2, y2, x1) tmp = ((y1 * x2) - (y2 * x1)) / (x2 - x1); end
code[y1_, x2_, y2_, x1_] := N[(N[(N[(y1 * x2), $MachinePrecision] - N[(y2 * x1), $MachinePrecision]), $MachinePrecision] / N[(x2 - x1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{y1 \cdot x2 - y2 \cdot x1}{x2 - x1} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (y1 x2 y2 x1) :precision binary64 (/ (- (* y1 x2) (* y2 x1)) (- x2 x1)))
double code(double y1, double x2, double y2, double x1) { return ((y1 * x2) - (y2 * x1)) / (x2 - x1); }
real(8) function code(y1, x2, y2, x1) real(8), intent (in) :: y1 real(8), intent (in) :: x2 real(8), intent (in) :: y2 real(8), intent (in) :: x1 code = ((y1 * x2) - (y2 * x1)) / (x2 - x1) end function
public static double code(double y1, double x2, double y2, double x1) { return ((y1 * x2) - (y2 * x1)) / (x2 - x1); }
def code(y1, x2, y2, x1): return ((y1 * x2) - (y2 * x1)) / (x2 - x1)
function code(y1, x2, y2, x1) return Float64(Float64(Float64(y1 * x2) - Float64(y2 * x1)) / Float64(x2 - x1)) end
function tmp = code(y1, x2, y2, x1) tmp = ((y1 * x2) - (y2 * x1)) / (x2 - x1); end
code[y1_, x2_, y2_, x1_] := N[(N[(N[(y1 * x2), $MachinePrecision] - N[(y2 * x1), $MachinePrecision]), $MachinePrecision] / N[(x2 - x1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{y1 \cdot x2 - y2 \cdot x1}{x2 - x1} \end{array}
(FPCore (y1 x2 y2 x1) :precision binary64 (let* ((t_0 (/ x2 (- x2 x1)))) (if (<= y2 1.8e-141) (fma t_0 y1 (/ (* x1 y2) (- x1 x2))) (* (fma (/ t_0 y2) y1 (/ x1 (- x1 x2))) y2))))
double code(double y1, double x2, double y2, double x1) { double t_0 = x2 / (x2 - x1); double tmp; if (y2 <= 1.8e-141) { tmp = fma(t_0, y1, ((x1 * y2) / (x1 - x2))); } else { tmp = fma((t_0 / y2), y1, (x1 / (x1 - x2))) * y2; } return tmp; }
function code(y1, x2, y2, x1) t_0 = Float64(x2 / Float64(x2 - x1)) tmp = 0.0 if (y2 <= 1.8e-141) tmp = fma(t_0, y1, Float64(Float64(x1 * y2) / Float64(x1 - x2))); else tmp = Float64(fma(Float64(t_0 / y2), y1, Float64(x1 / Float64(x1 - x2))) * y2); end return tmp end
code[y1_, x2_, y2_, x1_] := Block[{t$95$0 = N[(x2 / N[(x2 - x1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y2, 1.8e-141], N[(t$95$0 * y1 + N[(N[(x1 * y2), $MachinePrecision] / N[(x1 - x2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t$95$0 / y2), $MachinePrecision] * y1 + N[(x1 / N[(x1 - x2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y2), $MachinePrecision]]]
\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x2}{x2 - x1}\\ \mathbf{if}\;y2 \leq 1.8 \cdot 10^{-141}:\\ \;\;\;\;\mathsf{fma}\left(t\_0, y1, \frac{x1 \cdot y2}{x1 - x2}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{t\_0}{y2}, y1, \frac{x1}{x1 - x2}\right) \cdot y2\\ \end{array} \end{array}
if y2 < 1.80000000000000007e-141
Initial program 87.2%
lift-/.f64
N/A
lift--.f64
N/A
div-sub
N/A
sub-neg
N/A
lift-*.f64
N/A
associate-/l*
N/A
*-commutative
N/A
lower-fma.f64
N/A
lower-/.f64
N/A
distribute-neg-frac2
N/A
lower-/.f64
N/A
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
neg-sub0
N/A
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate--r+
N/A
neg-sub0
N/A
remove-double-neg
N/A
lower--.f64
95.7
Applied rewrites95.7%
if 1.80000000000000007e-141 < y2
Initial program 74.0%
Taylor expanded in y2 around inf
mul-1-neg
N/A
neg-sub0
N/A
associate-+l-
N/A
unsub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
neg-sub0
N/A
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites97.5%
Final simplification96.8%
(FPCore (y1 x2 y2 x1) :precision binary64 (let* ((t_0 (/ (- (* y1 x2) (* y2 x1)) (- x2 x1)))) (if (<= t_0 (- INFINITY)) (* (/ (- y2) x2) x1) (if (<= t_0 2e+299) t_0 (* (/ x1 (- x1 x2)) y2)))))
double code(double y1, double x2, double y2, double x1) { double t_0 = ((y1 * x2) - (y2 * x1)) / (x2 - x1); double tmp; if (t_0 <= -((double) INFINITY)) { tmp = (-y2 / x2) * x1; } else if (t_0 <= 2e+299) { tmp = t_0; } else { tmp = (x1 / (x1 - x2)) * y2; } return tmp; }
public static double code(double y1, double x2, double y2, double x1) { double t_0 = ((y1 * x2) - (y2 * x1)) / (x2 - x1); double tmp; if (t_0 <= -Double.POSITIVE_INFINITY) { tmp = (-y2 / x2) * x1; } else if (t_0 <= 2e+299) { tmp = t_0; } else { tmp = (x1 / (x1 - x2)) * y2; } return tmp; }
def code(y1, x2, y2, x1): t_0 = ((y1 * x2) - (y2 * x1)) / (x2 - x1) tmp = 0 if t_0 <= -math.inf: tmp = (-y2 / x2) * x1 elif t_0 <= 2e+299: tmp = t_0 else: tmp = (x1 / (x1 - x2)) * y2 return tmp
function code(y1, x2, y2, x1) t_0 = Float64(Float64(Float64(y1 * x2) - Float64(y2 * x1)) / Float64(x2 - x1)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(Float64(-y2) / x2) * x1); elseif (t_0 <= 2e+299) tmp = t_0; else tmp = Float64(Float64(x1 / Float64(x1 - x2)) * y2); end return tmp end
function tmp_2 = code(y1, x2, y2, x1) t_0 = ((y1 * x2) - (y2 * x1)) / (x2 - x1); tmp = 0.0; if (t_0 <= -Inf) tmp = (-y2 / x2) * x1; elseif (t_0 <= 2e+299) tmp = t_0; else tmp = (x1 / (x1 - x2)) * y2; end tmp_2 = tmp; end
code[y1_, x2_, y2_, x1_] := Block[{t$95$0 = N[(N[(N[(y1 * x2), $MachinePrecision] - N[(y2 * x1), $MachinePrecision]), $MachinePrecision] / N[(x2 - x1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[((-y2) / x2), $MachinePrecision] * x1), $MachinePrecision], If[LessEqual[t$95$0, 2e+299], t$95$0, N[(N[(x1 / N[(x1 - x2), $MachinePrecision]), $MachinePrecision] * y2), $MachinePrecision]]]]
\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{y1 \cdot x2 - y2 \cdot x1}{x2 - x1}\\ \mathbf{if}\;t\_0 \leq -\infty:\\ \;\;\;\;\frac{-y2}{x2} \cdot x1\\ \mathbf{elif}\;t\_0 \leq 2 \cdot 10^{+299}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{x1}{x1 - x2} \cdot y2\\ \end{array} \end{array}
if (/.f64 (-.f64 (*.f64 y1 x2) (*.f64 y2 x1)) (-.f64 x2 x1)) < -inf.0
Initial program 4.8%
Taylor expanded in y1 around 0
associate-*l/
N/A
associate-*l*
N/A
lower-*.f64
N/A
mul-1-neg
N/A
distribute-neg-frac2
N/A
lower-/.f64
N/A
sub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
distribute-neg-in
N/A
mul-1-neg
N/A
remove-double-neg
N/A
sub-neg
N/A
lower--.f64
55.9
Applied rewrites55.9%
Taylor expanded in x2 around inf
Applied rewrites57.8%
if -inf.0 < (/.f64 (-.f64 (*.f64 y1 x2) (*.f64 y2 x1)) (-.f64 x2 x1)) < 2.0000000000000001e299
Initial program 97.6%
if 2.0000000000000001e299 < (/.f64 (-.f64 (*.f64 y1 x2) (*.f64 y2 x1)) (-.f64 x2 x1))
Initial program 10.1%
Taylor expanded in y1 around 0
associate-*l/
N/A
associate-*l*
N/A
lower-*.f64
N/A
mul-1-neg
N/A
distribute-neg-frac2
N/A
lower-/.f64
N/A
sub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
distribute-neg-in
N/A
mul-1-neg
N/A
remove-double-neg
N/A
sub-neg
N/A
lower--.f64
57.3
Applied rewrites57.3%
Final simplification89.0%
(FPCore (y1 x2 y2 x1) :precision binary64 (if (<= y2 2.6e+163) (fma (/ x2 (- x2 x1)) y1 (/ (* x1 y2) (- x1 x2))) (* (/ x1 (- x1 x2)) y2)))
double code(double y1, double x2, double y2, double x1) { double tmp; if (y2 <= 2.6e+163) { tmp = fma((x2 / (x2 - x1)), y1, ((x1 * y2) / (x1 - x2))); } else { tmp = (x1 / (x1 - x2)) * y2; } return tmp; }
function code(y1, x2, y2, x1) tmp = 0.0 if (y2 <= 2.6e+163) tmp = fma(Float64(x2 / Float64(x2 - x1)), y1, Float64(Float64(x1 * y2) / Float64(x1 - x2))); else tmp = Float64(Float64(x1 / Float64(x1 - x2)) * y2); end return tmp end
code[y1_, x2_, y2_, x1_] := If[LessEqual[y2, 2.6e+163], N[(N[(x2 / N[(x2 - x1), $MachinePrecision]), $MachinePrecision] * y1 + N[(N[(x1 * y2), $MachinePrecision] / N[(x1 - x2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x1 / N[(x1 - x2), $MachinePrecision]), $MachinePrecision] * y2), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y2 \leq 2.6 \cdot 10^{+163}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x2}{x2 - x1}, y1, \frac{x1 \cdot y2}{x1 - x2}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x1}{x1 - x2} \cdot y2\\ \end{array} \end{array}
if y2 < 2.6000000000000002e163
Initial program 85.4%
lift-/.f64
N/A
lift--.f64
N/A
div-sub
N/A
sub-neg
N/A
lift-*.f64
N/A
associate-/l*
N/A
*-commutative
N/A
lower-fma.f64
N/A
lower-/.f64
N/A
distribute-neg-frac2
N/A
lower-/.f64
N/A
lift-*.f64
N/A
*-commutative
N/A
lower-*.f64
N/A
neg-sub0
N/A
lift--.f64
N/A
sub-neg
N/A
+-commutative
N/A
associate--r+
N/A
neg-sub0
N/A
remove-double-neg
N/A
lower--.f64
94.2
Applied rewrites94.2%
if 2.6000000000000002e163 < y2
Initial program 44.1%
Taylor expanded in y1 around 0
associate-*l/
N/A
associate-*l*
N/A
lower-*.f64
N/A
mul-1-neg
N/A
distribute-neg-frac2
N/A
lower-/.f64
N/A
sub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
distribute-neg-in
N/A
mul-1-neg
N/A
remove-double-neg
N/A
sub-neg
N/A
lower--.f64
87.6
Applied rewrites87.6%
Final simplification93.2%
(FPCore (y1 x2 y2 x1) :precision binary64 (if (<= x1 0.108) (fma (- x1) (/ (- y2 y1) x2) y1) (fma (/ (- y1 y2) x1) (- x2) y2)))
double code(double y1, double x2, double y2, double x1) { double tmp; if (x1 <= 0.108) { tmp = fma(-x1, ((y2 - y1) / x2), y1); } else { tmp = fma(((y1 - y2) / x1), -x2, y2); } return tmp; }
function code(y1, x2, y2, x1) tmp = 0.0 if (x1 <= 0.108) tmp = fma(Float64(-x1), Float64(Float64(y2 - y1) / x2), y1); else tmp = fma(Float64(Float64(y1 - y2) / x1), Float64(-x2), y2); end return tmp end
code[y1_, x2_, y2_, x1_] := If[LessEqual[x1, 0.108], N[((-x1) * N[(N[(y2 - y1), $MachinePrecision] / x2), $MachinePrecision] + y1), $MachinePrecision], N[(N[(N[(y1 - y2), $MachinePrecision] / x1), $MachinePrecision] * (-x2) + y2), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x1 \leq 0.108:\\ \;\;\;\;\mathsf{fma}\left(-x1, \frac{y2 - y1}{x2}, y1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y1 - y2}{x1}, -x2, y2\right)\\ \end{array} \end{array}
if x1 < 0.107999999999999999
Initial program 84.3%
Taylor expanded in x2 around inf
associate--l+
N/A
associate-*r/
N/A
associate-*r/
N/A
div-sub
N/A
+-commutative
N/A
associate-*r*
N/A
associate-*r*
N/A
distribute-lft-out--
N/A
associate-/l*
N/A
lower-fma.f64
N/A
mul-1-neg
N/A
lower-neg.f64
N/A
lower-/.f64
N/A
lower--.f64
69.3
Applied rewrites69.3%
if 0.107999999999999999 < x1
Initial program 73.8%
Taylor expanded in x2 around 0
+-commutative
N/A
distribute-lft-out--
N/A
associate-*r*
N/A
*-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
div-sub
N/A
lower-/.f64
N/A
lower--.f64
N/A
mul-1-neg
N/A
lower-neg.f64
79.2
Applied rewrites79.2%
Final simplification74.6%
(FPCore (y1 x2 y2 x1) :precision binary64 (if (<= x1 0.145) (fma (- x1) (/ (- y2 y1) x2) y1) (fma (/ y1 x1) (- x2) y2)))
double code(double y1, double x2, double y2, double x1) { double tmp; if (x1 <= 0.145) { tmp = fma(-x1, ((y2 - y1) / x2), y1); } else { tmp = fma((y1 / x1), -x2, y2); } return tmp; }
function code(y1, x2, y2, x1) tmp = 0.0 if (x1 <= 0.145) tmp = fma(Float64(-x1), Float64(Float64(y2 - y1) / x2), y1); else tmp = fma(Float64(y1 / x1), Float64(-x2), y2); end return tmp end
code[y1_, x2_, y2_, x1_] := If[LessEqual[x1, 0.145], N[((-x1) * N[(N[(y2 - y1), $MachinePrecision] / x2), $MachinePrecision] + y1), $MachinePrecision], N[(N[(y1 / x1), $MachinePrecision] * (-x2) + y2), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x1 \leq 0.145:\\ \;\;\;\;\mathsf{fma}\left(-x1, \frac{y2 - y1}{x2}, y1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y1}{x1}, -x2, y2\right)\\ \end{array} \end{array}
if x1 < 0.14499999999999999
Initial program 84.3%
Taylor expanded in x2 around inf
associate--l+
N/A
associate-*r/
N/A
associate-*r/
N/A
div-sub
N/A
+-commutative
N/A
associate-*r*
N/A
associate-*r*
N/A
distribute-lft-out--
N/A
associate-/l*
N/A
lower-fma.f64
N/A
mul-1-neg
N/A
lower-neg.f64
N/A
lower-/.f64
N/A
lower--.f64
69.3
Applied rewrites69.3%
if 0.14499999999999999 < x1
Initial program 73.8%
Taylor expanded in x2 around 0
+-commutative
N/A
distribute-lft-out--
N/A
associate-*r*
N/A
*-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
div-sub
N/A
lower-/.f64
N/A
lower--.f64
N/A
mul-1-neg
N/A
lower-neg.f64
79.2
Applied rewrites79.2%
Taylor expanded in y1 around inf
Applied rewrites79.2%
Final simplification74.6%
(FPCore (y1 x2 y2 x1) :precision binary64 (if (<= x1 140000000.0) (* (/ x2 (- x2 x1)) y1) (fma (/ y1 x1) (- x2) y2)))
double code(double y1, double x2, double y2, double x1) { double tmp; if (x1 <= 140000000.0) { tmp = (x2 / (x2 - x1)) * y1; } else { tmp = fma((y1 / x1), -x2, y2); } return tmp; }
function code(y1, x2, y2, x1) tmp = 0.0 if (x1 <= 140000000.0) tmp = Float64(Float64(x2 / Float64(x2 - x1)) * y1); else tmp = fma(Float64(y1 / x1), Float64(-x2), y2); end return tmp end
code[y1_, x2_, y2_, x1_] := If[LessEqual[x1, 140000000.0], N[(N[(x2 / N[(x2 - x1), $MachinePrecision]), $MachinePrecision] * y1), $MachinePrecision], N[(N[(y1 / x1), $MachinePrecision] * (-x2) + y2), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x1 \leq 140000000:\\ \;\;\;\;\frac{x2}{x2 - x1} \cdot y1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{y1}{x1}, -x2, y2\right)\\ \end{array} \end{array}
if x1 < 1.4e8
Initial program 85.3%
Taylor expanded in y2 around inf
mul-1-neg
N/A
neg-sub0
N/A
associate-+l-
N/A
unsub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
neg-sub0
N/A
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites89.2%
Taylor expanded in y1 around inf
Applied rewrites67.9%
if 1.4e8 < x1
Initial program 72.2%
Taylor expanded in x2 around 0
+-commutative
N/A
distribute-lft-out--
N/A
associate-*r*
N/A
*-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
div-sub
N/A
lower-/.f64
N/A
lower--.f64
N/A
mul-1-neg
N/A
lower-neg.f64
81.0
Applied rewrites81.0%
Taylor expanded in y1 around inf
Applied rewrites80.9%
Final simplification74.5%
(FPCore (y1 x2 y2 x1) :precision binary64 (if (<= y2 5.5e+16) (* (/ x2 (- x2 x1)) y1) (* (/ x1 (- x1 x2)) y2)))
double code(double y1, double x2, double y2, double x1) { double tmp; if (y2 <= 5.5e+16) { tmp = (x2 / (x2 - x1)) * y1; } else { tmp = (x1 / (x1 - x2)) * y2; } return tmp; }
real(8) function code(y1, x2, y2, x1) real(8), intent (in) :: y1 real(8), intent (in) :: x2 real(8), intent (in) :: y2 real(8), intent (in) :: x1 real(8) :: tmp if (y2 <= 5.5d+16) then tmp = (x2 / (x2 - x1)) * y1 else tmp = (x1 / (x1 - x2)) * y2 end if code = tmp end function
public static double code(double y1, double x2, double y2, double x1) { double tmp; if (y2 <= 5.5e+16) { tmp = (x2 / (x2 - x1)) * y1; } else { tmp = (x1 / (x1 - x2)) * y2; } return tmp; }
def code(y1, x2, y2, x1): tmp = 0 if y2 <= 5.5e+16: tmp = (x2 / (x2 - x1)) * y1 else: tmp = (x1 / (x1 - x2)) * y2 return tmp
function code(y1, x2, y2, x1) tmp = 0.0 if (y2 <= 5.5e+16) tmp = Float64(Float64(x2 / Float64(x2 - x1)) * y1); else tmp = Float64(Float64(x1 / Float64(x1 - x2)) * y2); end return tmp end
function tmp_2 = code(y1, x2, y2, x1) tmp = 0.0; if (y2 <= 5.5e+16) tmp = (x2 / (x2 - x1)) * y1; else tmp = (x1 / (x1 - x2)) * y2; end tmp_2 = tmp; end
code[y1_, x2_, y2_, x1_] := If[LessEqual[y2, 5.5e+16], N[(N[(x2 / N[(x2 - x1), $MachinePrecision]), $MachinePrecision] * y1), $MachinePrecision], N[(N[(x1 / N[(x1 - x2), $MachinePrecision]), $MachinePrecision] * y2), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y2 \leq 5.5 \cdot 10^{+16}:\\ \;\;\;\;\frac{x2}{x2 - x1} \cdot y1\\ \mathbf{else}:\\ \;\;\;\;\frac{x1}{x1 - x2} \cdot y2\\ \end{array} \end{array}
if y2 < 5.5e16
Initial program 85.5%
Taylor expanded in y2 around inf
mul-1-neg
N/A
neg-sub0
N/A
associate-+l-
N/A
unsub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
neg-sub0
N/A
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites85.1%
Taylor expanded in y1 around inf
Applied rewrites70.0%
if 5.5e16 < y2
Initial program 70.1%
Taylor expanded in y1 around 0
associate-*l/
N/A
associate-*l*
N/A
lower-*.f64
N/A
mul-1-neg
N/A
distribute-neg-frac2
N/A
lower-/.f64
N/A
sub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
distribute-neg-in
N/A
mul-1-neg
N/A
remove-double-neg
N/A
sub-neg
N/A
lower--.f64
72.9
Applied rewrites72.9%
Final simplification71.3%
(FPCore (y1 x2 y2 x1) :precision binary64 (if (<= x2 4.5e-124) (fma (/ x2 x1) y2 y2) (* (/ x2 (- x2 x1)) y1)))
double code(double y1, double x2, double y2, double x1) { double tmp; if (x2 <= 4.5e-124) { tmp = fma((x2 / x1), y2, y2); } else { tmp = (x2 / (x2 - x1)) * y1; } return tmp; }
function code(y1, x2, y2, x1) tmp = 0.0 if (x2 <= 4.5e-124) tmp = fma(Float64(x2 / x1), y2, y2); else tmp = Float64(Float64(x2 / Float64(x2 - x1)) * y1); end return tmp end
code[y1_, x2_, y2_, x1_] := If[LessEqual[x2, 4.5e-124], N[(N[(x2 / x1), $MachinePrecision] * y2 + y2), $MachinePrecision], N[(N[(x2 / N[(x2 - x1), $MachinePrecision]), $MachinePrecision] * y1), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x2 \leq 4.5 \cdot 10^{-124}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x2}{x1}, y2, y2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x2}{x2 - x1} \cdot y1\\ \end{array} \end{array}
if x2 < 4.4999999999999996e-124
Initial program 82.5%
Taylor expanded in x2 around 0
+-commutative
N/A
distribute-lft-out--
N/A
associate-*r*
N/A
*-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
div-sub
N/A
lower-/.f64
N/A
lower--.f64
N/A
mul-1-neg
N/A
lower-neg.f64
79.1
Applied rewrites79.1%
Taylor expanded in y1 around 0
Applied rewrites73.3%
if 4.4999999999999996e-124 < x2
Initial program 76.7%
Taylor expanded in y2 around inf
mul-1-neg
N/A
neg-sub0
N/A
associate-+l-
N/A
unsub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
neg-sub0
N/A
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites88.3%
Taylor expanded in y1 around inf
Applied rewrites63.8%
Final simplification67.0%
(FPCore (y1 x2 y2 x1) :precision binary64 (if (<= x1 6.1e-79) (* (/ y1 y2) y2) (* 1.0 y2)))
double code(double y1, double x2, double y2, double x1) { double tmp; if (x1 <= 6.1e-79) { tmp = (y1 / y2) * y2; } else { tmp = 1.0 * y2; } return tmp; }
real(8) function code(y1, x2, y2, x1) real(8), intent (in) :: y1 real(8), intent (in) :: x2 real(8), intent (in) :: y2 real(8), intent (in) :: x1 real(8) :: tmp if (x1 <= 6.1d-79) then tmp = (y1 / y2) * y2 else tmp = 1.0d0 * y2 end if code = tmp end function
public static double code(double y1, double x2, double y2, double x1) { double tmp; if (x1 <= 6.1e-79) { tmp = (y1 / y2) * y2; } else { tmp = 1.0 * y2; } return tmp; }
def code(y1, x2, y2, x1): tmp = 0 if x1 <= 6.1e-79: tmp = (y1 / y2) * y2 else: tmp = 1.0 * y2 return tmp
function code(y1, x2, y2, x1) tmp = 0.0 if (x1 <= 6.1e-79) tmp = Float64(Float64(y1 / y2) * y2); else tmp = Float64(1.0 * y2); end return tmp end
function tmp_2 = code(y1, x2, y2, x1) tmp = 0.0; if (x1 <= 6.1e-79) tmp = (y1 / y2) * y2; else tmp = 1.0 * y2; end tmp_2 = tmp; end
code[y1_, x2_, y2_, x1_] := If[LessEqual[x1, 6.1e-79], N[(N[(y1 / y2), $MachinePrecision] * y2), $MachinePrecision], N[(1.0 * y2), $MachinePrecision]]
\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x1 \leq 6.1 \cdot 10^{-79}:\\ \;\;\;\;\frac{y1}{y2} \cdot y2\\ \mathbf{else}:\\ \;\;\;\;1 \cdot y2\\ \end{array} \end{array}
if x1 < 6.1000000000000005e-79
Initial program 80.8%
Taylor expanded in y2 around inf
mul-1-neg
N/A
neg-sub0
N/A
associate-+l-
N/A
unsub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
neg-sub0
N/A
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites86.2%
Taylor expanded in x2 around inf
Applied rewrites54.9%
if 6.1000000000000005e-79 < x1
Initial program 77.5%
Taylor expanded in y2 around inf
mul-1-neg
N/A
neg-sub0
N/A
associate-+l-
N/A
unsub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
neg-sub0
N/A
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites93.5%
Taylor expanded in x2 around 0
Applied rewrites55.0%
Final simplification55.0%
(FPCore (y1 x2 y2 x1) :precision binary64 (* 1.0 y2))
double code(double y1, double x2, double y2, double x1) { return 1.0 * y2; }
real(8) function code(y1, x2, y2, x1) real(8), intent (in) :: y1 real(8), intent (in) :: x2 real(8), intent (in) :: y2 real(8), intent (in) :: x1 code = 1.0d0 * y2 end function
public static double code(double y1, double x2, double y2, double x1) { return 1.0 * y2; }
def code(y1, x2, y2, x1): return 1.0 * y2
function code(y1, x2, y2, x1) return Float64(1.0 * y2) end
function tmp = code(y1, x2, y2, x1) tmp = 1.0 * y2; end
code[y1_, x2_, y2_, x1_] := N[(1.0 * y2), $MachinePrecision]
\begin{array}{l} \\ 1 \cdot y2 \end{array}
Initial program 78.6%
Taylor expanded in y2 around inf
mul-1-neg
N/A
neg-sub0
N/A
associate-+l-
N/A
unsub-neg
N/A
mul-1-neg
N/A
+-commutative
N/A
neg-sub0
N/A
*-commutative
N/A
lower-*.f64
N/A
Applied rewrites90.9%
Taylor expanded in x2 around 0
Applied rewrites40.2%
Final simplification40.2%
herbie shell --seed 1
(FPCore (y1 x2 y2 x1)
:name "(y1 * x2 - y2 * x1) / (x2 - x1)"
:precision binary64
:pre (and (and (and (and (<= 0.0 y1) (<= y1 1.79e+308)) (and (<= 0.0 x2) (<= x2 1.79e+308))) (and (<= 0.0 y2) (<= y2 1.79e+308))) (and (<= 0.0 x1) (<= x1 1.79e+308)))
(/ (- (* y1 x2) (* y2 x1)) (- x2 x1)))