
(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 (if (or (<= z -8.4e+27) (not (<= z 2.55e-114))) (* x (/ (- y z) (- t z))) (/ (* x (- y z)) (- t z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.4e+27) || !(z <= 2.55e-114)) {
tmp = x * ((y - z) / (t - z));
} else {
tmp = (x * (y - z)) / (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 <= (-8.4d+27)) .or. (.not. (z <= 2.55d-114))) then
tmp = x * ((y - z) / (t - z))
else
tmp = (x * (y - z)) / (t - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8.4e+27) || !(z <= 2.55e-114)) {
tmp = x * ((y - z) / (t - z));
} else {
tmp = (x * (y - z)) / (t - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -8.4e+27) or not (z <= 2.55e-114): tmp = x * ((y - z) / (t - z)) else: tmp = (x * (y - z)) / (t - z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -8.4e+27) || !(z <= 2.55e-114)) tmp = Float64(x * Float64(Float64(y - z) / Float64(t - z))); else tmp = Float64(Float64(x * Float64(y - z)) / Float64(t - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -8.4e+27) || ~((z <= 2.55e-114))) tmp = x * ((y - z) / (t - z)); else tmp = (x * (y - z)) / (t - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -8.4e+27], N[Not[LessEqual[z, 2.55e-114]], $MachinePrecision]], N[(x * N[(N[(y - z), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{+27} \lor \neg \left(z \leq 2.55 \cdot 10^{-114}\right):\\
\;\;\;\;x \cdot \frac{y - z}{t - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y - z\right)}{t - z}\\
\end{array}
\end{array}
if z < -8.39999999999999978e27 or 2.55e-114 < z Initial program 78.4%
associate-/l*99.8%
Simplified99.8%
if -8.39999999999999978e27 < z < 2.55e-114Initial program 98.7%
Final simplification99.3%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.05e-27) (not (<= z 1.9e-9))) (* x (- 1.0 (/ y z))) (* x (/ y (- t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.05e-27) || !(z <= 1.9e-9)) {
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 <= (-1.05d-27)) .or. (.not. (z <= 1.9d-9))) 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 <= -1.05e-27) || !(z <= 1.9e-9)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = x * (y / (t - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.05e-27) or not (z <= 1.9e-9): 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 <= -1.05e-27) || !(z <= 1.9e-9)) 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 <= -1.05e-27) || ~((z <= 1.9e-9))) 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, -1.05e-27], N[Not[LessEqual[z, 1.9e-9]], $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 -1.05 \cdot 10^{-27} \lor \neg \left(z \leq 1.9 \cdot 10^{-9}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\end{array}
\end{array}
if z < -1.05000000000000008e-27 or 1.90000000000000006e-9 < z Initial program 77.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in t around 0 58.5%
mul-1-neg58.5%
associate-/l*77.6%
distribute-rgt-neg-in77.6%
distribute-frac-neg77.6%
sub-neg77.6%
distribute-neg-in77.6%
remove-double-neg77.6%
+-commutative77.6%
sub-neg77.6%
div-sub77.6%
*-inverses77.6%
Simplified77.6%
if -1.05000000000000008e-27 < z < 1.90000000000000006e-9Initial program 97.2%
associate-/l*90.2%
Simplified90.2%
Taylor expanded in y around inf 84.3%
associate-/l*78.8%
Simplified78.8%
Final simplification78.2%
(FPCore (x y z t) :precision binary64 (if (or (<= z -9.5e-101) (not (<= z 1.1e-82))) (* x (- 1.0 (/ y z))) (/ (* x y) t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -9.5e-101) || !(z <= 1.1e-82)) {
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 <= (-9.5d-101)) .or. (.not. (z <= 1.1d-82))) 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 <= -9.5e-101) || !(z <= 1.1e-82)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = (x * y) / t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -9.5e-101) or not (z <= 1.1e-82): tmp = x * (1.0 - (y / z)) else: tmp = (x * y) / t return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -9.5e-101) || !(z <= 1.1e-82)) 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 <= -9.5e-101) || ~((z <= 1.1e-82))) 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, -9.5e-101], N[Not[LessEqual[z, 1.1e-82]], $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 -9.5 \cdot 10^{-101} \lor \neg \left(z \leq 1.1 \cdot 10^{-82}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{t}\\
\end{array}
\end{array}
if z < -9.49999999999999994e-101 or 1.09999999999999993e-82 < z Initial program 80.8%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in t around 0 57.7%
mul-1-neg57.7%
associate-/l*73.9%
distribute-rgt-neg-in73.9%
distribute-frac-neg73.9%
sub-neg73.9%
distribute-neg-in73.9%
remove-double-neg73.9%
+-commutative73.9%
sub-neg73.9%
div-sub73.9%
*-inverses73.9%
Simplified73.9%
if -9.49999999999999994e-101 < z < 1.09999999999999993e-82Initial program 98.4%
associate-/l*87.2%
Simplified87.2%
Taylor expanded in z around 0 79.0%
Final simplification75.7%
(FPCore (x y z t) :precision binary64 (if (<= z -6.8e-28) x (if (<= z 1.25e-9) (/ (* x y) t) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.8e-28) {
tmp = x;
} else if (z <= 1.25e-9) {
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 <= (-6.8d-28)) then
tmp = x
else if (z <= 1.25d-9) 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 <= -6.8e-28) {
tmp = x;
} else if (z <= 1.25e-9) {
tmp = (x * y) / t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6.8e-28: tmp = x elif z <= 1.25e-9: tmp = (x * y) / t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6.8e-28) tmp = x; elseif (z <= 1.25e-9) 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 <= -6.8e-28) tmp = x; elseif (z <= 1.25e-9) tmp = (x * y) / t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.8e-28], x, If[LessEqual[z, 1.25e-9], N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.8 \cdot 10^{-28}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.25 \cdot 10^{-9}:\\
\;\;\;\;\frac{x \cdot y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.8000000000000001e-28 or 1.25e-9 < z Initial program 77.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 59.0%
if -6.8000000000000001e-28 < z < 1.25e-9Initial program 97.2%
associate-/l*90.2%
Simplified90.2%
Taylor expanded in z around 0 68.0%
(FPCore (x y z t) :precision binary64 (if (<= z -9.8e-28) x (if (<= z 8.2e-11) (* x (/ y t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9.8e-28) {
tmp = x;
} else if (z <= 8.2e-11) {
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 <= (-9.8d-28)) then
tmp = x
else if (z <= 8.2d-11) 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 <= -9.8e-28) {
tmp = x;
} else if (z <= 8.2e-11) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9.8e-28: tmp = x elif z <= 8.2e-11: tmp = x * (y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9.8e-28) tmp = x; elseif (z <= 8.2e-11) 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 <= -9.8e-28) tmp = x; elseif (z <= 8.2e-11) tmp = x * (y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9.8e-28], x, If[LessEqual[z, 8.2e-11], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.8 \cdot 10^{-28}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 8.2 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -9.80000000000000059e-28 or 8.2000000000000001e-11 < z Initial program 77.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 59.0%
if -9.80000000000000059e-28 < z < 8.2000000000000001e-11Initial program 97.2%
associate-/l*90.2%
Simplified90.2%
Taylor expanded in z around 0 68.0%
associate-/l*63.5%
Simplified63.5%
(FPCore (x y z t) :precision binary64 (if (<= x 7.8e+242) (* x (/ (- y z) (- t z))) (* (- z y) (/ x (- z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 7.8e+242) {
tmp = x * ((y - z) / (t - z));
} else {
tmp = (z - y) * (x / (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 (x <= 7.8d+242) then
tmp = x * ((y - z) / (t - z))
else
tmp = (z - y) * (x / (z - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 7.8e+242) {
tmp = x * ((y - z) / (t - z));
} else {
tmp = (z - y) * (x / (z - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 7.8e+242: tmp = x * ((y - z) / (t - z)) else: tmp = (z - y) * (x / (z - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 7.8e+242) tmp = Float64(x * Float64(Float64(y - z) / Float64(t - z))); else tmp = Float64(Float64(z - y) * Float64(x / Float64(z - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 7.8e+242) tmp = x * ((y - z) / (t - z)); else tmp = (z - y) * (x / (z - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 7.8e+242], N[(x * N[(N[(y - z), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z - y), $MachinePrecision] * N[(x / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.8 \cdot 10^{+242}:\\
\;\;\;\;x \cdot \frac{y - z}{t - z}\\
\mathbf{else}:\\
\;\;\;\;\left(z - y\right) \cdot \frac{x}{z - t}\\
\end{array}
\end{array}
if x < 7.8000000000000003e242Initial program 89.3%
associate-/l*95.4%
Simplified95.4%
if 7.8000000000000003e242 < x Initial program 42.4%
remove-double-neg42.4%
distribute-lft-neg-out42.4%
distribute-neg-frac42.4%
distribute-neg-frac242.4%
distribute-lft-neg-out42.4%
distribute-rgt-neg-in42.4%
sub-neg42.4%
distribute-neg-in42.4%
remove-double-neg42.4%
+-commutative42.4%
sub-neg42.4%
sub-neg42.4%
distribute-neg-in42.4%
remove-double-neg42.4%
+-commutative42.4%
sub-neg42.4%
Simplified42.4%
*-commutative42.4%
associate-/l*99.6%
Applied egg-rr99.6%
(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 87.3%
associate-/l*95.2%
Simplified95.2%
(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 87.3%
associate-/l*95.2%
Simplified95.2%
Taylor expanded in z around inf 33.9%
(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 2024144
(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)))