
(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 (/ (- 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.4%
associate-*r/96.3%
Simplified96.3%
Final simplification96.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (/ z (- z t)))))
(if (<= z -2.85e+85)
t_1
(if (<= z -5.2e+21)
(* x (/ y (- t z)))
(if (or (<= z -4.1e-29) (not (<= z 6e+103)))
t_1
(* y (/ x (- t z))))))))
double code(double x, double y, double z, double t) {
double t_1 = x * (z / (z - t));
double tmp;
if (z <= -2.85e+85) {
tmp = t_1;
} else if (z <= -5.2e+21) {
tmp = x * (y / (t - z));
} else if ((z <= -4.1e-29) || !(z <= 6e+103)) {
tmp = t_1;
} else {
tmp = y * (x / (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) :: t_1
real(8) :: tmp
t_1 = x * (z / (z - t))
if (z <= (-2.85d+85)) then
tmp = t_1
else if (z <= (-5.2d+21)) then
tmp = x * (y / (t - z))
else if ((z <= (-4.1d-29)) .or. (.not. (z <= 6d+103))) then
tmp = t_1
else
tmp = y * (x / (t - z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * (z / (z - t));
double tmp;
if (z <= -2.85e+85) {
tmp = t_1;
} else if (z <= -5.2e+21) {
tmp = x * (y / (t - z));
} else if ((z <= -4.1e-29) || !(z <= 6e+103)) {
tmp = t_1;
} else {
tmp = y * (x / (t - z));
}
return tmp;
}
def code(x, y, z, t): t_1 = x * (z / (z - t)) tmp = 0 if z <= -2.85e+85: tmp = t_1 elif z <= -5.2e+21: tmp = x * (y / (t - z)) elif (z <= -4.1e-29) or not (z <= 6e+103): tmp = t_1 else: tmp = y * (x / (t - z)) return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(z / Float64(z - t))) tmp = 0.0 if (z <= -2.85e+85) tmp = t_1; elseif (z <= -5.2e+21) tmp = Float64(x * Float64(y / Float64(t - z))); elseif ((z <= -4.1e-29) || !(z <= 6e+103)) tmp = t_1; else tmp = Float64(y * Float64(x / Float64(t - z))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * (z / (z - t)); tmp = 0.0; if (z <= -2.85e+85) tmp = t_1; elseif (z <= -5.2e+21) tmp = x * (y / (t - z)); elseif ((z <= -4.1e-29) || ~((z <= 6e+103))) tmp = t_1; else tmp = y * (x / (t - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.85e+85], t$95$1, If[LessEqual[z, -5.2e+21], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -4.1e-29], N[Not[LessEqual[z, 6e+103]], $MachinePrecision]], t$95$1, N[(y * N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \frac{z}{z - t}\\
\mathbf{if}\;z \leq -2.85 \cdot 10^{+85}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -5.2 \cdot 10^{+21}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{elif}\;z \leq -4.1 \cdot 10^{-29} \lor \neg \left(z \leq 6 \cdot 10^{+103}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{t - z}\\
\end{array}
\end{array}
if z < -2.8500000000000001e85 or -5.2e21 < z < -4.0999999999999998e-29 or 6e103 < z Initial program 68.7%
associate-*r/99.9%
Simplified99.9%
*-commutative99.9%
associate-/r/75.3%
frac-2neg75.3%
neg-sub075.3%
sub-neg75.3%
+-commutative75.3%
associate--r+75.3%
neg-sub075.3%
remove-double-neg75.3%
distribute-neg-frac75.3%
neg-sub075.3%
sub-neg75.3%
+-commutative75.3%
associate--r+75.3%
neg-sub075.3%
remove-double-neg75.3%
Applied egg-rr75.3%
Taylor expanded in y around 0 59.7%
*-commutative59.7%
associate-*l/87.9%
*-commutative87.9%
Simplified87.9%
if -2.8500000000000001e85 < z < -5.2e21Initial program 93.1%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in y around inf 73.0%
if -4.0999999999999998e-29 < z < 6e103Initial program 93.1%
associate-*r/93.8%
Simplified93.8%
Taylor expanded in y around inf 77.8%
associate-/l*77.6%
associate-/r/80.1%
Simplified80.1%
Final simplification82.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -1.3e+89) (not (<= z 2e+106))) (* x (/ z (- z t))) (* x (/ y (- t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -1.3e+89) || !(z <= 2e+106)) {
tmp = x * (z / (z - t));
} 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.3d+89)) .or. (.not. (z <= 2d+106))) then
tmp = x * (z / (z - t))
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.3e+89) || !(z <= 2e+106)) {
tmp = x * (z / (z - t));
} else {
tmp = x * (y / (t - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -1.3e+89) or not (z <= 2e+106): tmp = x * (z / (z - t)) else: tmp = x * (y / (t - z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -1.3e+89) || !(z <= 2e+106)) tmp = Float64(x * Float64(z / Float64(z - t))); 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.3e+89) || ~((z <= 2e+106))) tmp = x * (z / (z - t)); else tmp = x * (y / (t - z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -1.3e+89], N[Not[LessEqual[z, 2e+106]], $MachinePrecision]], N[(x * N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+89} \lor \neg \left(z \leq 2 \cdot 10^{+106}\right):\\
\;\;\;\;x \cdot \frac{z}{z - t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\end{array}
\end{array}
if z < -1.3e89 or 2.00000000000000018e106 < z Initial program 65.3%
associate-*r/100.0%
Simplified100.0%
*-commutative100.0%
associate-/r/72.6%
frac-2neg72.6%
neg-sub072.6%
sub-neg72.6%
+-commutative72.6%
associate--r+72.6%
neg-sub072.6%
remove-double-neg72.6%
distribute-neg-frac72.6%
neg-sub072.6%
sub-neg72.6%
+-commutative72.6%
associate--r+72.6%
neg-sub072.6%
remove-double-neg72.6%
Applied egg-rr72.6%
Taylor expanded in y around 0 58.8%
*-commutative58.8%
associate-*l/90.0%
*-commutative90.0%
Simplified90.0%
if -1.3e89 < z < 2.00000000000000018e106Initial program 93.4%
associate-*r/94.6%
Simplified94.6%
Taylor expanded in y around inf 75.9%
Final simplification80.4%
(FPCore (x y z t) :precision binary64 (if (<= z -6.6e+82) x (if (<= z 4.8e+120) (* x (/ y (- t z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.6e+82) {
tmp = x;
} else if (z <= 4.8e+120) {
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 <= (-6.6d+82)) then
tmp = x
else if (z <= 4.8d+120) 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 <= -6.6e+82) {
tmp = x;
} else if (z <= 4.8e+120) {
tmp = x * (y / (t - z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6.6e+82: tmp = x elif z <= 4.8e+120: tmp = x * (y / (t - z)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6.6e+82) tmp = x; elseif (z <= 4.8e+120) 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 <= -6.6e+82) tmp = x; elseif (z <= 4.8e+120) tmp = x * (y / (t - z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.6e+82], x, If[LessEqual[z, 4.8e+120], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.6 \cdot 10^{+82}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+120}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.5999999999999997e82 or 4.80000000000000002e120 < z Initial program 63.1%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in z around inf 83.8%
if -6.5999999999999997e82 < z < 4.80000000000000002e120Initial program 93.6%
associate-*r/94.8%
Simplified94.8%
Taylor expanded in y around inf 75.0%
Final simplification77.6%
(FPCore (x y z t) :precision binary64 (if (<= z -6.8e+45) (- x (* x (/ y z))) (if (<= z 6e+103) (* y (/ x (- t z))) (* x (/ z (- z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -6.8e+45) {
tmp = x - (x * (y / z));
} else if (z <= 6e+103) {
tmp = y * (x / (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 (z <= (-6.8d+45)) then
tmp = x - (x * (y / z))
else if (z <= 6d+103) then
tmp = y * (x / (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 (z <= -6.8e+45) {
tmp = x - (x * (y / z));
} else if (z <= 6e+103) {
tmp = y * (x / (t - z));
} else {
tmp = x * (z / (z - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -6.8e+45: tmp = x - (x * (y / z)) elif z <= 6e+103: tmp = y * (x / (t - z)) else: tmp = x * (z / (z - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -6.8e+45) tmp = Float64(x - Float64(x * Float64(y / z))); elseif (z <= 6e+103) tmp = Float64(y * Float64(x / 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 (z <= -6.8e+45) tmp = x - (x * (y / z)); elseif (z <= 6e+103) tmp = y * (x / (t - z)); else tmp = x * (z / (z - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -6.8e+45], N[(x - N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6e+103], N[(y * N[(x / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(z / N[(z - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.8 \cdot 10^{+45}:\\
\;\;\;\;x - x \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+103}:\\
\;\;\;\;y \cdot \frac{x}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{z}{z - t}\\
\end{array}
\end{array}
if z < -6.8e45Initial program 69.0%
associate-*r/100.0%
Simplified100.0%
*-commutative100.0%
associate-/r/71.2%
frac-2neg71.2%
neg-sub071.2%
sub-neg71.2%
+-commutative71.2%
associate--r+71.2%
neg-sub071.2%
remove-double-neg71.2%
distribute-neg-frac71.2%
neg-sub071.2%
sub-neg71.2%
+-commutative71.2%
associate--r+71.2%
neg-sub071.2%
remove-double-neg71.2%
Applied egg-rr71.2%
Taylor expanded in t around 0 58.8%
Taylor expanded in z around 0 77.3%
mul-1-neg77.3%
sub-neg77.3%
*-commutative77.3%
associate-*l/85.7%
*-commutative85.7%
Simplified85.7%
if -6.8e45 < z < 6e103Initial program 93.7%
associate-*r/94.4%
Simplified94.4%
Taylor expanded in y around inf 76.1%
associate-/l*75.9%
associate-/r/77.0%
Simplified77.0%
if 6e103 < z Initial program 64.0%
associate-*r/99.9%
Simplified99.9%
*-commutative99.9%
associate-/r/75.7%
frac-2neg75.7%
neg-sub075.7%
sub-neg75.7%
+-commutative75.7%
associate--r+75.7%
neg-sub075.7%
remove-double-neg75.7%
distribute-neg-frac75.7%
neg-sub075.7%
sub-neg75.7%
+-commutative75.7%
associate--r+75.7%
neg-sub075.7%
remove-double-neg75.7%
Applied egg-rr75.7%
Taylor expanded in y around 0 57.3%
*-commutative57.3%
associate-*l/93.3%
*-commutative93.3%
Simplified93.3%
Final simplification81.2%
(FPCore (x y z t) :precision binary64 (if (<= z -1.06e+41) x (if (<= z 4.9e+45) (* x (/ y t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -1.06e+41) {
tmp = x;
} else if (z <= 4.9e+45) {
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.06d+41)) then
tmp = x
else if (z <= 4.9d+45) 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.06e+41) {
tmp = x;
} else if (z <= 4.9e+45) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -1.06e+41: tmp = x elif z <= 4.9e+45: tmp = x * (y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -1.06e+41) tmp = x; elseif (z <= 4.9e+45) 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.06e+41) tmp = x; elseif (z <= 4.9e+45) tmp = x * (y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -1.06e+41], x, If[LessEqual[z, 4.9e+45], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.06 \cdot 10^{+41}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 4.9 \cdot 10^{+45}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -1.06e41 or 4.9000000000000002e45 < z Initial program 69.0%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in z around inf 71.5%
if -1.06e41 < z < 4.9000000000000002e45Initial program 94.4%
associate-*r/94.0%
Simplified94.0%
Taylor expanded in z around 0 66.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-*r/96.3%
Simplified96.3%
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)))