
(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 9 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 (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 86.7%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.1
Applied rewrites98.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.7e-69) (not (<= z 5.8e+116))) (fma (/ z (- a t)) y x) (- x (* y (/ t (- a t))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.7e-69) || !(z <= 5.8e+116)) {
tmp = fma((z / (a - t)), y, x);
} else {
tmp = x - (y * (t / (a - t)));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.7e-69) || !(z <= 5.8e+116)) tmp = fma(Float64(z / Float64(a - t)), y, x); else tmp = Float64(x - Float64(y * Float64(t / Float64(a - t)))); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.7e-69], N[Not[LessEqual[z, 5.8e+116]], $MachinePrecision]], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(x - N[(y * N[(t / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.7 \cdot 10^{-69} \lor \neg \left(z \leq 5.8 \cdot 10^{+116}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{t}{a - t}\\
\end{array}
\end{array}
if z < -1.70000000000000004e-69 or 5.8000000000000003e116 < z Initial program 87.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6495.8
Applied rewrites95.8%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6486.9
Applied rewrites86.9%
if -1.70000000000000004e-69 < z < 5.8000000000000003e116Initial program 85.7%
Taylor expanded in z around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6491.5
Applied rewrites91.5%
Final simplification89.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= y -8.6e+106) (not (<= y 1.02e+180))) (* (- z t) (/ y (- a t))) (fma (/ z (- a t)) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((y <= -8.6e+106) || !(y <= 1.02e+180)) {
tmp = (z - t) * (y / (a - t));
} else {
tmp = fma((z / (a - t)), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((y <= -8.6e+106) || !(y <= 1.02e+180)) tmp = Float64(Float64(z - t) * Float64(y / Float64(a - t))); else tmp = fma(Float64(z / Float64(a - t)), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[y, -8.6e+106], N[Not[LessEqual[y, 1.02e+180]], $MachinePrecision]], N[(N[(z - t), $MachinePrecision] * N[(y / N[(a - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.6 \cdot 10^{+106} \lor \neg \left(y \leq 1.02 \cdot 10^{+180}\right):\\
\;\;\;\;\left(z - t\right) \cdot \frac{y}{a - t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\end{array}
\end{array}
if y < -8.5999999999999999e106 or 1.02e180 < y Initial program 64.7%
Taylor expanded in x around 0
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower--.f64N/A
lower-/.f64N/A
lower--.f6479.8
Applied rewrites79.8%
if -8.5999999999999999e106 < y < 1.02e180Initial program 94.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6497.4
Applied rewrites97.4%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6485.3
Applied rewrites85.3%
Final simplification83.8%
(FPCore (x y z t a) :precision binary64 (if (<= t -3900000.0) (+ y x) (if (<= t 4.8e+80) (fma (/ z (- a t)) y x) (fma (/ y t) a (+ x y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -3900000.0) {
tmp = y + x;
} else if (t <= 4.8e+80) {
tmp = fma((z / (a - t)), y, x);
} else {
tmp = fma((y / t), a, (x + y));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -3900000.0) tmp = Float64(y + x); elseif (t <= 4.8e+80) tmp = fma(Float64(z / Float64(a - t)), y, x); else tmp = fma(Float64(y / t), a, Float64(x + y)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -3900000.0], N[(y + x), $MachinePrecision], If[LessEqual[t, 4.8e+80], N[(N[(z / N[(a - t), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(y / t), $MachinePrecision] * a + N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3900000:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 4.8 \cdot 10^{+80}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a - t}, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, a, x + y\right)\\
\end{array}
\end{array}
if t < -3.9e6Initial program 78.4%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6474.6
Applied rewrites74.6%
if -3.9e6 < t < 4.79999999999999958e80Initial program 93.8%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6496.8
Applied rewrites96.8%
Taylor expanded in z around inf
lower-/.f64N/A
lower--.f6487.2
Applied rewrites87.2%
if 4.79999999999999958e80 < t Initial program 72.8%
Taylor expanded in z around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6487.2
Applied rewrites87.2%
Taylor expanded in t around inf
Applied rewrites83.3%
Final simplification83.7%
(FPCore (x y z t a) :precision binary64 (if (<= t -1.42e+17) (+ y x) (if (<= t 1.15e+79) (fma (- z t) (/ y a) x) (fma (/ y t) a (+ x y)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -1.42e+17) {
tmp = y + x;
} else if (t <= 1.15e+79) {
tmp = fma((z - t), (y / a), x);
} else {
tmp = fma((y / t), a, (x + y));
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if (t <= -1.42e+17) tmp = Float64(y + x); elseif (t <= 1.15e+79) tmp = fma(Float64(z - t), Float64(y / a), x); else tmp = fma(Float64(y / t), a, Float64(x + y)); end return tmp end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -1.42e+17], N[(y + x), $MachinePrecision], If[LessEqual[t, 1.15e+79], N[(N[(z - t), $MachinePrecision] * N[(y / a), $MachinePrecision] + x), $MachinePrecision], N[(N[(y / t), $MachinePrecision] * a + N[(x + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.42 \cdot 10^{+17}:\\
\;\;\;\;y + x\\
\mathbf{elif}\;t \leq 1.15 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(z - t, \frac{y}{a}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{y}{t}, a, x + y\right)\\
\end{array}
\end{array}
if t < -1.42e17Initial program 76.9%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6474.6
Applied rewrites74.6%
if -1.42e17 < t < 1.15e79Initial program 93.8%
Taylor expanded in a around inf
+-commutativeN/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower--.f64N/A
lower-/.f6481.3
Applied rewrites81.3%
if 1.15e79 < t Initial program 74.0%
Taylor expanded in z around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6487.7
Applied rewrites87.7%
Taylor expanded in t around inf
Applied rewrites81.9%
Final simplification80.0%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1500000.0) (not (<= t 4.8e+23))) (+ y x) (+ x (* (/ y a) z))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1500000.0) || !(t <= 4.8e+23)) {
tmp = y + x;
} else {
tmp = x + ((y / a) * z);
}
return tmp;
}
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
real(8) :: tmp
if ((t <= (-1500000.0d0)) .or. (.not. (t <= 4.8d+23))) then
tmp = y + x
else
tmp = x + ((y / a) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1500000.0) || !(t <= 4.8e+23)) {
tmp = y + x;
} else {
tmp = x + ((y / a) * z);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -1500000.0) or not (t <= 4.8e+23): tmp = y + x else: tmp = x + ((y / a) * z) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1500000.0) || !(t <= 4.8e+23)) tmp = Float64(y + x); else tmp = Float64(x + Float64(Float64(y / a) * z)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -1500000.0) || ~((t <= 4.8e+23))) tmp = y + x; else tmp = x + ((y / a) * z); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1500000.0], N[Not[LessEqual[t, 4.8e+23]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(x + N[(N[(y / a), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1500000 \lor \neg \left(t \leq 4.8 \cdot 10^{+23}\right):\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{a} \cdot z\\
\end{array}
\end{array}
if t < -1.5e6 or 4.8e23 < t Initial program 76.4%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6475.6
Applied rewrites75.6%
if -1.5e6 < t < 4.8e23Initial program 95.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6476.9
Applied rewrites76.9%
Applied rewrites78.9%
Final simplification77.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1500000.0) (not (<= t 4.8e+23))) (+ y x) (fma (/ z a) y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1500000.0) || !(t <= 4.8e+23)) {
tmp = y + x;
} else {
tmp = fma((z / a), y, x);
}
return tmp;
}
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1500000.0) || !(t <= 4.8e+23)) tmp = Float64(y + x); else tmp = fma(Float64(z / a), y, x); end return tmp end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1500000.0], N[Not[LessEqual[t, 4.8e+23]], $MachinePrecision]], N[(y + x), $MachinePrecision], N[(N[(z / a), $MachinePrecision] * y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1500000 \lor \neg \left(t \leq 4.8 \cdot 10^{+23}\right):\\
\;\;\;\;y + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{a}, y, x\right)\\
\end{array}
\end{array}
if t < -1.5e6 or 4.8e23 < t Initial program 76.4%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6475.6
Applied rewrites75.6%
if -1.5e6 < t < 4.8e23Initial program 95.8%
Taylor expanded in t around 0
+-commutativeN/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6477.1
Applied rewrites77.1%
Final simplification76.4%
(FPCore (x y z t a) :precision binary64 (if (or (<= z -1.02e+212) (not (<= z 7.5e+244))) (* z (/ y a)) (+ y x)))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.02e+212) || !(z <= 7.5e+244)) {
tmp = z * (y / a);
} else {
tmp = y + x;
}
return tmp;
}
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
real(8) :: tmp
if ((z <= (-1.02d+212)) .or. (.not. (z <= 7.5d+244))) then
tmp = z * (y / a)
else
tmp = y + x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((z <= -1.02e+212) || !(z <= 7.5e+244)) {
tmp = z * (y / a);
} else {
tmp = y + x;
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (z <= -1.02e+212) or not (z <= 7.5e+244): tmp = z * (y / a) else: tmp = y + x return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((z <= -1.02e+212) || !(z <= 7.5e+244)) tmp = Float64(z * Float64(y / a)); else tmp = Float64(y + x); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((z <= -1.02e+212) || ~((z <= 7.5e+244))) tmp = z * (y / a); else tmp = y + x; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[z, -1.02e+212], N[Not[LessEqual[z, 7.5e+244]], $MachinePrecision]], N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision], N[(y + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.02 \cdot 10^{+212} \lor \neg \left(z \leq 7.5 \cdot 10^{+244}\right):\\
\;\;\;\;z \cdot \frac{y}{a}\\
\mathbf{else}:\\
\;\;\;\;y + x\\
\end{array}
\end{array}
if z < -1.01999999999999992e212 or 7.5e244 < z Initial program 79.4%
lift-+.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6491.0
Applied rewrites91.0%
Taylor expanded in z around inf
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
lower--.f6463.6
Applied rewrites63.6%
Taylor expanded in t around 0
Applied rewrites54.4%
Applied rewrites60.3%
if -1.01999999999999992e212 < z < 7.5e244Initial program 87.7%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6464.3
Applied rewrites64.3%
Final simplification63.8%
(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 86.7%
Taylor expanded in t around inf
+-commutativeN/A
lower-+.f6459.7
Applied rewrites59.7%
Final simplification59.7%
(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 2024339
(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))))