
(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 11 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 (- y (* (/ x z) (+ y -1.0))))
double code(double x, double y, double z) {
return y - ((x / z) * (y + -1.0));
}
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 + (-1.0d0)))
end function
public static double code(double x, double y, double z) {
return y - ((x / z) * (y + -1.0));
}
def code(x, y, z): return y - ((x / z) * (y + -1.0))
function code(x, y, z) return Float64(y - Float64(Float64(x / z) * Float64(y + -1.0))) end
function tmp = code(x, y, z) tmp = y - ((x / z) * (y + -1.0)); end
code[x_, y_, z_] := N[(y - N[(N[(x / z), $MachinePrecision] * N[(y + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y - \frac{x}{z} \cdot \left(y + -1\right)
\end{array}
Initial program 89.3%
Taylor expanded in x around -inf 96.9%
mul-1-neg96.9%
unsub-neg96.9%
associate-/l*97.5%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))) (t_1 (/ (- x) (/ z y))))
(if (<= y -2.6e+42)
t_0
(if (<= y -2300000000.0)
t_1
(if (<= y 12500000000.0) t_0 (if (<= y 2.9e+88) t_1 (* z (/ y z))))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double t_1 = -x / (z / y);
double tmp;
if (y <= -2.6e+42) {
tmp = t_0;
} else if (y <= -2300000000.0) {
tmp = t_1;
} else if (y <= 12500000000.0) {
tmp = t_0;
} else if (y <= 2.9e+88) {
tmp = t_1;
} else {
tmp = z * (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y + (x / z)
t_1 = -x / (z / y)
if (y <= (-2.6d+42)) then
tmp = t_0
else if (y <= (-2300000000.0d0)) then
tmp = t_1
else if (y <= 12500000000.0d0) then
tmp = t_0
else if (y <= 2.9d+88) then
tmp = t_1
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double t_1 = -x / (z / y);
double tmp;
if (y <= -2.6e+42) {
tmp = t_0;
} else if (y <= -2300000000.0) {
tmp = t_1;
} else if (y <= 12500000000.0) {
tmp = t_0;
} else if (y <= 2.9e+88) {
tmp = t_1;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) t_1 = -x / (z / y) tmp = 0 if y <= -2.6e+42: tmp = t_0 elif y <= -2300000000.0: tmp = t_1 elif y <= 12500000000.0: tmp = t_0 elif y <= 2.9e+88: tmp = t_1 else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) t_1 = Float64(Float64(-x) / Float64(z / y)) tmp = 0.0 if (y <= -2.6e+42) tmp = t_0; elseif (y <= -2300000000.0) tmp = t_1; elseif (y <= 12500000000.0) tmp = t_0; elseif (y <= 2.9e+88) tmp = t_1; else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); t_1 = -x / (z / y); tmp = 0.0; if (y <= -2.6e+42) tmp = t_0; elseif (y <= -2300000000.0) tmp = t_1; elseif (y <= 12500000000.0) tmp = t_0; elseif (y <= 2.9e+88) tmp = t_1; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-x) / N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.6e+42], t$95$0, If[LessEqual[y, -2300000000.0], t$95$1, If[LessEqual[y, 12500000000.0], t$95$0, If[LessEqual[y, 2.9e+88], t$95$1, N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
t_1 := \frac{-x}{\frac{z}{y}}\\
\mathbf{if}\;y \leq -2.6 \cdot 10^{+42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2300000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 12500000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+88}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.5999999999999999e42 or -2.3e9 < y < 1.25e10Initial program 92.4%
Taylor expanded in x around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
associate-/l*99.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 92.2%
mul-1-neg92.2%
distribute-frac-neg92.2%
Simplified92.2%
Taylor expanded in y around 0 92.2%
+-commutative92.2%
Simplified92.2%
if -2.5999999999999999e42 < y < -2.3e9 or 1.25e10 < y < 2.9e88Initial program 99.7%
Taylor expanded in x around inf 74.2%
associate-/l*65.7%
associate-/r/74.2%
mul-1-neg74.2%
unsub-neg74.2%
Simplified74.2%
Taylor expanded in y around inf 73.1%
mul-1-neg73.1%
associate-/l*64.6%
Simplified64.6%
if 2.9e88 < y Initial program 66.5%
Taylor expanded in y around inf 66.5%
Taylor expanded in z around inf 28.4%
associate-/l*57.0%
associate-/r/68.8%
Applied egg-rr68.8%
Final simplification85.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))) (t_1 (* (/ x z) (- y))))
(if (<= y -5e+44)
t_0
(if (<= y -2300000000.0)
t_1
(if (<= y 125000000000.0)
t_0
(if (<= y 1.4e+179) t_1 (* z (/ y z))))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double t_1 = (x / z) * -y;
double tmp;
if (y <= -5e+44) {
tmp = t_0;
} else if (y <= -2300000000.0) {
tmp = t_1;
} else if (y <= 125000000000.0) {
tmp = t_0;
} else if (y <= 1.4e+179) {
tmp = t_1;
} else {
tmp = z * (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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y + (x / z)
t_1 = (x / z) * -y
if (y <= (-5d+44)) then
tmp = t_0
else if (y <= (-2300000000.0d0)) then
tmp = t_1
else if (y <= 125000000000.0d0) then
tmp = t_0
else if (y <= 1.4d+179) then
tmp = t_1
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double t_1 = (x / z) * -y;
double tmp;
if (y <= -5e+44) {
tmp = t_0;
} else if (y <= -2300000000.0) {
tmp = t_1;
} else if (y <= 125000000000.0) {
tmp = t_0;
} else if (y <= 1.4e+179) {
tmp = t_1;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) t_1 = (x / z) * -y tmp = 0 if y <= -5e+44: tmp = t_0 elif y <= -2300000000.0: tmp = t_1 elif y <= 125000000000.0: tmp = t_0 elif y <= 1.4e+179: tmp = t_1 else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) t_1 = Float64(Float64(x / z) * Float64(-y)) tmp = 0.0 if (y <= -5e+44) tmp = t_0; elseif (y <= -2300000000.0) tmp = t_1; elseif (y <= 125000000000.0) tmp = t_0; elseif (y <= 1.4e+179) tmp = t_1; else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); t_1 = (x / z) * -y; tmp = 0.0; if (y <= -5e+44) tmp = t_0; elseif (y <= -2300000000.0) tmp = t_1; elseif (y <= 125000000000.0) tmp = t_0; elseif (y <= 1.4e+179) tmp = t_1; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]}, If[LessEqual[y, -5e+44], t$95$0, If[LessEqual[y, -2300000000.0], t$95$1, If[LessEqual[y, 125000000000.0], t$95$0, If[LessEqual[y, 1.4e+179], t$95$1, N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
t_1 := \frac{x}{z} \cdot \left(-y\right)\\
\mathbf{if}\;y \leq -5 \cdot 10^{+44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2300000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 125000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+179}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -4.9999999999999996e44 or -2.3e9 < y < 1.25e11Initial program 92.4%
Taylor expanded in x around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
associate-/l*99.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 92.2%
mul-1-neg92.2%
distribute-frac-neg92.2%
Simplified92.2%
Taylor expanded in y around 0 92.2%
+-commutative92.2%
Simplified92.2%
if -4.9999999999999996e44 < y < -2.3e9 or 1.25e11 < y < 1.4e179Initial program 95.5%
Taylor expanded in x around inf 67.8%
associate-/l*58.2%
associate-/r/67.8%
mul-1-neg67.8%
unsub-neg67.8%
Simplified67.8%
Taylor expanded in y around inf 67.1%
associate-*l/67.1%
neg-mul-167.1%
distribute-rgt-neg-out67.1%
Simplified67.1%
if 1.4e179 < y Initial program 53.7%
Taylor expanded in y around inf 53.7%
Taylor expanded in z around inf 25.5%
associate-/l*64.1%
associate-/r/79.3%
Applied egg-rr79.3%
Final simplification86.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))))
(if (<= y -2.2e+42)
t_0
(if (<= y -2300000000.0)
(* (/ x z) (- y))
(if (<= y 160000.0)
t_0
(if (<= y 4.1e+176) (/ (* x (- y)) z) (* z (/ y z))))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -2.2e+42) {
tmp = t_0;
} else if (y <= -2300000000.0) {
tmp = (x / z) * -y;
} else if (y <= 160000.0) {
tmp = t_0;
} else if (y <= 4.1e+176) {
tmp = (x * -y) / z;
} else {
tmp = z * (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) :: t_0
real(8) :: tmp
t_0 = y + (x / z)
if (y <= (-2.2d+42)) then
tmp = t_0
else if (y <= (-2300000000.0d0)) then
tmp = (x / z) * -y
else if (y <= 160000.0d0) then
tmp = t_0
else if (y <= 4.1d+176) then
tmp = (x * -y) / z
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -2.2e+42) {
tmp = t_0;
} else if (y <= -2300000000.0) {
tmp = (x / z) * -y;
} else if (y <= 160000.0) {
tmp = t_0;
} else if (y <= 4.1e+176) {
tmp = (x * -y) / z;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) tmp = 0 if y <= -2.2e+42: tmp = t_0 elif y <= -2300000000.0: tmp = (x / z) * -y elif y <= 160000.0: tmp = t_0 elif y <= 4.1e+176: tmp = (x * -y) / z else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) tmp = 0.0 if (y <= -2.2e+42) tmp = t_0; elseif (y <= -2300000000.0) tmp = Float64(Float64(x / z) * Float64(-y)); elseif (y <= 160000.0) tmp = t_0; elseif (y <= 4.1e+176) tmp = Float64(Float64(x * Float64(-y)) / z); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); tmp = 0.0; if (y <= -2.2e+42) tmp = t_0; elseif (y <= -2300000000.0) tmp = (x / z) * -y; elseif (y <= 160000.0) tmp = t_0; elseif (y <= 4.1e+176) tmp = (x * -y) / z; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e+42], t$95$0, If[LessEqual[y, -2300000000.0], N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision], If[LessEqual[y, 160000.0], t$95$0, If[LessEqual[y, 4.1e+176], N[(N[(x * (-y)), $MachinePrecision] / z), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{+42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2300000000:\\
\;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\
\mathbf{elif}\;y \leq 160000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+176}:\\
\;\;\;\;\frac{x \cdot \left(-y\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.2000000000000001e42 or -2.3e9 < y < 1.6e5Initial program 92.4%
Taylor expanded in x around -inf 97.9%
mul-1-neg97.9%
unsub-neg97.9%
associate-/l*99.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 92.2%
mul-1-neg92.2%
distribute-frac-neg92.2%
Simplified92.2%
Taylor expanded in y around 0 92.2%
+-commutative92.2%
Simplified92.2%
if -2.2000000000000001e42 < y < -2.3e9Initial program 99.6%
Taylor expanded in x around inf 81.9%
associate-/l*81.7%
associate-/r/82.0%
mul-1-neg82.0%
unsub-neg82.0%
Simplified82.0%
Taylor expanded in y around inf 79.0%
associate-*l/79.1%
neg-mul-179.1%
distribute-rgt-neg-out79.1%
Simplified79.1%
if 1.6e5 < y < 4.0999999999999999e176Initial program 94.2%
Taylor expanded in y around inf 94.2%
Taylor expanded in z around 0 63.3%
mul-1-neg63.3%
distribute-lft-neg-out63.3%
*-commutative63.3%
Simplified63.3%
if 4.0999999999999999e176 < y Initial program 53.7%
Taylor expanded in y around inf 53.7%
Taylor expanded in z around inf 25.5%
associate-/l*64.1%
associate-/r/79.3%
Applied egg-rr79.3%
Final simplification86.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.6) (not (<= y 0.64))) (* y (* (- z x) (/ 1.0 z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.6) || !(y <= 0.64)) {
tmp = y * ((z - x) * (1.0 / 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 <= (-2.6d0)) .or. (.not. (y <= 0.64d0))) then
tmp = y * ((z - x) * (1.0d0 / 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 <= -2.6) || !(y <= 0.64)) {
tmp = y * ((z - x) * (1.0 / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.6) or not (y <= 0.64): tmp = y * ((z - x) * (1.0 / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.6) || !(y <= 0.64)) tmp = Float64(y * Float64(Float64(z - x) * Float64(1.0 / z))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.6) || ~((y <= 0.64))) tmp = y * ((z - x) * (1.0 / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.6], N[Not[LessEqual[y, 0.64]], $MachinePrecision]], N[(y * N[(N[(z - x), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \lor \neg \left(y \leq 0.64\right):\\
\;\;\;\;y \cdot \left(\left(z - x\right) \cdot \frac{1}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.60000000000000009 or 0.640000000000000013 < y Initial program 78.1%
Taylor expanded in y around inf 77.8%
div-inv77.7%
associate-*l*99.6%
Applied egg-rr99.6%
if -2.60000000000000009 < y < 0.640000000000000013Initial program 99.9%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
mul-1-neg100.0%
distribute-frac-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
Simplified100.0%
Final simplification99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -4e-97) (not (<= z 6800000000.0))) (+ y (/ x z)) (* (/ x z) (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4e-97) || !(z <= 6800000000.0)) {
tmp = y + (x / z);
} else {
tmp = (x / z) * (1.0 - 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 ((z <= (-4d-97)) .or. (.not. (z <= 6800000000.0d0))) then
tmp = y + (x / z)
else
tmp = (x / z) * (1.0d0 - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4e-97) || !(z <= 6800000000.0)) {
tmp = y + (x / z);
} else {
tmp = (x / z) * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4e-97) or not (z <= 6800000000.0): tmp = y + (x / z) else: tmp = (x / z) * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4e-97) || !(z <= 6800000000.0)) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(x / z) * Float64(1.0 - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4e-97) || ~((z <= 6800000000.0))) tmp = y + (x / z); else tmp = (x / z) * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4e-97], N[Not[LessEqual[z, 6800000000.0]], $MachinePrecision]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{-97} \lor \neg \left(z \leq 6800000000\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -4.00000000000000014e-97 or 6.8e9 < z Initial program 81.1%
Taylor expanded in x around -inf 94.6%
mul-1-neg94.6%
unsub-neg94.6%
associate-/l*99.3%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 88.0%
mul-1-neg88.0%
distribute-frac-neg88.0%
Simplified88.0%
Taylor expanded in y around 0 88.0%
+-commutative88.0%
Simplified88.0%
if -4.00000000000000014e-97 < z < 6.8e9Initial program 99.9%
Taylor expanded in x around inf 90.7%
associate-/l*86.8%
associate-/r/90.7%
mul-1-neg90.7%
unsub-neg90.7%
Simplified90.7%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.6) (not (<= y 0.64))) (* (- z x) (/ y z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.6) || !(y <= 0.64)) {
tmp = (z - x) * (y / 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 <= (-2.6d0)) .or. (.not. (y <= 0.64d0))) then
tmp = (z - x) * (y / 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 <= -2.6) || !(y <= 0.64)) {
tmp = (z - x) * (y / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.6) or not (y <= 0.64): tmp = (z - x) * (y / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.6) || !(y <= 0.64)) tmp = Float64(Float64(z - x) * Float64(y / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.6) || ~((y <= 0.64))) tmp = (z - x) * (y / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.6], N[Not[LessEqual[y, 0.64]], $MachinePrecision]], N[(N[(z - x), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \lor \neg \left(y \leq 0.64\right):\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.60000000000000009 or 0.640000000000000013 < y Initial program 78.1%
Taylor expanded in y around inf 77.8%
associate-/l*99.6%
associate-/r/93.6%
Simplified93.6%
if -2.60000000000000009 < y < 0.640000000000000013Initial program 99.9%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
mul-1-neg100.0%
distribute-frac-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
Simplified100.0%
Final simplification96.9%
(FPCore (x y z) :precision binary64 (if (<= y -2.6) (* (- z x) (/ y z)) (if (<= y 0.64) (+ y (/ x z)) (- y (/ (* y x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.6) {
tmp = (z - x) * (y / z);
} else if (y <= 0.64) {
tmp = y + (x / z);
} else {
tmp = y - ((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 <= (-2.6d0)) then
tmp = (z - x) * (y / z)
else if (y <= 0.64d0) then
tmp = y + (x / z)
else
tmp = y - ((y * x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.6) {
tmp = (z - x) * (y / z);
} else if (y <= 0.64) {
tmp = y + (x / z);
} else {
tmp = y - ((y * x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.6: tmp = (z - x) * (y / z) elif y <= 0.64: tmp = y + (x / z) else: tmp = y - ((y * x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.6) tmp = Float64(Float64(z - x) * Float64(y / z)); elseif (y <= 0.64) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(Float64(y * x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.6) tmp = (z - x) * (y / z); elseif (y <= 0.64) tmp = y + (x / z); else tmp = y - ((y * x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.6], N[(N[(z - x), $MachinePrecision] * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.64], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6:\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 0.64:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{y \cdot x}{z}\\
\end{array}
\end{array}
if y < -2.60000000000000009Initial program 77.9%
Taylor expanded in y around inf 77.4%
associate-/l*99.4%
associate-/r/96.4%
Simplified96.4%
if -2.60000000000000009 < y < 0.640000000000000013Initial program 99.9%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
mul-1-neg100.0%
distribute-frac-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
+-commutative100.0%
Simplified100.0%
if 0.640000000000000013 < y Initial program 78.2%
Taylor expanded in x around -inf 93.5%
mul-1-neg93.5%
unsub-neg93.5%
associate-/l*92.7%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 93.5%
Final simplification97.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.1e-43) (not (<= x 2.9e+41))) (/ x z) y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e-43) || !(x <= 2.9e+41)) {
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 ((x <= (-2.1d-43)) .or. (.not. (x <= 2.9d+41))) 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 ((x <= -2.1e-43) || !(x <= 2.9e+41)) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.1e-43) or not (x <= 2.9e+41): tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.1e-43) || !(x <= 2.9e+41)) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.1e-43) || ~((x <= 2.9e+41))) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.1e-43], N[Not[LessEqual[x, 2.9e+41]], $MachinePrecision]], N[(x / z), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-43} \lor \neg \left(x \leq 2.9 \cdot 10^{+41}\right):\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -2.1000000000000001e-43 or 2.89999999999999988e41 < x Initial program 92.9%
Taylor expanded in y around 0 61.2%
if -2.1000000000000001e-43 < x < 2.89999999999999988e41Initial program 85.5%
Taylor expanded in x around 0 67.1%
Final simplification64.1%
(FPCore (x y z) :precision binary64 (if (<= y 0.64) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 0.64) {
tmp = y + (x / z);
} else {
tmp = z * (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 (y <= 0.64d0) then
tmp = y + (x / z)
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 0.64) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 0.64: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 0.64) tmp = Float64(y + Float64(x / z)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 0.64) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 0.64], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 0.64:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 0.640000000000000013Initial program 92.7%
Taylor expanded in x around -inf 98.0%
mul-1-neg98.0%
unsub-neg98.0%
associate-/l*99.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 88.3%
mul-1-neg88.3%
distribute-frac-neg88.3%
Simplified88.3%
Taylor expanded in y around 0 88.3%
+-commutative88.3%
Simplified88.3%
if 0.640000000000000013 < y Initial program 78.2%
Taylor expanded in y around inf 78.2%
Taylor expanded in z around inf 31.2%
associate-/l*49.7%
associate-/r/57.3%
Applied egg-rr57.3%
Final simplification81.1%
(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 89.3%
Taylor expanded in x around 0 40.0%
Final simplification40.0%
(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 2023315
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:herbie-target
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))