
(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 8 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 (+ 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}
Initial program 81.6%
associate-/l*99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -1.08e+105) (not (<= t 3.15e+119))) (+ x y) (+ x (/ y (/ (- a t) z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -1.08e+105) || !(t <= 3.15e+119)) {
tmp = x + y;
} else {
tmp = x + (y / ((a - t) / 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 <= (-1.08d+105)) .or. (.not. (t <= 3.15d+119))) then
tmp = x + y
else
tmp = x + (y / ((a - t) / 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 <= -1.08e+105) || !(t <= 3.15e+119)) {
tmp = x + y;
} else {
tmp = x + (y / ((a - t) / z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -1.08e+105) or not (t <= 3.15e+119): tmp = x + y else: tmp = x + (y / ((a - t) / z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -1.08e+105) || !(t <= 3.15e+119)) tmp = Float64(x + y); else tmp = Float64(x + Float64(y / Float64(Float64(a - t) / z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -1.08e+105) || ~((t <= 3.15e+119))) tmp = x + y; else tmp = x + (y / ((a - t) / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -1.08e+105], N[Not[LessEqual[t, 3.15e+119]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.08 \cdot 10^{+105} \lor \neg \left(t \leq 3.15 \cdot 10^{+119}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z}}\\
\end{array}
\end{array}
if t < -1.07999999999999994e105 or 3.1499999999999999e119 < t Initial program 68.0%
+-commutative68.0%
associate-*l/95.7%
fma-def95.7%
Simplified95.7%
Taylor expanded in t around inf 92.6%
+-commutative92.6%
Simplified92.6%
if -1.07999999999999994e105 < t < 3.1499999999999999e119Initial program 89.1%
associate-/l*98.6%
Simplified98.6%
Taylor expanded in z around inf 78.3%
associate-/l*86.6%
Simplified86.6%
Final simplification88.8%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -4.2e+75) (not (<= t 72000000000000.0))) (- x (/ y (+ (/ a t) -1.0))) (+ x (/ y (/ (- a t) z)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -4.2e+75) || !(t <= 72000000000000.0)) {
tmp = x - (y / ((a / t) + -1.0));
} else {
tmp = x + (y / ((a - t) / 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 <= (-4.2d+75)) .or. (.not. (t <= 72000000000000.0d0))) then
tmp = x - (y / ((a / t) + (-1.0d0)))
else
tmp = x + (y / ((a - t) / 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 <= -4.2e+75) || !(t <= 72000000000000.0)) {
tmp = x - (y / ((a / t) + -1.0));
} else {
tmp = x + (y / ((a - t) / z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -4.2e+75) or not (t <= 72000000000000.0): tmp = x - (y / ((a / t) + -1.0)) else: tmp = x + (y / ((a - t) / z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -4.2e+75) || !(t <= 72000000000000.0)) tmp = Float64(x - Float64(y / Float64(Float64(a / t) + -1.0))); else tmp = Float64(x + Float64(y / Float64(Float64(a - t) / z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -4.2e+75) || ~((t <= 72000000000000.0))) tmp = x - (y / ((a / t) + -1.0)); else tmp = x + (y / ((a - t) / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -4.2e+75], N[Not[LessEqual[t, 72000000000000.0]], $MachinePrecision]], N[(x - N[(y / N[(N[(a / t), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.2 \cdot 10^{+75} \lor \neg \left(t \leq 72000000000000\right):\\
\;\;\;\;x - \frac{y}{\frac{a}{t} + -1}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z}}\\
\end{array}
\end{array}
if t < -4.19999999999999997e75 or 7.2e13 < t Initial program 72.3%
+-commutative72.3%
associate-*l/96.6%
fma-def96.6%
Simplified96.6%
Taylor expanded in z around 0 67.4%
mul-1-neg67.4%
unsub-neg67.4%
*-commutative67.4%
associate-/l*90.0%
div-sub90.0%
sub-neg90.0%
*-inverses90.0%
metadata-eval90.0%
Simplified90.0%
if -4.19999999999999997e75 < t < 7.2e13Initial program 89.2%
associate-/l*98.3%
Simplified98.3%
Taylor expanded in z around inf 81.1%
associate-/l*90.2%
Simplified90.2%
Final simplification90.1%
(FPCore (x y z t a) :precision binary64 (if (<= t -2.9e+106) (+ x y) (if (<= t 1.45e+114) (+ x (/ y (/ (- a t) z))) (+ x (* (/ y t) (- t z))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (t <= -2.9e+106) {
tmp = x + y;
} else if (t <= 1.45e+114) {
tmp = x + (y / ((a - t) / z));
} else {
tmp = x + ((y / t) * (t - 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 <= (-2.9d+106)) then
tmp = x + y
else if (t <= 1.45d+114) then
tmp = x + (y / ((a - t) / z))
else
tmp = x + ((y / t) * (t - 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 <= -2.9e+106) {
tmp = x + y;
} else if (t <= 1.45e+114) {
tmp = x + (y / ((a - t) / z));
} else {
tmp = x + ((y / t) * (t - z));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if t <= -2.9e+106: tmp = x + y elif t <= 1.45e+114: tmp = x + (y / ((a - t) / z)) else: tmp = x + ((y / t) * (t - z)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (t <= -2.9e+106) tmp = Float64(x + y); elseif (t <= 1.45e+114) tmp = Float64(x + Float64(y / Float64(Float64(a - t) / z))); else tmp = Float64(x + Float64(Float64(y / t) * Float64(t - z))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (t <= -2.9e+106) tmp = x + y; elseif (t <= 1.45e+114) tmp = x + (y / ((a - t) / z)); else tmp = x + ((y / t) * (t - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[LessEqual[t, -2.9e+106], N[(x + y), $MachinePrecision], If[LessEqual[t, 1.45e+114], N[(x + N[(y / N[(N[(a - t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y / t), $MachinePrecision] * N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.9 \cdot 10^{+106}:\\
\;\;\;\;x + y\\
\mathbf{elif}\;t \leq 1.45 \cdot 10^{+114}:\\
\;\;\;\;x + \frac{y}{\frac{a - t}{z}}\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y}{t} \cdot \left(t - z\right)\\
\end{array}
\end{array}
if t < -2.9000000000000002e106Initial program 68.3%
+-commutative68.3%
associate-*l/95.6%
fma-def95.6%
Simplified95.6%
Taylor expanded in t around inf 95.9%
+-commutative95.9%
Simplified95.9%
if -2.9000000000000002e106 < t < 1.45e114Initial program 89.0%
associate-/l*98.6%
Simplified98.6%
Taylor expanded in z around inf 78.1%
associate-/l*86.5%
Simplified86.5%
if 1.45e114 < t Initial program 68.3%
+-commutative68.3%
associate-*l/95.8%
fma-def95.8%
Simplified95.8%
Taylor expanded in a around 0 66.3%
mul-1-neg66.3%
unsub-neg66.3%
associate-/l*95.9%
associate-/r/91.9%
Simplified91.9%
Final simplification89.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -6.5e-34) (not (<= t 2.4e+115))) (+ x y) (+ x (/ (* y z) a))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -6.5e-34) || !(t <= 2.4e+115)) {
tmp = x + y;
} else {
tmp = x + ((y * z) / a);
}
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 <= (-6.5d-34)) .or. (.not. (t <= 2.4d+115))) then
tmp = x + y
else
tmp = x + ((y * z) / a)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -6.5e-34) || !(t <= 2.4e+115)) {
tmp = x + y;
} else {
tmp = x + ((y * z) / a);
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -6.5e-34) or not (t <= 2.4e+115): tmp = x + y else: tmp = x + ((y * z) / a) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -6.5e-34) || !(t <= 2.4e+115)) tmp = Float64(x + y); else tmp = Float64(x + Float64(Float64(y * z) / a)); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -6.5e-34) || ~((t <= 2.4e+115))) tmp = x + y; else tmp = x + ((y * z) / a); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -6.5e-34], N[Not[LessEqual[t, 2.4e+115]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(x + N[(N[(y * z), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.5 \cdot 10^{-34} \lor \neg \left(t \leq 2.4 \cdot 10^{+115}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y \cdot z}{a}\\
\end{array}
\end{array}
if t < -6.49999999999999985e-34 or 2.4e115 < t Initial program 70.3%
+-commutative70.3%
associate-*l/96.7%
fma-def96.7%
Simplified96.7%
Taylor expanded in t around inf 85.5%
+-commutative85.5%
Simplified85.5%
if -6.49999999999999985e-34 < t < 2.4e115Initial program 91.5%
associate-/l*98.3%
Simplified98.3%
Taylor expanded in t around 0 73.4%
Final simplification79.1%
(FPCore (x y z t a) :precision binary64 (if (or (<= t -9e-51) (not (<= t 4.5e+115))) (+ x y) (+ x (* z (/ y a)))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -9e-51) || !(t <= 4.5e+115)) {
tmp = x + y;
} else {
tmp = x + (z * (y / a));
}
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 <= (-9d-51)) .or. (.not. (t <= 4.5d+115))) then
tmp = x + y
else
tmp = x + (z * (y / a))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((t <= -9e-51) || !(t <= 4.5e+115)) {
tmp = x + y;
} else {
tmp = x + (z * (y / a));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if (t <= -9e-51) or not (t <= 4.5e+115): tmp = x + y else: tmp = x + (z * (y / a)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if ((t <= -9e-51) || !(t <= 4.5e+115)) tmp = Float64(x + y); else tmp = Float64(x + Float64(z * Float64(y / a))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if ((t <= -9e-51) || ~((t <= 4.5e+115))) tmp = x + y; else tmp = x + (z * (y / a)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Or[LessEqual[t, -9e-51], N[Not[LessEqual[t, 4.5e+115]], $MachinePrecision]], N[(x + y), $MachinePrecision], N[(x + N[(z * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9 \cdot 10^{-51} \lor \neg \left(t \leq 4.5 \cdot 10^{+115}\right):\\
\;\;\;\;x + y\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \frac{y}{a}\\
\end{array}
\end{array}
if t < -8.99999999999999948e-51 or 4.49999999999999963e115 < t Initial program 71.2%
+-commutative71.2%
associate-*l/96.8%
fma-def96.8%
Simplified96.8%
Taylor expanded in t around inf 86.0%
+-commutative86.0%
Simplified86.0%
if -8.99999999999999948e-51 < t < 4.49999999999999963e115Initial program 91.3%
+-commutative91.3%
associate-*l/96.3%
fma-def96.3%
Simplified96.3%
Taylor expanded in t around 0 72.5%
+-commutative72.5%
associate-/l*78.8%
associate-/r/79.6%
Simplified79.6%
Final simplification82.7%
(FPCore (x y z t a) :precision binary64 (+ x y))
double code(double x, double y, double z, double t, double a) {
return x + y;
}
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
end function
public static double code(double x, double y, double z, double t, double a) {
return x + y;
}
def code(x, y, z, t, a): return x + y
function code(x, y, z, t, a) return Float64(x + y) end
function tmp = code(x, y, z, t, a) tmp = x + y; end
code[x_, y_, z_, t_, a_] := N[(x + y), $MachinePrecision]
\begin{array}{l}
\\
x + y
\end{array}
Initial program 81.6%
+-commutative81.6%
associate-*l/96.6%
fma-def96.6%
Simplified96.6%
Taylor expanded in t around inf 63.4%
+-commutative63.4%
Simplified63.4%
Final simplification63.4%
(FPCore (x y z t a) :precision binary64 x)
double code(double x, double y, double z, double t, double a) {
return 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 = x
end function
public static double code(double x, double y, double z, double t, double a) {
return x;
}
def code(x, y, z, t, a): return x
function code(x, y, z, t, a) return x end
function tmp = code(x, y, z, t, a) tmp = x; end
code[x_, y_, z_, t_, a_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 81.6%
+-commutative81.6%
associate-*l/96.6%
fma-def96.6%
Simplified96.6%
Taylor expanded in y around 0 51.2%
Final simplification51.2%
(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 2023310
(FPCore (x y z t a)
:name "Graphics.Rendering.Plot.Render.Plot.Axis:renderAxisTicks from plot-0.2.3.4, B"
:precision binary64
:herbie-target
(+ x (/ y (/ (- a t) (- z t))))
(+ x (/ (* y (- z t)) (- a t))))