
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
real(8) function code(x, y, z, t, a)
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
code = x + ((y * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (+ x (/ (* y (- z t)) (- a t))))
double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
real(8) function code(x, y, z, t, a)
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
code = x + ((y * (z - t)) / (a - t))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + ((y * (z - t)) / (a - t));
}
def code(x, y, z, t, a): return x + ((y * (z - t)) / (a - t))
function code(x, y, z, t, a) return Float64(x + Float64(Float64(y * Float64(z - t)) / Float64(a - t))) end
function tmp = code(x, y, z, t, a) tmp = x + ((y * (z - t)) / (a - t)); end
code[x_, y_, z_, t_, a_] := N[(x + N[(N[(y * N[(z - t), $MachinePrecision]), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y \cdot \left(z - t\right)}{a - t}
\end{array}
(FPCore (x y z t a) :precision binary64 (+ (/ y (/ (- a t) (- z t))) x))
double code(double x, double y, double z, double t, double a) {
return (y / ((a - t) / (z - t))) + x;
}
real(8) function code(x, y, z, t, a)
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
code = (y / ((a - t) / (z - t))) + x
end function
public static double code(double x, double y, double z, double t, double a) {
return (y / ((a - t) / (z - t))) + x;
}
def code(x, y, z, t, a): return (y / ((a - t) / (z - t))) + x
function code(x, y, z, t, a) return Float64(Float64(y / Float64(Float64(a - t) / Float64(z - t))) + x) end
function tmp = code(x, y, z, t, a) tmp = (y / ((a - t) / (z - t))) + x; end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{\frac{a - t}{z - t}} + x
\end{array}
Initial program 84.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
Final simplification98.0%
(FPCore (x y z t a)
:precision binary64
(if (<= t -1.95e+189)
(+ y x)
(if (<= t -5.2e-77)
(fma (/ (- z) t) y x)
(if (<= t 1.1e+32) (fma z (/ y a) x) (+ y x)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.95e+189) {
tmp = y + x;
} else if (t <= -5.2e-77) {
tmp = fma((-z / t), y, x);
} else if (t <= 1.1e+32) {
tmp = fma(z, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.95e+189) tmp = Float64(y + x); elseif (t <= -5.2e-77) tmp = fma(Float64(Float64(-z) / t), y, x); elseif (t <= 1.1e+32) tmp = fma(z, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.95e+189], N[(y + x), $MachinePrecision], If[LessEqual[t, -5.2e-77], N[(N[((-z) / t), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[t, 1.1e+32], N[(z * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.95 \cdot 10^{+189}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq -5.2 \cdot 10^{-77}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-z}{t}, y, x\right)\\
\mathbf{elif}\;t \leq 1.1 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -1.95e189 or 1.1e32 < t Initial program 61.6%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6488.2
Applied rewrites88.2%
if -1.95e189 < t < -5.2000000000000002e-77Initial program 92.1%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
div-subN/A
*-inversesN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6483.0
Applied rewrites83.0%
Taylor expanded in z around inf
Applied rewrites78.4%
if -5.2000000000000002e-77 < t < 1.1e32Initial program 96.0%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6496.6
Applied rewrites96.6%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6477.9
Applied rewrites77.9%
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (fma (- 1.0 (/ z t)) y x)))
(if (<= t -0.000205)
t_1
(if (<= t 1.26e+33) (+ (/ (* z y) (- a t)) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((1.0 - (z / t)), y, x);
double tmp;
if (t <= -0.000205) {
tmp = t_1;
} else if (t <= 1.26e+33) {
tmp = ((z * y) / (a - t)) + x;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(1.0 - Float64(z / t)), y, x) tmp = 0.0 if (t <= -0.000205) tmp = t_1; elseif (t <= 1.26e+33) tmp = Float64(Float64(Float64(z * y) / Float64(a - t)) + x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -0.000205], t$95$1, If[LessEqual[t, 1.26e+33], N[(N[(N[(z * y), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -0.000205:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.26 \cdot 10^{+33}:\\
\;\;\;\;\frac{z \cdot y}{a - t} + x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.05e-4 or 1.26e33 < t Initial program 70.3%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
div-subN/A
*-inversesN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6492.6
Applied rewrites92.6%
if -2.05e-4 < t < 1.26e33Initial program 96.6%
Taylor expanded in z around inf
*-commutativeN/A
lower-*.f6487.3
Applied rewrites87.3%
Final simplification89.7%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (- 1.0 (/ z t)) y x))) (if (<= t -9.5e+129) t_1 (if (<= t 7.5e+33) (fma (/ z (- a t)) y x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((1.0 - (z / t)), y, x);
double tmp;
if (t <= -9.5e+129) {
tmp = t_1;
} else if (t <= 7.5e+33) {
tmp = fma((z / (a - t)), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(1.0 - Float64(z / t)), y, x) tmp = 0.0 if (t <= -9.5e+129) tmp = t_1; elseif (t <= 7.5e+33) tmp = fma(Float64(z / Float64(a - t)), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -9.5e+129], t$95$1, If[LessEqual[t, 7.5e+33], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -9.5 \cdot 10^{+129}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 7.5 \cdot 10^{+33}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -9.5000000000000004e129 or 7.50000000000000046e33 < t Initial program 66.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
div-subN/A
*-inversesN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6496.2
Applied rewrites96.2%
if -9.5000000000000004e129 < t < 7.50000000000000046e33Initial program 95.3%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.7
Applied rewrites95.7%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6485.3
Applied rewrites85.3%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (- 1.0 (/ z t)) y x))) (if (<= t -3.3e-77) t_1 (if (<= t 2.45e+73) (fma (- z t) (/ y a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((1.0 - (z / t)), y, x);
double tmp;
if (t <= -3.3e-77) {
tmp = t_1;
} else if (t <= 2.45e+73) {
tmp = fma((z - t), (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(1.0 - Float64(z / t)), y, x) tmp = 0.0 if (t <= -3.3e-77) tmp = t_1; elseif (t <= 2.45e+73) tmp = fma(Float64(z - t), Float64(y / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -3.3e-77], t$95$1, If[LessEqual[t, 2.45e+73], N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -3.3 \cdot 10^{-77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.45 \cdot 10^{+73}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.29999999999999991e-77 or 2.45e73 < t Initial program 73.9%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
div-subN/A
*-inversesN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6491.2
Applied rewrites91.2%
if -3.29999999999999991e-77 < t < 2.45e73Initial program 96.2%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6481.8
Applied rewrites81.8%
(FPCore (x y z t a) :precision binary64 (let* ((t_1 (fma (- 1.0 (/ z t)) y x))) (if (<= t -2.4e-77) t_1 (if (<= t 1.86e-88) (fma z (/ y a) x) t_1))))
double code(double x, double y, double z, double t, double a) {
double t_1 = fma((1.0 - (z / t)), y, x);
double tmp;
if (t <= -2.4e-77) {
tmp = t_1;
} else if (t <= 1.86e-88) {
tmp = fma(z, (y / a), x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t, a) t_1 = fma(Float64(1.0 - Float64(z / t)), y, x) tmp = 0.0 if (t <= -2.4e-77) tmp = t_1; elseif (t <= 1.86e-88) tmp = fma(z, Float64(y / a), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(1.0 - N[(z / t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -2.4e-77], t$95$1, If[LessEqual[t, 1.86e-88], N[(z * N[(y / a), $MachinePrecision] + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(1 - \frac{z}{t}, y, x\right)\\
\mathbf{if}\;t \leq -2.4 \cdot 10^{-77}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.86 \cdot 10^{-88}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.3999999999999999e-77 or 1.85999999999999991e-88 < t Initial program 78.3%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
associate-/l*N/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
neg-sub0N/A
div-subN/A
*-inversesN/A
associate-+l-N/A
neg-sub0N/A
mul-1-negN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f6485.4
Applied rewrites85.4%
if -2.3999999999999999e-77 < t < 1.85999999999999991e-88Initial program 96.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6495.6
Applied rewrites95.6%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6482.7
Applied rewrites82.7%
(FPCore (x y z t a) :precision binary64 (if (<= t -4.6e-29) (+ y x) (if (<= t 1.1e+32) (fma z (/ y a) x) (+ y x))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -4.6e-29) {
tmp = y + x;
} else if (t <= 1.1e+32) {
tmp = fma(z, (y / a), x);
} else {
tmp = y + x;
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -4.6e-29) tmp = Float64(y + x); elseif (t <= 1.1e+32) tmp = fma(z, Float64(y / a), x); else tmp = Float64(y + x); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -4.6e-29], N[(y + x), $MachinePrecision], If[LessEqual[t, 1.1e+32], N[(z * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(y + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{-29}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 1.1 \cdot 10^{+32}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if t < -4.59999999999999982e-29 or 1.1e32 < t Initial program 71.5%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6479.5
Applied rewrites79.5%
if -4.59999999999999982e-29 < t < 1.1e32Initial program 96.5%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
lower-/.f64N/A
lower-/.f6496.3
Applied rewrites96.3%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f6474.2
Applied rewrites74.2%
(FPCore (x y z t a) :precision binary64 (fma (/ (- z t) (- a t)) y x))
double code(double x, double y, double z, double t, double a) {
return fma(((z - t) / (a - t)), y, x);
}
function code(x, y, z, t, a) return fma(Float64(Float64(z - t) / Float64(a - t)), y, x) end
code[x_, y_, z_, t_, a_] := N[(N[(N[(z - t), $MachinePrecision] / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z - t}{a - t}, y, x\right)
\end{array}
Initial program 84.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.2
Applied rewrites97.2%
(FPCore (x y z t a) :precision binary64 (fma (/ y (- a t)) (- z t) x))
double code(double x, double y, double z, double t, double a) {
return fma((y / (a - t)), (z - t), x);
}
function code(x, y, z, t, a) return fma(Float64(y / Float64(a - t)), Float64(z - t), x) end
code[x_, y_, z_, t_, a_] := N[(N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision] * N[(z - t), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{y}{a - t}, z - t, x\right)
\end{array}
Initial program 84.9%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6494.9
Applied rewrites94.9%
(FPCore (x y z t a) :precision binary64 (+ y x))
double code(double x, double y, double z, double t, double a) {
return y + x;
}
real(8) function code(x, y, z, t, a)
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
code = y + x
end function
public static double code(double x, double y, double z, double t, double a) {
return y + x;
}
def code(x, y, z, t, a): return y + x
function code(x, y, z, t, a) return Float64(y + x) end
function tmp = code(x, y, z, t, a) tmp = y + x; end
code[x_, y_, z_, t_, a_] := N[(y + x), $MachinePrecision]
\begin{array}{l}
\\
y + x
\end{array}
Initial program 84.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6462.3
Applied rewrites62.3%
(FPCore (x y z t a) :precision binary64 (+ x (/ y (/ (- a t) (- z t)))))
double code(double x, double y, double z, double t, double a) {
return x + (y / ((a - t) / (z - t)));
}
real(8) function code(x, y, z, t, a)
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
code = x + (y / ((a - t) / (z - t)))
end function
public static double code(double x, double y, double z, double t, double a) {
return x + (y / ((a - t) / (z - t)));
}
def code(x, y, z, t, a): return x + (y / ((a - t) / (z - t)))
function code(x, y, z, t, a) return Float64(x + Float64(y / Float64(Float64(a - t) / Float64(z - t)))) end
function tmp = code(x, y, z, t, a) tmp = x + (y / ((a - t) / (z - t))); end
code[x_, y_, z_, t_, a_] := N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + \frac{y}{\frac{a - t}{z - t}}
\end{array}
herbie shell --seed 2024294
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, B"
:precision binary64
:alt
(! :herbie-platform default (+ x (/ y (/ (- a t) (- z t)))))
(+ x (/ (* y (- z t)) (- a t))))