
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))
double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((1.0d0 / 8.0d0) * x) - ((y * z) / 2.0d0)) + t
end function
public static double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
def code(x, y, z, t): return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) - Float64(Float64(y * z) / 2.0)) + t) end
function tmp = code(x, y, z, t) tmp = (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = ((((1) / (8)) * x) - ((y * z) / (2))) + t END code
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))
double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((1.0d0 / 8.0d0) * x) - ((y * z) / 2.0d0)) + t
end function
public static double code(double x, double y, double z, double t) {
return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t;
}
def code(x, y, z, t): return (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t
function code(x, y, z, t) return Float64(Float64(Float64(Float64(1.0 / 8.0) * x) - Float64(Float64(y * z) / 2.0)) + t) end
function tmp = code(x, y, z, t) tmp = (((1.0 / 8.0) * x) - ((y * z) / 2.0)) + t; end
code[x_, y_, z_, t_] := N[(N[(N[(N[(1.0 / 8.0), $MachinePrecision] * x), $MachinePrecision] - N[(N[(y * z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = ((((1) / (8)) * x) - ((y * z) / (2))) + t END code
\left(\frac{1}{8} \cdot x - \frac{y \cdot z}{2}\right) + t
(FPCore (x y z t) :precision binary64 :pre TRUE (fma y (* z -0.5) (fma x 0.125 t)))
double code(double x, double y, double z, double t) {
return fma(y, (z * -0.5), fma(x, 0.125, t));
}
function code(x, y, z, t) return fma(y, Float64(z * -0.5), fma(x, 0.125, t)) end
code[x_, y_, z_, t_] := N[(y * N[(z * -0.5), $MachinePrecision] + N[(x * 0.125 + t), $MachinePrecision]), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = (y * (z * (-5e-1))) + ((x * (125e-3)) + t) END code
\mathsf{fma}\left(y, z \cdot -0.5, \mathsf{fma}\left(x, 0.125, t\right)\right)
Initial program 100.0%
Applied rewrites100.0%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (+ (* -0.5 (* y z)) t)))
(if (<= t -1.6770947112847438e-50)
t_1
(if (<= t 76298940059016.36) (fma y (* -0.5 z) (* 0.125 x)) t_1))))double code(double x, double y, double z, double t) {
double t_1 = (-0.5 * (y * z)) + t;
double tmp;
if (t <= -1.6770947112847438e-50) {
tmp = t_1;
} else if (t <= 76298940059016.36) {
tmp = fma(y, (-0.5 * z), (0.125 * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(-0.5 * Float64(y * z)) + t) tmp = 0.0 if (t <= -1.6770947112847438e-50) tmp = t_1; elseif (t <= 76298940059016.36) tmp = fma(y, Float64(-0.5 * z), Float64(0.125 * x)); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(-0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[t, -1.6770947112847438e-50], t$95$1, If[LessEqual[t, 76298940059016.36], N[(y * N[(-0.5 * z), $MachinePrecision] + N[(0.125 * x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET t_1 = (((-5e-1) * (y * z)) + t) IN LET tmp_1 = IF (t <= (76298940059016359375e-6)) THEN ((y * ((-5e-1) * z)) + ((125e-3) * x)) ELSE t_1 ENDIF IN LET tmp = IF (t <= (-167709471128474384815647562929888437797664347855967950775217343270676325862336514112358919563496671100570645038506509306522611509049358602396750939078629016876220703125e-217)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := -0.5 \cdot \left(y \cdot z\right) + t\\
\mathbf{if}\;t \leq -1.6770947112847438 \cdot 10^{-50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 76298940059016.36:\\
\;\;\;\;\mathsf{fma}\left(y, -0.5 \cdot z, 0.125 \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if t < -1.6770947112847438e-50 or 76298940059016.359 < t Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites67.8%
if -1.6770947112847438e-50 < t < 76298940059016.359Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Applied rewrites64.6%
Taylor expanded in t around 0
Applied rewrites68.2%
Applied rewrites68.2%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (+ (* -0.5 (* y z)) t)))
(if (<= (* y z) -3.811187879761372e-39)
t_1
(if (<= (* y z) 5.193479599924079e-49) (fma 0.125 x t) t_1))))double code(double x, double y, double z, double t) {
double t_1 = (-0.5 * (y * z)) + t;
double tmp;
if ((y * z) <= -3.811187879761372e-39) {
tmp = t_1;
} else if ((y * z) <= 5.193479599924079e-49) {
tmp = fma(0.125, x, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(-0.5 * Float64(y * z)) + t) tmp = 0.0 if (Float64(y * z) <= -3.811187879761372e-39) tmp = t_1; elseif (Float64(y * z) <= 5.193479599924079e-49) tmp = fma(0.125, x, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(-0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -3.811187879761372e-39], t$95$1, If[LessEqual[N[(y * z), $MachinePrecision], 5.193479599924079e-49], N[(0.125 * x + t), $MachinePrecision], t$95$1]]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET t_1 = (((-5e-1) * (y * z)) + t) IN LET tmp_1 = IF ((y * z) <= (519347959992407922738789092435664841483204930658308108660499036343171355847186042158132009909050298978109699785556393355719952131810401851907954551279544830322265625e-213)) THEN (((125e-3) * x) + t) ELSE t_1 ENDIF IN LET tmp = IF ((y * z) <= (-3811187879761372015349719338492753709029299134921760281036981209992095526189864673376994075372514204913532154250788153149187564849853515625e-177)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := -0.5 \cdot \left(y \cdot z\right) + t\\
\mathbf{if}\;y \cdot z \leq -3.811187879761372 \cdot 10^{-39}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \cdot z \leq 5.193479599924079 \cdot 10^{-49}:\\
\;\;\;\;\mathsf{fma}\left(0.125, x, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 y z) < -3.811187879761372e-39 or 5.1934795999240792e-49 < (*.f64 y z) Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites67.8%
if -3.811187879761372e-39 < (*.f64 y z) < 5.1934795999240792e-49Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Applied rewrites64.6%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (* -0.5 (* y z))))
(if (<= (* y z) -5.175013782460881e+99)
t_1
(if (<= (* y z) 6.4573354302613295e+72) (fma 0.125 x t) t_1))))double code(double x, double y, double z, double t) {
double t_1 = -0.5 * (y * z);
double tmp;
if ((y * z) <= -5.175013782460881e+99) {
tmp = t_1;
} else if ((y * z) <= 6.4573354302613295e+72) {
tmp = fma(0.125, x, t);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(-0.5 * Float64(y * z)) tmp = 0.0 if (Float64(y * z) <= -5.175013782460881e+99) tmp = t_1; elseif (Float64(y * z) <= 6.4573354302613295e+72) tmp = fma(0.125, x, t); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(-0.5 * N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y * z), $MachinePrecision], -5.175013782460881e+99], t$95$1, If[LessEqual[N[(y * z), $MachinePrecision], 6.4573354302613295e+72], N[(0.125 * x + t), $MachinePrecision], t$95$1]]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET t_1 = ((-5e-1) * (y * z)) IN LET tmp_1 = IF ((y * z) <= (6457335430261329547810767699390821776343632049679724029847141179088437248)) THEN (((125e-3) * x) + t) ELSE t_1 ENDIF IN LET tmp = IF ((y * z) <= (-5175013782460881157524174131526843532796470125390131372701020118359893052427140865462262724732911616)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := -0.5 \cdot \left(y \cdot z\right)\\
\mathbf{if}\;y \cdot z \leq -5.175013782460881 \cdot 10^{+99}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \cdot z \leq 6.4573354302613295 \cdot 10^{+72}:\\
\;\;\;\;\mathsf{fma}\left(0.125, x, t\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (*.f64 y z) < -5.1750137824608812e99 or 6.4573354302613295e72 < (*.f64 y z) Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Applied rewrites64.6%
Taylor expanded in y around inf
Applied rewrites36.8%
if -5.1750137824608812e99 < (*.f64 y z) < 6.4573354302613295e72Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Applied rewrites64.6%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma 0.125 x t))
double code(double x, double y, double z, double t) {
return fma(0.125, x, t);
}
function code(x, y, z, t) return fma(0.125, x, t) end
code[x_, y_, z_, t_] := N[(0.125 * x + t), $MachinePrecision]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = ((125e-3) * x) + t END code
\mathsf{fma}\left(0.125, x, t\right)
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Applied rewrites64.6%
(FPCore (x y z t) :precision binary64 :pre TRUE (if (<= t -1.6770947112847438e-50) t (if (<= t 9.624175003052535e+19) (* 0.125 x) t)))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.6770947112847438e-50) {
tmp = t;
} else if (t <= 9.624175003052535e+19) {
tmp = 0.125 * x;
} else {
tmp = t;
}
return tmp;
}
real(8) function code(x, y, z, t)
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) :: tmp
if (t <= (-1.6770947112847438d-50)) then
tmp = t
else if (t <= 9.624175003052535d+19) then
tmp = 0.125d0 * x
else
tmp = t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.6770947112847438e-50) {
tmp = t;
} else if (t <= 9.624175003052535e+19) {
tmp = 0.125 * x;
} else {
tmp = t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.6770947112847438e-50: tmp = t elif t <= 9.624175003052535e+19: tmp = 0.125 * x else: tmp = t return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.6770947112847438e-50) tmp = t; elseif (t <= 9.624175003052535e+19) tmp = Float64(0.125 * x); else tmp = t; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.6770947112847438e-50) tmp = t; elseif (t <= 9.624175003052535e+19) tmp = 0.125 * x; else tmp = t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.6770947112847438e-50], t, If[LessEqual[t, 9.624175003052535e+19], N[(0.125 * x), $MachinePrecision], t]]
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = LET tmp_1 = IF (t <= (96241750030525349888)) THEN ((125e-3) * x) ELSE t ENDIF IN LET tmp = IF (t <= (-167709471128474384815647562929888437797664347855967950775217343270676325862336514112358919563496671100570645038506509306522611509049358602396750939078629016876220703125e-217)) THEN t ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;t \leq -1.6770947112847438 \cdot 10^{-50}:\\
\;\;\;\;t\\
\mathbf{elif}\;t \leq 9.624175003052535 \cdot 10^{+19}:\\
\;\;\;\;0.125 \cdot x\\
\mathbf{else}:\\
\;\;\;\;t\\
\end{array}
if t < -1.6770947112847438e-50 or 96241750030525350000 < t Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Taylor expanded in x around 0
Applied rewrites33.1%
if -1.6770947112847438e-50 < t < 96241750030525350000Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Taylor expanded in x around 0
Applied rewrites33.1%
Taylor expanded in x around inf
Applied rewrites33.3%
(FPCore (x y z t) :precision binary64 :pre TRUE t)
double code(double x, double y, double z, double t) {
return t;
}
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = t
end function
public static double code(double x, double y, double z, double t) {
return t;
}
def code(x, y, z, t): return t
function code(x, y, z, t) return t end
function tmp = code(x, y, z, t) tmp = t; end
code[x_, y_, z_, t_] := t
f(x, y, z, t): x in [-inf, +inf], y in [-inf, +inf], z in [-inf, +inf], t in [-inf, +inf] code: THEORY BEGIN f(x, y, z, t: real): real = t END code
t
Initial program 100.0%
Taylor expanded in y around 0
Applied rewrites64.6%
Taylor expanded in x around 0
Applied rewrites33.1%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, B"
:precision binary64
(+ (- (* (/ 1.0 8.0) x) (/ (* y z) 2.0)) t))