
(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 6 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.5%
associate-/l*97.5%
Simplified97.5%
(FPCore (x y z t) :precision binary64 (if (or (<= z -8e-45) (not (<= z 1.14e+55))) (* x (- 1.0 (/ y z))) (* x (/ y (- t z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -8e-45) || !(z <= 1.14e+55)) {
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 <= (-8d-45)) .or. (.not. (z <= 1.14d+55))) 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 <= -8e-45) || !(z <= 1.14e+55)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = x * (y / (t - z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -8e-45) or not (z <= 1.14e+55): 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 <= -8e-45) || !(z <= 1.14e+55)) 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 <= -8e-45) || ~((z <= 1.14e+55))) 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, -8e-45], N[Not[LessEqual[z, 1.14e+55]], $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 -8 \cdot 10^{-45} \lor \neg \left(z \leq 1.14 \cdot 10^{+55}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\end{array}
\end{array}
if z < -7.99999999999999987e-45 or 1.1399999999999999e55 < z Initial program 75.4%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 61.2%
mul-1-neg61.2%
associate-/l*82.0%
distribute-rgt-neg-in82.0%
distribute-frac-neg82.0%
sub-neg82.0%
distribute-neg-in82.0%
remove-double-neg82.0%
+-commutative82.0%
sub-neg82.0%
div-sub82.0%
*-inverses82.0%
Simplified82.0%
if -7.99999999999999987e-45 < z < 1.1399999999999999e55Initial program 90.6%
associate-/l*96.0%
Simplified96.0%
Taylor expanded in y around inf 76.9%
associate-/l*81.0%
Simplified81.0%
Final simplification81.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -4.2e-47) (not (<= z 8e-137))) (* x (- 1.0 (/ y z))) (* x (/ y t))))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -4.2e-47) || !(z <= 8e-137)) {
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 <= (-4.2d-47)) .or. (.not. (z <= 8d-137))) 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 <= -4.2e-47) || !(z <= 8e-137)) {
tmp = x * (1.0 - (y / z));
} else {
tmp = x * (y / t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -4.2e-47) or not (z <= 8e-137): tmp = x * (1.0 - (y / z)) else: tmp = x * (y / t) return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -4.2e-47) || !(z <= 8e-137)) tmp = Float64(x * Float64(1.0 - Float64(y / z))); else tmp = Float64(x * Float64(y / t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -4.2e-47) || ~((z <= 8e-137))) 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, -4.2e-47], N[Not[LessEqual[z, 8e-137]], $MachinePrecision]], N[(x * N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{-47} \lor \neg \left(z \leq 8 \cdot 10^{-137}\right):\\
\;\;\;\;x \cdot \left(1 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\end{array}
\end{array}
if z < -4.2000000000000001e-47 or 7.99999999999999982e-137 < z Initial program 82.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in t around 0 57.1%
mul-1-neg57.1%
associate-/l*70.3%
distribute-rgt-neg-in70.3%
distribute-frac-neg70.3%
sub-neg70.3%
distribute-neg-in70.3%
remove-double-neg70.3%
+-commutative70.3%
sub-neg70.3%
div-sub70.3%
*-inverses70.3%
Simplified70.3%
if -4.2000000000000001e-47 < z < 7.99999999999999982e-137Initial program 87.7%
associate-/l*93.7%
Simplified93.7%
Taylor expanded in z around 0 66.6%
associate-/l*73.2%
Simplified73.2%
Final simplification71.4%
(FPCore (x y z t) :precision binary64 (if (<= z -8.2e-45) (* x (- 1.0 (/ y z))) (if (<= z 2.35e+55) (* x (/ y (- t z))) (* x (/ z (- z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.2e-45) {
tmp = x * (1.0 - (y / z));
} else if (z <= 2.35e+55) {
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 (z <= (-8.2d-45)) then
tmp = x * (1.0d0 - (y / z))
else if (z <= 2.35d+55) 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 (z <= -8.2e-45) {
tmp = x * (1.0 - (y / z));
} else if (z <= 2.35e+55) {
tmp = x * (y / (t - z));
} else {
tmp = x * (z / (z - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.2e-45: tmp = x * (1.0 - (y / z)) elif z <= 2.35e+55: tmp = x * (y / (t - z)) else: tmp = x * (z / (z - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.2e-45) tmp = Float64(x * Float64(1.0 - Float64(y / z))); elseif (z <= 2.35e+55) 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 (z <= -8.2e-45) tmp = x * (1.0 - (y / z)); elseif (z <= 2.35e+55) tmp = x * (y / (t - z)); else tmp = x * (z / (z - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.2e-45], N[(x * N[(1.0 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.35e+55], 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}\;z \leq -8.2 \cdot 10^{-45}:\\
\;\;\;\;x \cdot \left(1 - \frac{y}{z}\right)\\
\mathbf{elif}\;z \leq 2.35 \cdot 10^{+55}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{z}{z - t}\\
\end{array}
\end{array}
if z < -8.1999999999999998e-45Initial program 73.1%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in t around 0 61.9%
mul-1-neg61.9%
associate-/l*85.6%
distribute-rgt-neg-in85.6%
distribute-frac-neg85.6%
sub-neg85.6%
distribute-neg-in85.6%
remove-double-neg85.6%
+-commutative85.6%
sub-neg85.6%
div-sub85.6%
*-inverses85.6%
Simplified85.6%
if -8.1999999999999998e-45 < z < 2.35e55Initial program 90.6%
associate-/l*96.0%
Simplified96.0%
Taylor expanded in y around inf 76.9%
associate-/l*81.0%
Simplified81.0%
if 2.35e55 < z Initial program 79.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 69.5%
mul-1-neg69.5%
distribute-neg-frac269.5%
sub-neg69.5%
distribute-neg-in69.5%
remove-double-neg69.5%
+-commutative69.5%
sub-neg69.5%
associate-/l*83.4%
Simplified83.4%
(FPCore (x y z t) :precision binary64 (if (<= z -8.4e-45) x (if (<= z 6.5e+107) (* x (/ y t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -8.4e-45) {
tmp = x;
} else if (z <= 6.5e+107) {
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 <= (-8.4d-45)) then
tmp = x
else if (z <= 6.5d+107) 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 <= -8.4e-45) {
tmp = x;
} else if (z <= 6.5e+107) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -8.4e-45: tmp = x elif z <= 6.5e+107: tmp = x * (y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -8.4e-45) tmp = x; elseif (z <= 6.5e+107) 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 <= -8.4e-45) tmp = x; elseif (z <= 6.5e+107) tmp = x * (y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -8.4e-45], x, If[LessEqual[z, 6.5e+107], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{-45}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+107}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -8.3999999999999998e-45 or 6.5000000000000006e107 < z Initial program 72.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 72.7%
if -8.3999999999999998e-45 < z < 6.5000000000000006e107Initial program 91.2%
associate-/l*96.2%
Simplified96.2%
Taylor expanded in z around 0 54.5%
associate-/l*59.6%
Simplified59.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.5%
associate-/l*97.5%
Simplified97.5%
Taylor expanded in z around inf 34.8%
(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 2024132
(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)))