
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (x * (y - z)) / (t - z)
end function
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{t - z}
\end{array}
(FPCore (x y z t) :precision binary64 (* x (/ (- y z) (- t z))))
double code(double x, double y, double z, double t) {
return x * ((y - z) / (t - z));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * ((y - z) / (t - z))
end function
public static double code(double x, double y, double z, double t) {
return x * ((y - z) / (t - z));
}
def code(x, y, z, t): return x * ((y - z) / (t - z))
function code(x, y, z, t) return Float64(x * Float64(Float64(y - z) / Float64(t - z))) end
function tmp = code(x, y, z, t) tmp = x * ((y - z) / (t - z)); end
code[x_, y_, z_, t_] := N[(x * N[(N[(y - z), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{y - z}{t - z}
\end{array}
Initial program 84.3%
associate-/l*97.5%
Simplified97.5%
(FPCore (x y z t) :precision binary64 (if (or (<= y -2e-20) (not (<= y 1.12e+20))) (* x (/ y (- t z))) (* x (/ z (- z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2e-20) || !(y <= 1.12e+20)) {
tmp = x * (y / (t - z));
} else {
tmp = x * (z / (z - t));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-2d-20)) .or. (.not. (y <= 1.12d+20))) then
tmp = x * (y / (t - z))
else
tmp = x * (z / (z - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -2e-20) || !(y <= 1.12e+20)) {
tmp = x * (y / (t - z));
} else {
tmp = x * (z / (z - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -2e-20) or not (y <= 1.12e+20): tmp = x * (y / (t - z)) else: tmp = x * (z / (z - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -2e-20) || !(y <= 1.12e+20)) tmp = Float64(x * Float64(y / Float64(t - z))); else tmp = Float64(x * Float64(z / Float64(z - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -2e-20) || ~((y <= 1.12e+20))) tmp = x * (y / (t - z)); else tmp = x * (z / (z - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -2e-20], N[Not[LessEqual[y, 1.12e+20]], $MachinePrecision]], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-20} \lor \neg \left(y \leq 1.12 \cdot 10^{+20}\right):\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{z}{z - t}\\
\end{array}
\end{array}
if y < -1.99999999999999989e-20 or 1.12e20 < y Initial program 86.6%
associate-/l*97.7%
Simplified97.7%
Taylor expanded in y around inf 70.7%
associate-/l*74.8%
Simplified74.8%
if -1.99999999999999989e-20 < y < 1.12e20Initial program 81.8%
associate-/l*97.3%
Simplified97.3%
Taylor expanded in y around 0 67.2%
mul-1-neg67.2%
distribute-neg-frac267.2%
sub-neg67.2%
distribute-neg-in67.2%
remove-double-neg67.2%
+-commutative67.2%
sub-neg67.2%
associate-/l*83.5%
Simplified83.5%
Final simplification78.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -3.4e-63) (not (<= z 9.2e-7))) (* x (- 1.0 (/ y z))) (* x (/ y (- t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.4e-63) || !(z <= 9.2e-7)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = x * (y / (t - z));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-3.4d-63)) .or. (.not. (z <= 9.2d-7))) then
tmp = x * (1.0d0 - (y / z))
else
tmp = x * (y / (t - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -3.4e-63) || !(z <= 9.2e-7)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = x * (y / (t - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -3.4e-63) or not (z <= 9.2e-7): tmp = x * (1.0 - (y / z)) else: tmp = x * (y / (t - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -3.4e-63) || !(z <= 9.2e-7)) tmp = Float64(x * Float64(1.0 - Float64(y / z))); else tmp = Float64(x * Float64(y / Float64(t - z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -3.4e-63) || ~((z <= 9.2e-7))) tmp = x * (1.0 - (y / z)); else tmp = x * (y / (t - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -3.4e-63], N[Not[LessEqual[z, 9.2e-7]], $MachinePrecision]], N[(x * N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.4 \cdot 10^{-63} \lor \neg \left(z \leq 9.2 \cdot 10^{-7}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\end{array}
\end{array}
if z < -3.39999999999999998e-63 or 9.1999999999999998e-7 < z Initial program 78.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 58.9%
mul-1-neg58.9%
associate-/l*76.3%
distribute-rgt-neg-in76.3%
distribute-frac-neg76.3%
sub-neg76.3%
distribute-neg-in76.3%
remove-double-neg76.3%
+-commutative76.3%
sub-neg76.3%
div-sub76.3%
*-inverses76.3%
Simplified76.3%
if -3.39999999999999998e-63 < z < 9.1999999999999998e-7Initial program 92.0%
associate-/l*94.4%
Simplified94.4%
Taylor expanded in y around inf 78.0%
associate-/l*78.8%
Simplified78.8%
Final simplification77.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.1e-70) (not (<= z 4e-7))) (* x (- 1.0 (/ y z))) (/ (* x y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.1e-70) || !(z <= 4e-7)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = (x * y) / t;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((z <= (-1.1d-70)) .or. (.not. (z <= 4d-7))) then
tmp = x * (1.0d0 - (y / z))
else
tmp = (x * y) / t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.1e-70) || !(z <= 4e-7)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = (x * y) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.1e-70) or not (z <= 4e-7): tmp = x * (1.0 - (y / z)) else: tmp = (x * y) / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.1e-70) || !(z <= 4e-7)) tmp = Float64(x * Float64(1.0 - Float64(y / z))); else tmp = Float64(Float64(x * y) / t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.1e-70) || ~((z <= 4e-7))) tmp = x * (1.0 - (y / z)); else tmp = (x * y) / t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.1e-70], N[Not[LessEqual[z, 4e-7]], $MachinePrecision]], N[(x * N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1 \cdot 10^{-70} \lor \neg \left(z \leq 4 \cdot 10^{-7}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{t}\\
\end{array}
\end{array}
if z < -1.0999999999999999e-70 or 3.9999999999999998e-7 < z Initial program 78.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 58.8%
mul-1-neg58.8%
associate-/l*76.0%
distribute-rgt-neg-in76.0%
distribute-frac-neg76.0%
sub-neg76.0%
distribute-neg-in76.0%
remove-double-neg76.0%
+-commutative76.0%
sub-neg76.0%
div-sub76.0%
*-inverses76.0%
Simplified76.0%
if -1.0999999999999999e-70 < z < 3.9999999999999998e-7Initial program 91.8%
associate-/l*94.3%
Simplified94.3%
Taylor expanded in z around 0 68.0%
Final simplification72.6%
(FPCore (x y z t) :precision binary64 (if (<= z -8e-61) x (if (<= z 1.25e-5) (/ (* x y) t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8e-61) {
tmp = x;
} else if (z <= 1.25e-5) {
tmp = (x * y) / t;
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-8d-61)) then
tmp = x
else if (z <= 1.25d-5) then
tmp = (x * y) / t
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8e-61) {
tmp = x;
} else if (z <= 1.25e-5) {
tmp = (x * y) / t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8e-61: tmp = x elif z <= 1.25e-5: tmp = (x * y) / t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8e-61) tmp = x; elseif (z <= 1.25e-5) tmp = Float64(Float64(x * y) / t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -8e-61) tmp = x; elseif (z <= 1.25e-5) tmp = (x * y) / t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8e-61], x, If[LessEqual[z, 1.25e-5], N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-61}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;\frac{x \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.0000000000000003e-61 or 1.25000000000000006e-5 < z Initial program 78.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 57.1%
if -8.0000000000000003e-61 < z < 1.25000000000000006e-5Initial program 92.0%
associate-/l*94.4%
Simplified94.4%
Taylor expanded in z around 0 67.7%
(FPCore (x y z t) :precision binary64 (if (<= z -6.8e-61) x (if (<= z 3.8e-7) (/ x (/ t y)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.8e-61) {
tmp = x;
} else if (z <= 3.8e-7) {
tmp = x / (t / y);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-6.8d-61)) then
tmp = x
else if (z <= 3.8d-7) then
tmp = x / (t / y)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.8e-61) {
tmp = x;
} else if (z <= 3.8e-7) {
tmp = x / (t / y);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6.8e-61: tmp = x elif z <= 3.8e-7: tmp = x / (t / y) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6.8e-61) tmp = x; elseif (z <= 3.8e-7) tmp = Float64(x / Float64(t / y)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -6.8e-61) tmp = x; elseif (z <= 3.8e-7) tmp = x / (t / y); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.8e-61], x, If[LessEqual[z, 3.8e-7], N[(x / N[(t / y), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.8 \cdot 10^{-61}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{\frac{t}{y}}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.7999999999999996e-61 or 3.80000000000000015e-7 < z Initial program 78.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 57.1%
if -6.7999999999999996e-61 < z < 3.80000000000000015e-7Initial program 92.0%
associate-/l*94.4%
Simplified94.4%
Taylor expanded in x around 0 92.0%
*-rgt-identity92.0%
times-frac89.4%
/-rgt-identity89.4%
associate-/r/94.3%
Simplified94.3%
Taylor expanded in z around 0 67.6%
(FPCore (x y z t) :precision binary64 (if (<= z -1.35e-64) x (if (<= z 1.42e-5) (* x (/ y t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.35e-64) {
tmp = x;
} else if (z <= 1.42e-5) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= (-1.35d-64)) then
tmp = x
else if (z <= 1.42d-5) then
tmp = x * (y / t)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.35e-64) {
tmp = x;
} else if (z <= 1.42e-5) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.35e-64: tmp = x elif z <= 1.42e-5: tmp = x * (y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.35e-64) tmp = x; elseif (z <= 1.42e-5) tmp = Float64(x * Float64(y / t)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -1.35e-64) tmp = x; elseif (z <= 1.42e-5) tmp = x * (y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.35e-64], x, If[LessEqual[z, 1.42e-5], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{-64}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.34999999999999993e-64 or 1.42e-5 < z Initial program 78.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 57.1%
if -1.34999999999999993e-64 < z < 1.42e-5Initial program 92.0%
associate-/l*94.4%
Simplified94.4%
Taylor expanded in z around 0 67.7%
associate-/l*67.6%
Simplified67.6%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 84.3%
associate-/l*97.5%
Simplified97.5%
Taylor expanded in z around inf 37.4%
(FPCore (x y z t) :precision binary64 (/ x (/ (- t z) (- y z))))
double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x / ((t - z) / (y - z))
end function
public static double code(double x, double y, double z, double t) {
return x / ((t - z) / (y - z));
}
def code(x, y, z, t): return x / ((t - z) / (y - z))
function code(x, y, z, t) return Float64(x / Float64(Float64(t - z) / Float64(y - z))) end
function tmp = code(x, y, z, t) tmp = x / ((t - z) / (y - z)); end
code[x_, y_, z_, t_] := N[(x / N[(N[(t - z), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{t - z}{y - z}}
\end{array}
herbie shell --seed 2024128
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
:precision binary64
:alt
(! :herbie-platform default (/ x (/ (- t z) (- y z))))
(/ (* x (- y z)) (- t z)))