
(FPCore (x y z t a b c) :precision binary64 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
def code(x, y, z, t, a, b, c): return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) end
function tmp = code(x, y, z, t, a, b, c) tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c); end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a b c) :precision binary64 (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))
double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t, a, b, c)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((((x * 9.0d0) * y) - (((z * 4.0d0) * t) * a)) + b) / (z * c)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c) {
return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
def code(x, y, z, t, a, b, c): return ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)
function code(x, y, z, t, a, b, c) return Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) end
function tmp = code(x, y, z, t, a, b, c) tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c); end
code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}
\end{array}
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(if (or (<= z -1.3e+55) (not (<= z 1.15e+35)))
(*
(* -1.0 y)
(fma
(- (/ (/ b (* c z)) y) (/ (* (/ (* a t) c) 4.0) y))
-1.0
(* (/ x (* c z)) -9.0)))
(/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -1.3e+55) || !(z <= 1.15e+35)) {
tmp = (-1.0 * y) * fma((((b / (c * z)) / y) - ((((a * t) / c) * 4.0) / y)), -1.0, ((x / (c * z)) * -9.0));
} else {
tmp = ((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c);
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if ((z <= -1.3e+55) || !(z <= 1.15e+35)) tmp = Float64(Float64(-1.0 * y) * fma(Float64(Float64(Float64(b / Float64(c * z)) / y) - Float64(Float64(Float64(Float64(a * t) / c) * 4.0) / y)), -1.0, Float64(Float64(x / Float64(c * z)) * -9.0))); else tmp = Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -1.3e+55], N[Not[LessEqual[z, 1.15e+35]], $MachinePrecision]], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - N[(N[(N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision] * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / N[(c * z), $MachinePrecision]), $MachinePrecision] * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+55} \lor \neg \left(z \leq 1.15 \cdot 10^{+35}\right):\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \mathsf{fma}\left(\frac{\frac{b}{c \cdot z}}{y} - \frac{\frac{a \cdot t}{c} \cdot 4}{y}, -1, \frac{x}{c \cdot z} \cdot -9\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c}\\
\end{array}
\end{array}
if z < -1.3e55 or 1.1499999999999999e35 < z Initial program 53.0%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites78.7%
if -1.3e55 < z < 1.1499999999999999e35Initial program 94.5%
Final simplification87.7%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(if (or (<= z -1.25e+50) (not (<= z 0.00046)))
(*
(* -1.0 y)
(fma
(- (/ (/ b (* c z)) y) (/ (* (/ (* a t) c) 4.0) y))
-1.0
(* (/ x (* c z)) -9.0)))
(/ (* (fma 9.0 x (/ (- b (* (* (* t z) a) 4.0)) y)) y) (* z c))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -1.25e+50) || !(z <= 0.00046)) {
tmp = (-1.0 * y) * fma((((b / (c * z)) / y) - ((((a * t) / c) * 4.0) / y)), -1.0, ((x / (c * z)) * -9.0));
} else {
tmp = (fma(9.0, x, ((b - (((t * z) * a) * 4.0)) / y)) * y) / (z * c);
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if ((z <= -1.25e+50) || !(z <= 0.00046)) tmp = Float64(Float64(-1.0 * y) * fma(Float64(Float64(Float64(b / Float64(c * z)) / y) - Float64(Float64(Float64(Float64(a * t) / c) * 4.0) / y)), -1.0, Float64(Float64(x / Float64(c * z)) * -9.0))); else tmp = Float64(Float64(fma(9.0, x, Float64(Float64(b - Float64(Float64(Float64(t * z) * a) * 4.0)) / y)) * y) / Float64(z * c)); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -1.25e+50], N[Not[LessEqual[z, 0.00046]], $MachinePrecision]], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - N[(N[(N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision] * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / N[(c * z), $MachinePrecision]), $MachinePrecision] * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(9.0 * x + N[(N[(b - N[(N[(N[(t * z), $MachinePrecision] * a), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.25 \cdot 10^{+50} \lor \neg \left(z \leq 0.00046\right):\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \mathsf{fma}\left(\frac{\frac{b}{c \cdot z}}{y} - \frac{\frac{a \cdot t}{c} \cdot 4}{y}, -1, \frac{x}{c \cdot z} \cdot -9\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(9, x, \frac{b - \left(\left(t \cdot z\right) \cdot a\right) \cdot 4}{y}\right) \cdot y}{z \cdot c}\\
\end{array}
\end{array}
if z < -1.25e50 or 4.6000000000000001e-4 < z Initial program 55.8%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites79.9%
if -1.25e50 < z < 4.6000000000000001e-4Initial program 94.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites92.2%
Final simplification86.6%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(if (or (<= z -9e-242) (not (<= z 1.2e+33)))
(*
(* -1.0 y)
(fma
(- (/ (/ b (* c z)) y) (/ (* (/ (* a t) c) 4.0) y))
-1.0
(* (/ x (* c z)) -9.0)))
(* (fma (/ t c) -4.0 (/ (fma (* y x) 9.0 b) (* (* c z) a))) a)))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if ((z <= -9e-242) || !(z <= 1.2e+33)) {
tmp = (-1.0 * y) * fma((((b / (c * z)) / y) - ((((a * t) / c) * 4.0) / y)), -1.0, ((x / (c * z)) * -9.0));
} else {
tmp = fma((t / c), -4.0, (fma((y * x), 9.0, b) / ((c * z) * a))) * a;
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if ((z <= -9e-242) || !(z <= 1.2e+33)) tmp = Float64(Float64(-1.0 * y) * fma(Float64(Float64(Float64(b / Float64(c * z)) / y) - Float64(Float64(Float64(Float64(a * t) / c) * 4.0) / y)), -1.0, Float64(Float64(x / Float64(c * z)) * -9.0))); else tmp = Float64(fma(Float64(t / c), -4.0, Float64(fma(Float64(y * x), 9.0, b) / Float64(Float64(c * z) * a))) * a); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[Or[LessEqual[z, -9e-242], N[Not[LessEqual[z, 1.2e+33]], $MachinePrecision]], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - N[(N[(N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision] * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / N[(c * z), $MachinePrecision]), $MachinePrecision] * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(t / c), $MachinePrecision] * -4.0 + N[(N[(N[(y * x), $MachinePrecision] * 9.0 + b), $MachinePrecision] / N[(N[(c * z), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{-242} \lor \neg \left(z \leq 1.2 \cdot 10^{+33}\right):\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \mathsf{fma}\left(\frac{\frac{b}{c \cdot z}}{y} - \frac{\frac{a \cdot t}{c} \cdot 4}{y}, -1, \frac{x}{c \cdot z} \cdot -9\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t}{c}, -4, \frac{\mathsf{fma}\left(y \cdot x, 9, b\right)}{\left(c \cdot z\right) \cdot a}\right) \cdot a\\
\end{array}
\end{array}
if z < -8.9999999999999997e-242 or 1.2e33 < z Initial program 68.0%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites81.5%
if -8.9999999999999997e-242 < z < 1.2e33Initial program 94.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites77.9%
Final simplification80.3%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (/ (* a t) c)))
(if (<= x -1e-34)
(* (- (fma (/ y (* c z)) 9.0 (/ b (* (* z x) c))) (* (/ t_1 x) 4.0)) x)
(*
(* -1.0 y)
(fma
(- (/ (/ b (* c z)) y) (/ (* t_1 4.0) y))
-1.0
(* (/ x (* c z)) -9.0))))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (a * t) / c;
double tmp;
if (x <= -1e-34) {
tmp = (fma((y / (c * z)), 9.0, (b / ((z * x) * c))) - ((t_1 / x) * 4.0)) * x;
} else {
tmp = (-1.0 * y) * fma((((b / (c * z)) / y) - ((t_1 * 4.0) / y)), -1.0, ((x / (c * z)) * -9.0));
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(a * t) / c) tmp = 0.0 if (x <= -1e-34) tmp = Float64(Float64(fma(Float64(y / Float64(c * z)), 9.0, Float64(b / Float64(Float64(z * x) * c))) - Float64(Float64(t_1 / x) * 4.0)) * x); else tmp = Float64(Float64(-1.0 * y) * fma(Float64(Float64(Float64(b / Float64(c * z)) / y) - Float64(Float64(t_1 * 4.0) / y)), -1.0, Float64(Float64(x / Float64(c * z)) * -9.0))); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[x, -1e-34], N[(N[(N[(N[(y / N[(c * z), $MachinePrecision]), $MachinePrecision] * 9.0 + N[(b / N[(N[(z * x), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$1 / x), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - N[(N[(t$95$1 * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / N[(c * z), $MachinePrecision]), $MachinePrecision] * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
t_1 := \frac{a \cdot t}{c}\\
\mathbf{if}\;x \leq -1 \cdot 10^{-34}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{y}{c \cdot z}, 9, \frac{b}{\left(z \cdot x\right) \cdot c}\right) - \frac{t\_1}{x} \cdot 4\right) \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \mathsf{fma}\left(\frac{\frac{b}{c \cdot z}}{y} - \frac{t\_1 \cdot 4}{y}, -1, \frac{x}{c \cdot z} \cdot -9\right)\\
\end{array}
\end{array}
if x < -9.99999999999999928e-35Initial program 66.4%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites81.1%
if -9.99999999999999928e-35 < x Initial program 80.7%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites76.7%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (/ (* a t) c)))
(if (<= (/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)) 5e+273)
(*
(* -1.0 y)
(fma
(- (/ (/ b (* c z)) y) (/ (* t_1 4.0) y))
-1.0
(* (/ x (* c z)) -9.0)))
(*
(* -1.0 y)
(fma (/ (fma (/ x c) 9.0 (/ (/ b c) y)) z) -1.0 (* (/ t_1 y) 4.0))))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (a * t) / c;
double tmp;
if ((((((x * 9.0) * y) - (((z * 4.0) * t) * a)) + b) / (z * c)) <= 5e+273) {
tmp = (-1.0 * y) * fma((((b / (c * z)) / y) - ((t_1 * 4.0) / y)), -1.0, ((x / (c * z)) * -9.0));
} else {
tmp = (-1.0 * y) * fma((fma((x / c), 9.0, ((b / c) / y)) / z), -1.0, ((t_1 / y) * 4.0));
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(a * t) / c) tmp = 0.0 if (Float64(Float64(Float64(Float64(Float64(x * 9.0) * y) - Float64(Float64(Float64(z * 4.0) * t) * a)) + b) / Float64(z * c)) <= 5e+273) tmp = Float64(Float64(-1.0 * y) * fma(Float64(Float64(Float64(b / Float64(c * z)) / y) - Float64(Float64(t_1 * 4.0) / y)), -1.0, Float64(Float64(x / Float64(c * z)) * -9.0))); else tmp = Float64(Float64(-1.0 * y) * fma(Float64(fma(Float64(x / c), 9.0, Float64(Float64(b / c) / y)) / z), -1.0, Float64(Float64(t_1 / y) * 4.0))); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision] - N[(N[(N[(z * 4.0), $MachinePrecision] * t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] + b), $MachinePrecision] / N[(z * c), $MachinePrecision]), $MachinePrecision], 5e+273], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] - N[(N[(t$95$1 * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(x / N[(c * z), $MachinePrecision]), $MachinePrecision] * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(N[(x / c), $MachinePrecision] * 9.0 + N[(N[(b / c), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + N[(N[(t$95$1 / y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
t_1 := \frac{a \cdot t}{c}\\
\mathbf{if}\;\frac{\left(\left(x \cdot 9\right) \cdot y - \left(\left(z \cdot 4\right) \cdot t\right) \cdot a\right) + b}{z \cdot c} \leq 5 \cdot 10^{+273}:\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \mathsf{fma}\left(\frac{\frac{b}{c \cdot z}}{y} - \frac{t\_1 \cdot 4}{y}, -1, \frac{x}{c \cdot z} \cdot -9\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{x}{c}, 9, \frac{\frac{b}{c}}{y}\right)}{z}, -1, \frac{t\_1}{y} \cdot 4\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) < 4.99999999999999961e273Initial program 90.3%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites77.4%
if 4.99999999999999961e273 < (/.f64 (+.f64 (-.f64 (*.f64 (*.f64 x #s(literal 9 binary64)) y) (*.f64 (*.f64 (*.f64 z #s(literal 4 binary64)) t) a)) b) (*.f64 z c)) Initial program 53.3%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites70.9%
Taylor expanded in z around -inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites78.0%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(if (<= a -1.45e-118)
(*
(* -1.0 y)
(*
(fma
(/ x (* (* t z) c))
-9.0
(fma (/ (/ a c) y) 4.0 (* (/ b (* (* (* t y) z) c)) -1.0)))
t))
(*
(* -1.0 y)
(fma
(/ (fma (/ x c) 9.0 (/ (/ b c) y)) z)
-1.0
(* (/ (/ (* a t) c) y) 4.0)))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double tmp;
if (a <= -1.45e-118) {
tmp = (-1.0 * y) * (fma((x / ((t * z) * c)), -9.0, fma(((a / c) / y), 4.0, ((b / (((t * y) * z) * c)) * -1.0))) * t);
} else {
tmp = (-1.0 * y) * fma((fma((x / c), 9.0, ((b / c) / y)) / z), -1.0, ((((a * t) / c) / y) * 4.0));
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) tmp = 0.0 if (a <= -1.45e-118) tmp = Float64(Float64(-1.0 * y) * Float64(fma(Float64(x / Float64(Float64(t * z) * c)), -9.0, fma(Float64(Float64(a / c) / y), 4.0, Float64(Float64(b / Float64(Float64(Float64(t * y) * z) * c)) * -1.0))) * t)); else tmp = Float64(Float64(-1.0 * y) * fma(Float64(fma(Float64(x / c), 9.0, Float64(Float64(b / c) / y)) / z), -1.0, Float64(Float64(Float64(Float64(a * t) / c) / y) * 4.0))); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := If[LessEqual[a, -1.45e-118], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(x / N[(N[(t * z), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] * -9.0 + N[(N[(N[(a / c), $MachinePrecision] / y), $MachinePrecision] * 4.0 + N[(N[(b / N[(N[(N[(t * y), $MachinePrecision] * z), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(N[(x / c), $MachinePrecision] * 9.0 + N[(N[(b / c), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision] * -1.0 + N[(N[(N[(N[(a * t), $MachinePrecision] / c), $MachinePrecision] / y), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
\mathbf{if}\;a \leq -1.45 \cdot 10^{-118}:\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \left(\mathsf{fma}\left(\frac{x}{\left(t \cdot z\right) \cdot c}, -9, \mathsf{fma}\left(\frac{\frac{a}{c}}{y}, 4, \frac{b}{\left(\left(t \cdot y\right) \cdot z\right) \cdot c} \cdot -1\right)\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{x}{c}, 9, \frac{\frac{b}{c}}{y}\right)}{z}, -1, \frac{\frac{a \cdot t}{c}}{y} \cdot 4\right)\\
\end{array}
\end{array}
if a < -1.4499999999999999e-118Initial program 72.4%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites71.8%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites67.2%
if -1.4499999999999999e-118 < a Initial program 78.8%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites76.5%
Taylor expanded in z around -inf
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites74.1%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c)
:precision binary64
(let* ((t_1 (* (* x 9.0) y)))
(if (or (<= t_1 -1e-104) (not (<= t_1 5e-135)))
(*
(* -1.0 y)
(*
(fma
(/ x (* (* t z) c))
-9.0
(fma (/ (/ a c) y) 4.0 (* (/ b (* (* (* t y) z) c)) -1.0)))
t))
(*
(* -1.0 t)
(fma
(/ (fma (* (/ (* 9.0 x) c) (/ y z)) t (* t (/ b (* c z)))) (* t t))
-1.0
(* (/ a c) 4.0))))))assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
double t_1 = (x * 9.0) * y;
double tmp;
if ((t_1 <= -1e-104) || !(t_1 <= 5e-135)) {
tmp = (-1.0 * y) * (fma((x / ((t * z) * c)), -9.0, fma(((a / c) / y), 4.0, ((b / (((t * y) * z) * c)) * -1.0))) * t);
} else {
tmp = (-1.0 * t) * fma((fma((((9.0 * x) / c) * (y / z)), t, (t * (b / (c * z)))) / (t * t)), -1.0, ((a / c) * 4.0));
}
return tmp;
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) t_1 = Float64(Float64(x * 9.0) * y) tmp = 0.0 if ((t_1 <= -1e-104) || !(t_1 <= 5e-135)) tmp = Float64(Float64(-1.0 * y) * Float64(fma(Float64(x / Float64(Float64(t * z) * c)), -9.0, fma(Float64(Float64(a / c) / y), 4.0, Float64(Float64(b / Float64(Float64(Float64(t * y) * z) * c)) * -1.0))) * t)); else tmp = Float64(Float64(-1.0 * t) * fma(Float64(fma(Float64(Float64(Float64(9.0 * x) / c) * Float64(y / z)), t, Float64(t * Float64(b / Float64(c * z)))) / Float64(t * t)), -1.0, Float64(Float64(a / c) * 4.0))); end return tmp end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(x * 9.0), $MachinePrecision] * y), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -1e-104], N[Not[LessEqual[t$95$1, 5e-135]], $MachinePrecision]], N[(N[(-1.0 * y), $MachinePrecision] * N[(N[(N[(x / N[(N[(t * z), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] * -9.0 + N[(N[(N[(a / c), $MachinePrecision] / y), $MachinePrecision] * 4.0 + N[(N[(b / N[(N[(N[(t * y), $MachinePrecision] * z), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] * -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 * t), $MachinePrecision] * N[(N[(N[(N[(N[(N[(9.0 * x), $MachinePrecision] / c), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision] * t + N[(t * N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(a / c), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\begin{array}{l}
t_1 := \left(x \cdot 9\right) \cdot y\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-104} \lor \neg \left(t\_1 \leq 5 \cdot 10^{-135}\right):\\
\;\;\;\;\left(-1 \cdot y\right) \cdot \left(\mathsf{fma}\left(\frac{x}{\left(t \cdot z\right) \cdot c}, -9, \mathsf{fma}\left(\frac{\frac{a}{c}}{y}, 4, \frac{b}{\left(\left(t \cdot y\right) \cdot z\right) \cdot c} \cdot -1\right)\right) \cdot t\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-1 \cdot t\right) \cdot \mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{9 \cdot x}{c} \cdot \frac{y}{z}, t, t \cdot \frac{b}{c \cdot z}\right)}{t \cdot t}, -1, \frac{a}{c} \cdot 4\right)\\
\end{array}
\end{array}
if (*.f64 (*.f64 x #s(literal 9 binary64)) y) < -9.99999999999999927e-105 or 5.0000000000000002e-135 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) Initial program 78.0%
Taylor expanded in y around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites77.1%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites60.7%
if -9.99999999999999927e-105 < (*.f64 (*.f64 x #s(literal 9 binary64)) y) < 5.0000000000000002e-135Initial program 73.4%
Taylor expanded in t around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites67.0%
Final simplification62.5%
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. (FPCore (x y z t a b c) :precision binary64 (* (* -1.0 t) (fma (/ (fma (* (/ (* 9.0 x) c) (/ y z)) t (* t (/ b (* c z)))) (* t t)) -1.0 (* (/ a c) 4.0))))
assert(x < y && y < z && z < t && t < a && a < b && b < c);
double code(double x, double y, double z, double t, double a, double b, double c) {
return (-1.0 * t) * fma((fma((((9.0 * x) / c) * (y / z)), t, (t * (b / (c * z)))) / (t * t)), -1.0, ((a / c) * 4.0));
}
x, y, z, t, a, b, c = sort([x, y, z, t, a, b, c]) function code(x, y, z, t, a, b, c) return Float64(Float64(-1.0 * t) * fma(Float64(fma(Float64(Float64(Float64(9.0 * x) / c) * Float64(y / z)), t, Float64(t * Float64(b / Float64(c * z)))) / Float64(t * t)), -1.0, Float64(Float64(a / c) * 4.0))) end
NOTE: x, y, z, t, a, b, and c should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_, b_, c_] := N[(N[(-1.0 * t), $MachinePrecision] * N[(N[(N[(N[(N[(N[(9.0 * x), $MachinePrecision] / c), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision] * t + N[(t * N[(b / N[(c * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision] * -1.0 + N[(N[(a / c), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c] = \mathsf{sort}([x, y, z, t, a, b, c])\\
\\
\left(-1 \cdot t\right) \cdot \mathsf{fma}\left(\frac{\mathsf{fma}\left(\frac{9 \cdot x}{c} \cdot \frac{y}{z}, t, t \cdot \frac{b}{c \cdot z}\right)}{t \cdot t}, -1, \frac{a}{c} \cdot 4\right)
\end{array}
Initial program 76.7%
Taylor expanded in t around -inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites53.0%
herbie shell --seed 2025065
(FPCore (x y z t a b c)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, J"
:precision binary64
:alt
(! :herbie-platform default (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) -220031348160821/200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 0) (/ (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) z) c) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 365902434742109/31250000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 28768236795461370000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (+ (* (* 9 (/ y c)) (/ x z)) (/ b (* c z))) (* 4 (/ (* a t) c))) (if (< (/ (+ (- (* (* x 9) y) (* (* (* z 4) t) a)) b) (* z c)) 138385150424563190000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (+ (- (* (* x 9) y) (* (* z 4) (* t a))) b) (* z c)) (- (+ (* 9 (* (/ y (* c z)) x)) (/ b (* c z))) (* 4 (/ (* a t) c)))))))))
(/ (+ (- (* (* x 9.0) y) (* (* (* z 4.0) t) a)) b) (* z c)))