
(FPCore (x y z t) :precision binary64 :pre TRUE (+ x (* (- y x) (/ z t))))
double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / 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 = x + ((y - x) * (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
def code(x, y, z, t): return x + ((y - x) * (z / t))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) * (z / t)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $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 = x + ((y - x) * (z / t)) END code
x + \left(y - x\right) \cdot \frac{z}{t}
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 :pre TRUE (+ x (* (- y x) (/ z t))))
double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / 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 = x + ((y - x) * (z / t))
end function
public static double code(double x, double y, double z, double t) {
return x + ((y - x) * (z / t));
}
def code(x, y, z, t): return x + ((y - x) * (z / t))
function code(x, y, z, t) return Float64(x + Float64(Float64(y - x) * Float64(z / t))) end
function tmp = code(x, y, z, t) tmp = x + ((y - x) * (z / t)); end
code[x_, y_, z_, t_] := N[(x + N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision]), $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 = x + ((y - x) * (z / t)) END code
x + \left(y - x\right) \cdot \frac{z}{t}
(FPCore (x y z t) :precision binary64 :pre TRUE (fma (- y x) (/ z t) x))
double code(double x, double y, double z, double t) {
return fma((y - x), (z / t), x);
}
function code(x, y, z, t) return fma(Float64(y - x), Float64(z / t), x) end
code[x_, y_, z_, t_] := N[(N[(y - x), $MachinePrecision] * N[(z / t), $MachinePrecision] + x), $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 - x) * (z / t)) + x END code
\mathsf{fma}\left(y - x, \frac{z}{t}, x\right)
Initial program 97.7%
Applied rewrites97.7%
(FPCore (x y z t) :precision binary64 :pre TRUE (if (<= (/ z t) -1e-8) (fma z (/ (- y x) t) x) (if (<= (/ z t) 5e-10) (fma y (/ z t) x) (/ (* z (- y x)) t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= -1e-8) {
tmp = fma(z, ((y - x) / t), x);
} else if ((z / t) <= 5e-10) {
tmp = fma(y, (z / t), x);
} else {
tmp = (z * (y - x)) / t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z / t) <= -1e-8) tmp = fma(z, Float64(Float64(y - x) / t), x); elseif (Float64(z / t) <= 5e-10) tmp = fma(y, Float64(z / t), x); else tmp = Float64(Float64(z * Float64(y - x)) / t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z / t), $MachinePrecision], -1e-8], N[(z * N[(N[(y - x), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[N[(z / t), $MachinePrecision], 5e-10], N[(y * N[(z / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * N[(y - x), $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 = LET tmp_1 = IF ((z / t) <= (50000000000000003114079572888992820944853434639298939146101474761962890625e-83)) THEN ((y * (z / t)) + x) ELSE ((z * (y - x)) / t) ENDIF IN LET tmp = IF ((z / t) <= (-10000000000000000209225608301284726753266340892878361046314239501953125e-78)) THEN ((z * ((y - x) / t)) + x) ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq -1 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y - x}{t}, x\right)\\
\mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot \left(y - x\right)}{t}\\
\end{array}
if (/.f64 z t) < -1e-8Initial program 97.7%
Applied rewrites92.4%
if -1e-8 < (/.f64 z t) < 5.0000000000000003e-10Initial program 97.7%
Applied rewrites97.7%
Taylor expanded in x around 0
Applied rewrites76.4%
if 5.0000000000000003e-10 < (/.f64 z t) Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites76.4%
Taylor expanded in undef-var around zero
Applied rewrites40.6%
Applied rewrites40.6%
Taylor expanded in z around -inf
Applied rewrites58.0%
(FPCore (x y z t)
:precision binary64
:pre TRUE
(let* ((t_1 (/ (* z (- y x)) t)))
(if (<= (/ z t) -1e+28)
t_1
(if (<= (/ z t) 5e-10) (fma y (/ z t) x) t_1))))double code(double x, double y, double z, double t) {
double t_1 = (z * (y - x)) / t;
double tmp;
if ((z / t) <= -1e+28) {
tmp = t_1;
} else if ((z / t) <= 5e-10) {
tmp = fma(y, (z / t), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * Float64(y - x)) / t) tmp = 0.0 if (Float64(z / t) <= -1e+28) tmp = t_1; elseif (Float64(z / t) <= 5e-10) tmp = fma(y, Float64(z / t), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * N[(y - x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]}, If[LessEqual[N[(z / t), $MachinePrecision], -1e+28], t$95$1, If[LessEqual[N[(z / t), $MachinePrecision], 5e-10], N[(y * N[(z / t), $MachinePrecision] + x), $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 = ((z * (y - x)) / t) IN LET tmp_1 = IF ((z / t) <= (50000000000000003114079572888992820944853434639298939146101474761962890625e-83)) THEN ((y * (z / t)) + x) ELSE t_1 ENDIF IN LET tmp = IF ((z / t) <= (-9999999999999999583119736832)) THEN t_1 ELSE tmp_1 ENDIF IN tmp END code
\begin{array}{l}
t_1 := \frac{z \cdot \left(y - x\right)}{t}\\
\mathbf{if}\;\frac{z}{t} \leq -1 \cdot 10^{+28}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\frac{z}{t} \leq 5 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(y, \frac{z}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
if (/.f64 z t) < -9.9999999999999996e27 or 5.0000000000000003e-10 < (/.f64 z t) Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites76.4%
Taylor expanded in undef-var around zero
Applied rewrites40.6%
Applied rewrites40.6%
Taylor expanded in z around -inf
Applied rewrites58.0%
if -9.9999999999999996e27 < (/.f64 z t) < 5.0000000000000003e-10Initial program 97.7%
Applied rewrites97.7%
Taylor expanded in x around 0
Applied rewrites76.4%
(FPCore (x y z t) :precision binary64 :pre TRUE (fma y (/ z t) x))
double code(double x, double y, double z, double t) {
return fma(y, (z / t), x);
}
function code(x, y, z, t) return fma(y, Float64(z / t), x) end
code[x_, y_, z_, t_] := N[(y * N[(z / t), $MachinePrecision] + x), $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 / t)) + x END code
\mathsf{fma}\left(y, \frac{z}{t}, x\right)
Initial program 97.7%
Applied rewrites97.7%
Taylor expanded in x around 0
Applied rewrites76.4%
(FPCore (x y z t) :precision binary64 :pre TRUE (if (<= (/ z t) 2e-39) (fma z (/ y t) x) (/ (* y z) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z / t) <= 2e-39) {
tmp = fma(z, (y / t), x);
} else {
tmp = (y * z) / t;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(z / t) <= 2e-39) tmp = fma(z, Float64(y / t), x); else tmp = Float64(Float64(y * z) / t); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(z / t), $MachinePrecision], 2e-39], N[(z * N[(y / t), $MachinePrecision] + x), $MachinePrecision], N[(N[(y * z), $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 = LET tmp = IF ((z / t) <= (19999999999999998585857587997602900046612902381239473479626644444638600999022172123081953005438153743965334907528585972613655030727386474609375e-181)) THEN ((z * (y / t)) + x) ELSE ((y * z) / t) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\frac{z}{t} \leq 2 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot z}{t}\\
\end{array}
if (/.f64 z t) < 1.9999999999999999e-39Initial program 97.7%
Applied rewrites92.4%
Taylor expanded in x around 0
Applied rewrites72.8%
if 1.9999999999999999e-39 < (/.f64 z t) Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites76.4%
Taylor expanded in undef-var around zero
Applied rewrites40.6%
Applied rewrites40.6%
Taylor expanded in x around 0
Applied rewrites37.6%
(FPCore (x y z t) :precision binary64 :pre TRUE (/ (* y z) t))
double code(double x, double y, double z, double t) {
return (y * z) / 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 = (y * z) / t
end function
public static double code(double x, double y, double z, double t) {
return (y * z) / t;
}
def code(x, y, z, t): return (y * z) / t
function code(x, y, z, t) return Float64(Float64(y * z) / t) end
function tmp = code(x, y, z, t) tmp = (y * z) / t; end
code[x_, y_, z_, t_] := N[(N[(y * z), $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 = (y * z) / t END code
\frac{y \cdot z}{t}
Initial program 97.7%
Taylor expanded in x around 0
Applied rewrites76.4%
Taylor expanded in undef-var around zero
Applied rewrites40.6%
Applied rewrites40.6%
Taylor expanded in x around 0
Applied rewrites37.6%
herbie shell --seed 2026092
(FPCore (x y z t)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:tickPosition from plot-0.2.3.4"
:precision binary64
(+ x (* (- y x) (/ z t))))