
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x (* y (- z x))) z)))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e+275)))
(+ y (* x (/ (- 1.0 y) z)))
(+ (- y (* y (/ x z))) (/ x z)))))
double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 4e+275)) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = (y - (y * (x / z))) + (x / z);
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 4e+275)) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = (y - (y * (x / z))) + (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = (x + (y * (z - x))) / z tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 4e+275): tmp = y + (x * ((1.0 - y) / z)) else: tmp = (y - (y * (x / z))) + (x / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + Float64(y * Float64(z - x))) / z) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 4e+275)) tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z))); else tmp = Float64(Float64(y - Float64(y * Float64(x / z))) + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + (y * (z - x))) / z; tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 4e+275))) tmp = y + (x * ((1.0 - y) / z)); else tmp = (y - (y * (x / z))) + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 4e+275]], $MachinePrecision]], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 4 \cdot 10^{+275}\right):\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(y - y \cdot \frac{x}{z}\right) + \frac{x}{z}\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -inf.0 or 3.99999999999999984e275 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) Initial program 63.0%
Taylor expanded in y around 0 83.9%
Taylor expanded in x around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 3.99999999999999984e275Initial program 99.8%
Taylor expanded in y around 0 99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (+ x (* y (- z x))) z)))
(if (or (<= t_0 (- INFINITY)) (not (<= t_0 4e+275)))
(+ y (* x (/ (- 1.0 y) z)))
(+ (/ x z) (* y (- 1.0 (/ x z)))))))
double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 4e+275)) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = (x / z) + (y * (1.0 - (x / z)));
}
return tmp;
}
public static double code(double x, double y, double z) {
double t_0 = (x + (y * (z - x))) / z;
double tmp;
if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 4e+275)) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = (x / z) + (y * (1.0 - (x / z)));
}
return tmp;
}
def code(x, y, z): t_0 = (x + (y * (z - x))) / z tmp = 0 if (t_0 <= -math.inf) or not (t_0 <= 4e+275): tmp = y + (x * ((1.0 - y) / z)) else: tmp = (x / z) + (y * (1.0 - (x / z))) return tmp
function code(x, y, z) t_0 = Float64(Float64(x + Float64(y * Float64(z - x))) / z) tmp = 0.0 if ((t_0 <= Float64(-Inf)) || !(t_0 <= 4e+275)) tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z))); else tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x + (y * (z - x))) / z; tmp = 0.0; if ((t_0 <= -Inf) || ~((t_0 <= 4e+275))) tmp = y + (x * ((1.0 - y) / z)); else tmp = (x / z) + (y * (1.0 - (x / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 4e+275]], $MachinePrecision]], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{if}\;t\_0 \leq -\infty \lor \neg \left(t\_0 \leq 4 \cdot 10^{+275}\right):\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < -inf.0 or 3.99999999999999984e275 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) Initial program 63.0%
Taylor expanded in y around 0 83.9%
Taylor expanded in x around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
sub-neg100.0%
div-sub100.0%
Simplified100.0%
if -inf.0 < (/.f64 (+.f64 x (*.f64 y (-.f64 z x))) z) < 3.99999999999999984e275Initial program 99.8%
Taylor expanded in y around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1e+16) (not (<= y 2800000000000.0))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+16) || !(y <= 2800000000000.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-1d+16)) .or. (.not. (y <= 2800000000000.0d0))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = (x + (y * (z - x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+16) || !(y <= 2800000000000.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e+16) or not (y <= 2800000000000.0): tmp = y * (1.0 - (x / z)) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e+16) || !(y <= 2800000000000.0)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1e+16) || ~((y <= 2800000000000.0))) tmp = y * (1.0 - (x / z)); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+16], N[Not[LessEqual[y, 2800000000000.0]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+16} \lor \neg \left(y \leq 2800000000000\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if y < -1e16 or 2.8e12 < y Initial program 73.3%
Taylor expanded in y around inf 73.3%
associate-/l*99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
if -1e16 < y < 2.8e12Initial program 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.32e-39) (not (<= z 1.3e-176))) (+ y (/ x z)) (* x (/ (- 1.0 y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.32e-39) || !(z <= 1.3e-176)) {
tmp = y + (x / z);
} else {
tmp = x * ((1.0 - y) / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.32d-39)) .or. (.not. (z <= 1.3d-176))) then
tmp = y + (x / z)
else
tmp = x * ((1.0d0 - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.32e-39) || !(z <= 1.3e-176)) {
tmp = y + (x / z);
} else {
tmp = x * ((1.0 - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.32e-39) or not (z <= 1.3e-176): tmp = y + (x / z) else: tmp = x * ((1.0 - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.32e-39) || !(z <= 1.3e-176)) tmp = Float64(y + Float64(x / z)); else tmp = Float64(x * Float64(Float64(1.0 - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.32e-39) || ~((z <= 1.3e-176))) tmp = y + (x / z); else tmp = x * ((1.0 - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.32e-39], N[Not[LessEqual[z, 1.3e-176]], $MachinePrecision]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.32 \cdot 10^{-39} \lor \neg \left(z \leq 1.3 \cdot 10^{-176}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\end{array}
\end{array}
if z < -1.31999999999999997e-39 or 1.29999999999999996e-176 < z Initial program 83.3%
Taylor expanded in y around 0 98.8%
Taylor expanded in x around 0 87.3%
if -1.31999999999999997e-39 < z < 1.29999999999999996e-176Initial program 99.8%
Taylor expanded in x around inf 90.1%
associate-/l*85.9%
mul-1-neg85.9%
unsub-neg85.9%
Simplified85.9%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -9500000000.0) (not (<= y 0.35))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -9500000000.0) || !(y <= 0.35)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-9500000000.0d0)) .or. (.not. (y <= 0.35d0))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -9500000000.0) || !(y <= 0.35)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -9500000000.0) or not (y <= 0.35): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -9500000000.0) || !(y <= 0.35)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -9500000000.0) || ~((y <= 0.35))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -9500000000.0], N[Not[LessEqual[y, 0.35]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9500000000 \lor \neg \left(y \leq 0.35\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -9.5e9 or 0.34999999999999998 < y Initial program 74.8%
Taylor expanded in y around inf 74.1%
associate-/l*99.1%
div-sub99.1%
*-inverses99.1%
Simplified99.1%
if -9.5e9 < y < 0.34999999999999998Initial program 99.9%
Taylor expanded in y around 0 94.1%
Taylor expanded in x around 0 99.9%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.75e-83) (not (<= y 2.6e-28))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.75e-83) || !(y <= 2.6e-28)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-2.75d-83)) .or. (.not. (y <= 2.6d-28))) then
tmp = z * (y / z)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.75e-83) || !(y <= 2.6e-28)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.75e-83) or not (y <= 2.6e-28): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.75e-83) || !(y <= 2.6e-28)) tmp = Float64(z * Float64(y / z)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.75e-83) || ~((y <= 2.6e-28))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.75e-83], N[Not[LessEqual[y, 2.6e-28]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.75 \cdot 10^{-83} \lor \neg \left(y \leq 2.6 \cdot 10^{-28}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.74999999999999982e-83 or 2.6e-28 < y Initial program 79.3%
Taylor expanded in x around 0 38.8%
*-commutative38.8%
associate-/l*57.8%
Applied egg-rr57.8%
if -2.74999999999999982e-83 < y < 2.6e-28Initial program 100.0%
Taylor expanded in y around 0 78.7%
Final simplification66.8%
(FPCore (x y z) :precision binary64 (if (<= y 65000000000000.0) (+ y (* x (/ (- 1.0 y) z))) (* y (- 1.0 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 65000000000000.0) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 65000000000000.0d0) then
tmp = y + (x * ((1.0d0 - y) / z))
else
tmp = y * (1.0d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 65000000000000.0) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 65000000000000.0: tmp = y + (x * ((1.0 - y) / z)) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 65000000000000.0) tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z))); else tmp = Float64(y * Float64(1.0 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 65000000000000.0) tmp = y + (x * ((1.0 - y) / z)); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 65000000000000.0], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 65000000000000:\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < 6.5e13Initial program 93.2%
Taylor expanded in y around 0 95.9%
Taylor expanded in x around 0 97.8%
neg-mul-197.8%
+-commutative97.8%
sub-neg97.8%
div-sub97.9%
Simplified97.9%
if 6.5e13 < y Initial program 72.1%
Taylor expanded in y around inf 72.1%
associate-/l*99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
Final simplification98.3%
(FPCore (x y z) :precision binary64 (if (<= y -4.5e-81) y (if (<= y 3e-27) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e-81) {
tmp = y;
} else if (y <= 3e-27) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-4.5d-81)) then
tmp = y
else if (y <= 3d-27) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e-81) {
tmp = y;
} else if (y <= 3e-27) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.5e-81: tmp = y elif y <= 3e-27: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.5e-81) tmp = y; elseif (y <= 3e-27) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.5e-81) tmp = y; elseif (y <= 3e-27) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.5e-81], y, If[LessEqual[y, 3e-27], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-81}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -4.5e-81 or 3.0000000000000001e-27 < y Initial program 79.3%
Taylor expanded in x around 0 55.5%
if -4.5e-81 < y < 3.0000000000000001e-27Initial program 100.0%
Taylor expanded in y around 0 78.7%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (+ y (/ x z)))
double code(double x, double y, double z) {
return y + (x / z);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y + (x / z)
end function
public static double code(double x, double y, double z) {
return y + (x / z);
}
def code(x, y, z): return y + (x / z)
function code(x, y, z) return Float64(y + Float64(x / z)) end
function tmp = code(x, y, z) tmp = y + (x / z); end
code[x_, y_, z_] := N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{z}
\end{array}
Initial program 88.2%
Taylor expanded in y around 0 94.9%
Taylor expanded in x around 0 80.2%
Final simplification80.2%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 88.2%
Taylor expanded in x around 0 41.1%
Final simplification41.1%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2024075
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))