
(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 7 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 (/ (- 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}
Initial program 84.4%
associate-*l/87.6%
Simplified87.6%
associate-/r/96.1%
Applied egg-rr96.1%
Final simplification96.1%
(FPCore (x y z t) :precision binary64 (if (<= z -2.15e+150) (/ (- x) (/ z (- y z))) (if (<= z 3.55e+254) (* (- y z) (/ x (- t z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.15e+150) {
tmp = -x / (z / (y - z));
} else if (z <= 3.55e+254) {
tmp = (y - z) * (x / (t - z));
} 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 <= (-2.15d+150)) then
tmp = -x / (z / (y - z))
else if (z <= 3.55d+254) then
tmp = (y - z) * (x / (t - z))
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 <= -2.15e+150) {
tmp = -x / (z / (y - z));
} else if (z <= 3.55e+254) {
tmp = (y - z) * (x / (t - z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.15e+150: tmp = -x / (z / (y - z)) elif z <= 3.55e+254: tmp = (y - z) * (x / (t - z)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.15e+150) tmp = Float64(Float64(-x) / Float64(z / Float64(y - z))); elseif (z <= 3.55e+254) tmp = Float64(Float64(y - z) * Float64(x / Float64(t - z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.15e+150) tmp = -x / (z / (y - z)); elseif (z <= 3.55e+254) tmp = (y - z) * (x / (t - z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.15e+150], N[((-x) / N[(z / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.55e+254], N[(N[(y - z), $MachinePrecision] * N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.15 \cdot 10^{+150}:\\
\;\;\;\;\frac{-x}{\frac{z}{y - z}}\\
\mathbf{elif}\;z \leq 3.55 \cdot 10^{+254}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.14999999999999999e150Initial program 59.4%
associate-*l/62.9%
Simplified62.9%
Taylor expanded in t around 0 53.0%
mul-1-neg53.0%
associate-/l*93.5%
distribute-neg-frac93.5%
Simplified93.5%
if -2.14999999999999999e150 < z < 3.54999999999999997e254Initial program 89.4%
associate-*l/92.3%
Simplified92.3%
if 3.54999999999999997e254 < z Initial program 56.4%
associate-*l/62.9%
Simplified62.9%
Taylor expanded in z around inf 100.0%
Final simplification92.9%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.15e+49) (not (<= z 5.5e+53))) (/ (- x) (/ z (- y z))) (/ (* x y) (- t z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.15e+49) || !(z <= 5.5e+53)) {
tmp = -x / (z / (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.15d+49)) .or. (.not. (z <= 5.5d+53))) then
tmp = -x / (z / (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.15e+49) || !(z <= 5.5e+53)) {
tmp = -x / (z / (y - z));
} else {
tmp = (x * y) / (t - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.15e+49) or not (z <= 5.5e+53): tmp = -x / (z / (y - z)) else: tmp = (x * y) / (t - z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.15e+49) || !(z <= 5.5e+53)) tmp = Float64(Float64(-x) / Float64(z / Float64(y - z))); else tmp = Float64(Float64(x * y) / Float64(t - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -1.15e+49) || ~((z <= 5.5e+53))) tmp = -x / (z / (y - z)); else tmp = (x * y) / (t - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.15e+49], N[Not[LessEqual[z, 5.5e+53]], $MachinePrecision]], N[((-x) / N[(z / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{+49} \lor \neg \left(z \leq 5.5 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{-x}{\frac{z}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{t - z}\\
\end{array}
\end{array}
if z < -1.15000000000000001e49 or 5.49999999999999975e53 < z Initial program 68.4%
associate-*l/77.9%
Simplified77.9%
Taylor expanded in t around 0 54.4%
mul-1-neg54.4%
associate-/l*82.1%
distribute-neg-frac82.1%
Simplified82.1%
if -1.15000000000000001e49 < z < 5.49999999999999975e53Initial program 94.5%
associate-*l/93.7%
Simplified93.7%
Taylor expanded in y around inf 78.6%
Final simplification79.9%
(FPCore (x y z t) :precision binary64 (if (<= z -6.5e+81) x (if (<= z 4.5e+112) (* y (/ x (- t z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.5e+81) {
tmp = x;
} else if (z <= 4.5e+112) {
tmp = y * (x / (t - z));
} 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.5d+81)) then
tmp = x
else if (z <= 4.5d+112) then
tmp = y * (x / (t - z))
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.5e+81) {
tmp = x;
} else if (z <= 4.5e+112) {
tmp = y * (x / (t - z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6.5e+81: tmp = x elif z <= 4.5e+112: tmp = y * (x / (t - z)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6.5e+81) tmp = x; elseif (z <= 4.5e+112) tmp = Float64(y * Float64(x / Float64(t - z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -6.5e+81) tmp = x; elseif (z <= 4.5e+112) tmp = y * (x / (t - z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.5e+81], x, If[LessEqual[z, 4.5e+112], N[(y * N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.5 \cdot 10^{+81}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{+112}:\\
\;\;\;\;y \cdot \frac{x}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.4999999999999996e81 or 4.4999999999999999e112 < z Initial program 64.9%
associate-*l/75.4%
Simplified75.4%
Taylor expanded in z around inf 81.1%
if -6.4999999999999996e81 < z < 4.4999999999999999e112Initial program 93.4%
associate-*l/93.3%
Simplified93.3%
Taylor expanded in y around inf 74.9%
associate-*l/75.7%
*-commutative75.7%
Simplified75.7%
Final simplification77.4%
(FPCore (x y z t) :precision binary64 (if (<= z -2.4e+79) x (if (<= z 3.6e+121) (* x (/ y (- t z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -2.4e+79) {
tmp = x;
} else if (z <= 3.6e+121) {
tmp = x * (y / (t - z));
} 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 <= (-2.4d+79)) then
tmp = x
else if (z <= 3.6d+121) then
tmp = x * (y / (t - z))
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 <= -2.4e+79) {
tmp = x;
} else if (z <= 3.6e+121) {
tmp = x * (y / (t - z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -2.4e+79: tmp = x elif z <= 3.6e+121: tmp = x * (y / (t - z)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -2.4e+79) tmp = x; elseif (z <= 3.6e+121) tmp = Float64(x * Float64(y / Float64(t - z))); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -2.4e+79) tmp = x; elseif (z <= 3.6e+121) tmp = x * (y / (t - z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -2.4e+79], x, If[LessEqual[z, 3.6e+121], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.4 \cdot 10^{+79}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 3.6 \cdot 10^{+121}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -2.39999999999999986e79 or 3.59999999999999981e121 < z Initial program 63.1%
associate-*l/75.5%
Simplified75.5%
Taylor expanded in z around inf 83.8%
if -2.39999999999999986e79 < z < 3.59999999999999981e121Initial program 93.6%
associate-*l/92.8%
Simplified92.8%
Taylor expanded in y around inf 74.4%
*-commutative74.4%
associate-/l*74.2%
associate-/r/75.0%
Simplified75.0%
Final simplification77.6%
(FPCore (x y z t) :precision binary64 (if (<= z -7.3e+49) x (if (<= z 1.32e+50) (* x (/ y t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.3e+49) {
tmp = x;
} else if (z <= 1.32e+50) {
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 <= (-7.3d+49)) then
tmp = x
else if (z <= 1.32d+50) 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 <= -7.3e+49) {
tmp = x;
} else if (z <= 1.32e+50) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.3e+49: tmp = x elif z <= 1.32e+50: tmp = x * (y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.3e+49) tmp = x; elseif (z <= 1.32e+50) 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 <= -7.3e+49) tmp = x; elseif (z <= 1.32e+50) tmp = x * (y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.3e+49], x, If[LessEqual[z, 1.32e+50], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.3 \cdot 10^{+49}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.32 \cdot 10^{+50}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -7.30000000000000014e49 or 1.3199999999999999e50 < z Initial program 69.0%
associate-*l/78.3%
Simplified78.3%
Taylor expanded in z around inf 71.5%
if -7.30000000000000014e49 < z < 1.3199999999999999e50Initial program 94.4%
associate-*l/93.7%
Simplified93.7%
associate-/r/93.6%
Applied egg-rr93.6%
Taylor expanded in z around 0 65.4%
associate-*r/66.5%
Simplified66.5%
Final simplification68.4%
(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.4%
associate-*l/87.6%
Simplified87.6%
Taylor expanded in z around inf 34.9%
Final simplification34.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 2023297
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
:precision binary64
:herbie-target
(/ x (/ (- t z) (- y z)))
(/ (* x (- y z)) (- t z)))