
(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 86.2%
associate-*r/98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (x y z t)
:precision binary64
(if (<= z -4.6e+139)
(- x (/ x (/ z y)))
(if (<= z -4.8e+19)
(/ (* x (- z)) (- t z))
(if (<= z 3e+32) (* x (/ y (- t z))) (* x (/ (- z y) z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.6e+139) {
tmp = x - (x / (z / y));
} else if (z <= -4.8e+19) {
tmp = (x * -z) / (t - z);
} else if (z <= 3e+32) {
tmp = x * (y / (t - z));
} else {
tmp = x * ((z - y) / 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 <= (-4.6d+139)) then
tmp = x - (x / (z / y))
else if (z <= (-4.8d+19)) then
tmp = (x * -z) / (t - z)
else if (z <= 3d+32) then
tmp = x * (y / (t - z))
else
tmp = x * ((z - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.6e+139) {
tmp = x - (x / (z / y));
} else if (z <= -4.8e+19) {
tmp = (x * -z) / (t - z);
} else if (z <= 3e+32) {
tmp = x * (y / (t - z));
} else {
tmp = x * ((z - y) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.6e+139: tmp = x - (x / (z / y)) elif z <= -4.8e+19: tmp = (x * -z) / (t - z) elif z <= 3e+32: tmp = x * (y / (t - z)) else: tmp = x * ((z - y) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.6e+139) tmp = Float64(x - Float64(x / Float64(z / y))); elseif (z <= -4.8e+19) tmp = Float64(Float64(x * Float64(-z)) / Float64(t - z)); elseif (z <= 3e+32) tmp = Float64(x * Float64(y / Float64(t - z))); else tmp = Float64(x * Float64(Float64(z - y) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4.6e+139) tmp = x - (x / (z / y)); elseif (z <= -4.8e+19) tmp = (x * -z) / (t - z); elseif (z <= 3e+32) tmp = x * (y / (t - z)); else tmp = x * ((z - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.6e+139], N[(x - N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -4.8e+19], N[(N[(x * (-z)), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3e+32], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(z - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+139}:\\
\;\;\;\;x - \frac{x}{\frac{z}{y}}\\
\mathbf{elif}\;z \leq -4.8 \cdot 10^{+19}:\\
\;\;\;\;\frac{x \cdot \left(-z\right)}{t - z}\\
\mathbf{elif}\;z \leq 3 \cdot 10^{+32}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{z - y}{z}\\
\end{array}
\end{array}
if z < -4.6e139Initial program 70.6%
associate-*r/99.9%
Simplified99.9%
associate-*r/70.6%
clear-num67.5%
Applied egg-rr67.5%
Taylor expanded in t around 0 61.6%
mul-1-neg61.6%
neg-sub061.6%
associate-/l*49.8%
div-sub49.8%
associate-/l*46.6%
associate-*r/50.7%
*-commutative50.7%
associate-/r/82.0%
*-inverses82.0%
*-lft-identity82.0%
associate-+l-82.0%
neg-sub082.0%
associate-*l/79.8%
*-commutative79.8%
mul-1-neg79.8%
+-commutative79.8%
mul-1-neg79.8%
associate-*r/82.0%
*-commutative82.0%
unsub-neg82.0%
*-commutative82.0%
Simplified82.0%
associate-*r/79.8%
*-commutative79.8%
associate-/l*88.7%
Applied egg-rr88.7%
if -4.6e139 < z < -4.8e19Initial program 99.8%
Taylor expanded in y around 0 87.3%
mul-1-neg87.3%
distribute-rgt-neg-in87.3%
Simplified87.3%
if -4.8e19 < z < 3e32Initial program 92.9%
associate-*r/97.0%
Simplified97.0%
Taylor expanded in y around inf 78.3%
if 3e32 < z Initial program 77.5%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in t around 0 76.9%
associate-*r/76.9%
neg-mul-176.9%
neg-sub076.9%
associate--r-76.9%
neg-sub076.9%
Simplified76.9%
Final simplification80.3%
(FPCore (x y z t) :precision binary64 (if (or (<= t -3.1e+22) (not (<= t 1.75e-25))) (* x (/ (- y z) t)) (- x (* y (/ x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.1e+22) || !(t <= 1.75e-25)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (y * (x / 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 ((t <= (-3.1d+22)) .or. (.not. (t <= 1.75d-25))) then
tmp = x * ((y - z) / t)
else
tmp = x - (y * (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -3.1e+22) || !(t <= 1.75e-25)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (y * (x / z));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -3.1e+22) or not (t <= 1.75e-25): tmp = x * ((y - z) / t) else: tmp = x - (y * (x / z)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -3.1e+22) || !(t <= 1.75e-25)) tmp = Float64(x * Float64(Float64(y - z) / t)); else tmp = Float64(x - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -3.1e+22) || ~((t <= 1.75e-25))) tmp = x * ((y - z) / t); else tmp = x - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -3.1e+22], N[Not[LessEqual[t, 1.75e-25]], $MachinePrecision]], N[(x * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -3.1 \cdot 10^{+22} \lor \neg \left(t \leq 1.75 \cdot 10^{-25}\right):\\
\;\;\;\;x \cdot \frac{y - z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if t < -3.1000000000000002e22 or 1.7500000000000001e-25 < t Initial program 86.1%
associate-*r/96.9%
Simplified96.9%
Taylor expanded in t around inf 77.3%
if -3.1000000000000002e22 < t < 1.7500000000000001e-25Initial program 86.4%
associate-*r/99.8%
Simplified99.8%
associate-*r/86.4%
clear-num86.3%
Applied egg-rr86.3%
Taylor expanded in t around 0 68.3%
mul-1-neg68.3%
neg-sub068.3%
associate-/l*62.2%
div-sub61.3%
associate-/l*61.6%
associate-*r/62.7%
*-commutative62.7%
associate-/r/76.8%
*-inverses76.8%
*-lft-identity76.8%
associate-+l-76.8%
neg-sub076.8%
associate-*l/76.6%
*-commutative76.6%
mul-1-neg76.6%
+-commutative76.6%
mul-1-neg76.6%
associate-*r/76.8%
*-commutative76.8%
unsub-neg76.8%
*-commutative76.8%
Simplified76.8%
Final simplification77.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.3e+22) (not (<= t 1.25e-25))) (* x (/ (- y z) t)) (- x (/ x (/ z y)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.3e+22) || !(t <= 1.25e-25)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (x / (z / y));
}
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 ((t <= (-2.3d+22)) .or. (.not. (t <= 1.25d-25))) then
tmp = x * ((y - z) / t)
else
tmp = x - (x / (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.3e+22) || !(t <= 1.25e-25)) {
tmp = x * ((y - z) / t);
} else {
tmp = x - (x / (z / y));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -2.3e+22) or not (t <= 1.25e-25): tmp = x * ((y - z) / t) else: tmp = x - (x / (z / y)) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -2.3e+22) || !(t <= 1.25e-25)) tmp = Float64(x * Float64(Float64(y - z) / t)); else tmp = Float64(x - Float64(x / Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -2.3e+22) || ~((t <= 1.25e-25))) tmp = x * ((y - z) / t); else tmp = x - (x / (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.3e+22], N[Not[LessEqual[t, 1.25e-25]], $MachinePrecision]], N[(x * N[(N[(y - z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(x - N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.3 \cdot 10^{+22} \lor \neg \left(t \leq 1.25 \cdot 10^{-25}\right):\\
\;\;\;\;x \cdot \frac{y - z}{t}\\
\mathbf{else}:\\
\;\;\;\;x - \frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if t < -2.3000000000000002e22 or 1.2499999999999999e-25 < t Initial program 86.1%
associate-*r/96.9%
Simplified96.9%
Taylor expanded in t around inf 77.3%
if -2.3000000000000002e22 < t < 1.2499999999999999e-25Initial program 86.4%
associate-*r/99.8%
Simplified99.8%
associate-*r/86.4%
clear-num86.3%
Applied egg-rr86.3%
Taylor expanded in t around 0 68.3%
mul-1-neg68.3%
neg-sub068.3%
associate-/l*62.2%
div-sub61.3%
associate-/l*61.6%
associate-*r/62.7%
*-commutative62.7%
associate-/r/76.8%
*-inverses76.8%
*-lft-identity76.8%
associate-+l-76.8%
neg-sub076.8%
associate-*l/76.6%
*-commutative76.6%
mul-1-neg76.6%
+-commutative76.6%
mul-1-neg76.6%
associate-*r/76.8%
*-commutative76.8%
unsub-neg76.8%
*-commutative76.8%
Simplified76.8%
associate-*r/76.6%
*-commutative76.6%
associate-/l*80.2%
Applied egg-rr80.2%
Final simplification78.7%
(FPCore (x y z t) :precision binary64 (if (<= z -4.2e+31) x (if (<= z 1.1e+103) (* x (/ y (- t z))) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.2e+31) {
tmp = x;
} else if (z <= 1.1e+103) {
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 <= (-4.2d+31)) then
tmp = x
else if (z <= 1.1d+103) 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 <= -4.2e+31) {
tmp = x;
} else if (z <= 1.1e+103) {
tmp = x * (y / (t - z));
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.2e+31: tmp = x elif z <= 1.1e+103: tmp = x * (y / (t - z)) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.2e+31) tmp = x; elseif (z <= 1.1e+103) 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 <= -4.2e+31) tmp = x; elseif (z <= 1.1e+103) tmp = x * (y / (t - z)); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.2e+31], x, If[LessEqual[z, 1.1e+103], N[(x * N[(y / N[(t - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+31}:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 1.1 \cdot 10^{+103}:\\
\;\;\;\;x \cdot \frac{y}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.19999999999999958e31 or 1.09999999999999996e103 < z Initial program 76.4%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in z around inf 69.8%
if -4.19999999999999958e31 < z < 1.09999999999999996e103Initial program 92.5%
associate-*r/97.4%
Simplified97.4%
Taylor expanded in y around inf 75.1%
Final simplification73.0%
(FPCore (x y z t) :precision binary64 (if (<= z -50.0) x (if (<= z 2.8e+31) (* x (/ y t)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -50.0) {
tmp = x;
} else if (z <= 2.8e+31) {
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 <= (-50.0d0)) then
tmp = x
else if (z <= 2.8d+31) 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 <= -50.0) {
tmp = x;
} else if (z <= 2.8e+31) {
tmp = x * (y / t);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -50.0: tmp = x elif z <= 2.8e+31: tmp = x * (y / t) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -50.0) tmp = x; elseif (z <= 2.8e+31) 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 <= -50.0) tmp = x; elseif (z <= 2.8e+31) tmp = x * (y / t); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -50.0], x, If[LessEqual[z, 2.8e+31], N[(x * N[(y / t), $MachinePrecision]), $MachinePrecision], x]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -50:\\
\;\;\;\;x\\
\mathbf{elif}\;z \leq 2.8 \cdot 10^{+31}:\\
\;\;\;\;x \cdot \frac{y}{t}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -50 or 2.80000000000000017e31 < z Initial program 78.9%
associate-*r/99.9%
Simplified99.9%
Taylor expanded in z around inf 63.5%
if -50 < z < 2.80000000000000017e31Initial program 93.3%
associate-*r/96.9%
Simplified96.9%
Taylor expanded in z around 0 65.6%
Final simplification64.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 86.2%
associate-*r/98.3%
Simplified98.3%
Taylor expanded in z around inf 36.0%
Final simplification36.0%
(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 2023230
(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)))