
(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 14 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 (if (or (<= x -1.25e+56) (not (<= x 0.005))) (* x (+ (/ (- 1.0 y) z) (/ y x))) (+ (/ x z) (* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.25e+56) || !(x <= 0.005)) {
tmp = x * (((1.0 - y) / z) + (y / x));
} else {
tmp = (x / z) + (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 ((x <= (-1.25d+56)) .or. (.not. (x <= 0.005d0))) then
tmp = x * (((1.0d0 - y) / z) + (y / x))
else
tmp = (x / z) + (y * (1.0d0 - (x / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.25e+56) || !(x <= 0.005)) {
tmp = x * (((1.0 - y) / z) + (y / x));
} else {
tmp = (x / z) + (y * (1.0 - (x / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.25e+56) or not (x <= 0.005): tmp = x * (((1.0 - y) / z) + (y / x)) else: tmp = (x / z) + (y * (1.0 - (x / z))) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.25e+56) || !(x <= 0.005)) tmp = Float64(x * Float64(Float64(Float64(1.0 - y) / z) + Float64(y / x))); 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) tmp = 0.0; if ((x <= -1.25e+56) || ~((x <= 0.005))) tmp = x * (((1.0 - y) / z) + (y / x)); else tmp = (x / z) + (y * (1.0 - (x / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.25e+56], N[Not[LessEqual[x, 0.005]], $MachinePrecision]], N[(x * N[(N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision] + N[(y / x), $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}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+56} \lor \neg \left(x \leq 0.005\right):\\
\;\;\;\;x \cdot \left(\frac{1 - y}{z} + \frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if x < -1.25000000000000006e56 or 0.0050000000000000001 < x Initial program 89.6%
Taylor expanded in x around inf 99.9%
associate-+r+99.9%
+-commutative99.9%
mul-1-neg99.9%
unsub-neg99.9%
div-sub99.9%
Simplified99.9%
if -1.25000000000000006e56 < x < 0.0050000000000000001Initial program 85.6%
Taylor expanded in y around 0 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y 1.55e+60)
(+ y (/ x z))
(if (or (<= y 1.1e+138) (not (<= y 2.6e+197)))
(* y (/ x (- z)))
(* z (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.55e+60) {
tmp = y + (x / z);
} else if ((y <= 1.1e+138) || !(y <= 2.6e+197)) {
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 <= 1.55d+60) then
tmp = y + (x / z)
else if ((y <= 1.1d+138) .or. (.not. (y <= 2.6d+197))) 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 <= 1.55e+60) {
tmp = y + (x / z);
} else if ((y <= 1.1e+138) || !(y <= 2.6e+197)) {
tmp = y * (x / -z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.55e+60: tmp = y + (x / z) elif (y <= 1.1e+138) or not (y <= 2.6e+197): tmp = y * (x / -z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.55e+60) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.1e+138) || !(y <= 2.6e+197)) tmp = Float64(y * Float64(x / Float64(-z))); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.55e+60) tmp = y + (x / z); elseif ((y <= 1.1e+138) || ~((y <= 2.6e+197))) tmp = y * (x / -z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.55e+60], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.1e+138], N[Not[LessEqual[y, 2.6e+197]], $MachinePrecision]], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.55 \cdot 10^{+60}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+138} \lor \neg \left(y \leq 2.6 \cdot 10^{+197}\right):\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 1.55e60Initial program 92.7%
Taylor expanded in y around 0 93.3%
Taylor expanded in x around 0 89.4%
if 1.55e60 < y < 1.1e138 or 2.59999999999999987e197 < y Initial program 74.5%
Taylor expanded in y around inf 74.5%
associate-/l*99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 63.4%
mul-1-neg63.4%
associate-*l/67.2%
distribute-rgt-neg-in67.2%
Simplified67.2%
if 1.1e138 < y < 2.59999999999999987e197Initial program 56.1%
Taylor expanded in x around 0 26.1%
*-commutative26.1%
associate-/l*76.9%
Applied egg-rr76.9%
Final simplification84.6%
(FPCore (x y z)
:precision binary64
(if (<= y 1.05e+61)
(+ y (/ x z))
(if (<= y 6e+138)
(* y (/ x (- z)))
(if (<= y 1.75e+195) (* z (/ y z)) (/ (* x (- y)) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.05e+61) {
tmp = y + (x / z);
} else if (y <= 6e+138) {
tmp = y * (x / -z);
} else if (y <= 1.75e+195) {
tmp = z * (y / z);
} else {
tmp = (x * -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 <= 1.05d+61) then
tmp = y + (x / z)
else if (y <= 6d+138) then
tmp = y * (x / -z)
else if (y <= 1.75d+195) then
tmp = z * (y / z)
else
tmp = (x * -y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.05e+61) {
tmp = y + (x / z);
} else if (y <= 6e+138) {
tmp = y * (x / -z);
} else if (y <= 1.75e+195) {
tmp = z * (y / z);
} else {
tmp = (x * -y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.05e+61: tmp = y + (x / z) elif y <= 6e+138: tmp = y * (x / -z) elif y <= 1.75e+195: tmp = z * (y / z) else: tmp = (x * -y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.05e+61) tmp = Float64(y + Float64(x / z)); elseif (y <= 6e+138) tmp = Float64(y * Float64(x / Float64(-z))); elseif (y <= 1.75e+195) tmp = Float64(z * Float64(y / z)); else tmp = Float64(Float64(x * Float64(-y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.05e+61) tmp = y + (x / z); elseif (y <= 6e+138) tmp = y * (x / -z); elseif (y <= 1.75e+195) tmp = z * (y / z); else tmp = (x * -y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.05e+61], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6e+138], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.75e+195], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * (-y)), $MachinePrecision] / z), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.05 \cdot 10^{+61}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 6 \cdot 10^{+138}:\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+195}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(-y\right)}{z}\\
\end{array}
\end{array}
if y < 1.0500000000000001e61Initial program 92.7%
Taylor expanded in y around 0 93.3%
Taylor expanded in x around 0 89.4%
if 1.0500000000000001e61 < y < 6.0000000000000002e138Initial program 75.1%
Taylor expanded in y around inf 75.1%
associate-/l*99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 62.0%
mul-1-neg62.0%
associate-*l/70.0%
distribute-rgt-neg-in70.0%
Simplified70.0%
if 6.0000000000000002e138 < y < 1.7500000000000001e195Initial program 56.1%
Taylor expanded in x around 0 26.1%
*-commutative26.1%
associate-/l*76.9%
Applied egg-rr76.9%
if 1.7500000000000001e195 < y Initial program 74.0%
Taylor expanded in x around inf 64.7%
associate-/l*54.1%
mul-1-neg54.1%
unsub-neg54.1%
Simplified54.1%
Taylor expanded in y around inf 64.7%
mul-1-neg64.7%
distribute-frac-neg64.7%
distribute-rgt-neg-in64.7%
Simplified64.7%
Final simplification84.6%
(FPCore (x y z)
:precision binary64
(if (<= y -1250000000000.0)
(- y (* y (/ x z)))
(if (<= y 3900000000000.0)
(* x (+ (/ (- 1.0 y) z) (/ y x)))
(* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1250000000000.0) {
tmp = y - (y * (x / z));
} else if (y <= 3900000000000.0) {
tmp = x * (((1.0 - y) / z) + (y / x));
} 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 <= (-1250000000000.0d0)) then
tmp = y - (y * (x / z))
else if (y <= 3900000000000.0d0) then
tmp = x * (((1.0d0 - y) / z) + (y / x))
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 <= -1250000000000.0) {
tmp = y - (y * (x / z));
} else if (y <= 3900000000000.0) {
tmp = x * (((1.0 - y) / z) + (y / x));
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1250000000000.0: tmp = y - (y * (x / z)) elif y <= 3900000000000.0: tmp = x * (((1.0 - y) / z) + (y / x)) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1250000000000.0) tmp = Float64(y - Float64(y * Float64(x / z))); elseif (y <= 3900000000000.0) tmp = Float64(x * Float64(Float64(Float64(1.0 - y) / z) + Float64(y / x))); 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 <= -1250000000000.0) tmp = y - (y * (x / z)); elseif (y <= 3900000000000.0) tmp = x * (((1.0 - y) / z) + (y / x)); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1250000000000.0], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3900000000000.0], N[(x * N[(N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision] + N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1250000000000:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 3900000000000:\\
\;\;\;\;x \cdot \left(\frac{1 - y}{z} + \frac{y}{x}\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.25e12Initial program 76.2%
Taylor expanded in y around inf 76.2%
associate-/l*99.8%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
sub-neg99.9%
Simplified99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
if -1.25e12 < y < 3.9e12Initial program 99.2%
Taylor expanded in x around inf 99.8%
associate-+r+99.8%
+-commutative99.8%
mul-1-neg99.8%
unsub-neg99.8%
div-sub99.8%
Simplified99.8%
if 3.9e12 < y Initial program 74.7%
Taylor expanded in y around inf 74.7%
associate-/l*99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
sub-neg99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y -3.5e+42) (- y (* y (/ x z))) (if (<= y 2.45e-20) (/ (+ x (* y (- z x))) z) (* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+42) {
tmp = y - (y * (x / z));
} else if (y <= 2.45e-20) {
tmp = (x + (y * (z - x))) / 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 <= (-3.5d+42)) then
tmp = y - (y * (x / z))
else if (y <= 2.45d-20) then
tmp = (x + (y * (z - x))) / 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 <= -3.5e+42) {
tmp = y - (y * (x / z));
} else if (y <= 2.45e-20) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.5e+42: tmp = y - (y * (x / z)) elif y <= 2.45e-20: tmp = (x + (y * (z - x))) / z else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.5e+42) tmp = Float64(y - Float64(y * Float64(x / z))); elseif (y <= 2.45e-20) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / 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 <= -3.5e+42) tmp = y - (y * (x / z)); elseif (y <= 2.45e-20) tmp = (x + (y * (z - x))) / z; else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.5e+42], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e-20], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{+42}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{-20}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -3.50000000000000023e42Initial program 72.2%
Taylor expanded in y around inf 72.2%
associate-/l*99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
sub-neg99.8%
Simplified99.8%
sub-neg99.8%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
if -3.50000000000000023e42 < y < 2.4500000000000001e-20Initial program 99.9%
if 2.4500000000000001e-20 < y Initial program 75.1%
Taylor expanded in y around inf 74.4%
associate-/l*99.1%
div-sub99.1%
sub-neg99.1%
*-inverses99.1%
sub-neg99.1%
Simplified99.1%
Final simplification99.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -29000000000.0) (not (<= x 8.5e+142))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -29000000000.0) || !(x <= 8.5e+142)) {
tmp = x * ((1.0 - 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 ((x <= (-29000000000.0d0)) .or. (.not. (x <= 8.5d+142))) then
tmp = x * ((1.0d0 - 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 ((x <= -29000000000.0) || !(x <= 8.5e+142)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -29000000000.0) or not (x <= 8.5e+142): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -29000000000.0) || !(x <= 8.5e+142)) tmp = Float64(x * Float64(Float64(1.0 - y) / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -29000000000.0) || ~((x <= 8.5e+142))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -29000000000.0], N[Not[LessEqual[x, 8.5e+142]], $MachinePrecision]], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -29000000000 \lor \neg \left(x \leq 8.5 \cdot 10^{+142}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -2.9e10 or 8.49999999999999955e142 < x Initial program 89.9%
Taylor expanded in x around inf 86.4%
associate-/l*90.4%
mul-1-neg90.4%
unsub-neg90.4%
Simplified90.4%
if -2.9e10 < x < 8.49999999999999955e142Initial program 86.0%
Taylor expanded in y around 0 99.3%
Taylor expanded in x around 0 86.6%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 2.45e-20))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 2.45e-20)) {
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 <= (-1.0d0)) .or. (.not. (y <= 2.45d-20))) 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 <= -1.0) || !(y <= 2.45e-20)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 2.45e-20): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 2.45e-20)) 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 <= -1.0) || ~((y <= 2.45e-20))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 2.45e-20]], $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 -1 \lor \neg \left(y \leq 2.45 \cdot 10^{-20}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 2.4500000000000001e-20 < y Initial program 75.9%
Taylor expanded in y around inf 74.7%
associate-/l*98.7%
div-sub98.7%
sub-neg98.7%
*-inverses98.7%
sub-neg98.7%
Simplified98.7%
if -1 < y < 2.4500000000000001e-20Initial program 99.9%
Taylor expanded in y around 0 90.2%
Taylor expanded in x around 0 99.4%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.0) (- y (* y (/ x z))) (if (<= y 2.45e-20) (+ y (/ x z)) (* y (- 1.0 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = y - (y * (x / z));
} else if (y <= 2.45e-20) {
tmp = y + (x / 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 <= (-1.0d0)) then
tmp = y - (y * (x / z))
else if (y <= 2.45d-20) then
tmp = y + (x / 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 <= -1.0) {
tmp = y - (y * (x / z));
} else if (y <= 2.45e-20) {
tmp = y + (x / z);
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = y - (y * (x / z)) elif y <= 2.45e-20: tmp = y + (x / z) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(y - Float64(y * Float64(x / z))); elseif (y <= 2.45e-20) tmp = Float64(y + Float64(x / 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 <= -1.0) tmp = y - (y * (x / z)); elseif (y <= 2.45e-20) tmp = y + (x / z); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.45e-20], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 2.45 \cdot 10^{-20}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1Initial program 77.0%
Taylor expanded in y around inf 75.2%
associate-/l*98.0%
div-sub98.0%
sub-neg98.0%
*-inverses98.0%
sub-neg98.0%
Simplified98.0%
sub-neg98.0%
distribute-rgt-in98.1%
*-un-lft-identity98.1%
distribute-neg-frac298.1%
Applied egg-rr98.1%
if -1 < y < 2.4500000000000001e-20Initial program 99.9%
Taylor expanded in y around 0 90.2%
Taylor expanded in x around 0 99.4%
if 2.4500000000000001e-20 < y Initial program 75.1%
Taylor expanded in y around inf 74.4%
associate-/l*99.1%
div-sub99.1%
sub-neg99.1%
*-inverses99.1%
sub-neg99.1%
Simplified99.1%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= y 7e+60) (+ y (/ x z)) (if (<= y 1.5e+128) (* (/ y z) (- x)) (* z (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e+60) {
tmp = y + (x / z);
} else if (y <= 1.5e+128) {
tmp = (y / z) * -x;
} 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 <= 7d+60) then
tmp = y + (x / z)
else if (y <= 1.5d+128) then
tmp = (y / z) * -x
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 <= 7e+60) {
tmp = y + (x / z);
} else if (y <= 1.5e+128) {
tmp = (y / z) * -x;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7e+60: tmp = y + (x / z) elif y <= 1.5e+128: tmp = (y / z) * -x else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7e+60) tmp = Float64(y + Float64(x / z)); elseif (y <= 1.5e+128) tmp = Float64(Float64(y / z) * Float64(-x)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7e+60) tmp = y + (x / z); elseif (y <= 1.5e+128) tmp = (y / z) * -x; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7e+60], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e+128], N[(N[(y / z), $MachinePrecision] * (-x)), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{+60}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+128}:\\
\;\;\;\;\frac{y}{z} \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 7.0000000000000004e60Initial program 92.7%
Taylor expanded in y around 0 93.3%
Taylor expanded in x around 0 89.4%
if 7.0000000000000004e60 < y < 1.4999999999999999e128Initial program 84.0%
Taylor expanded in y around inf 84.0%
associate-/l*100.0%
div-sub100.0%
sub-neg100.0%
*-inverses100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 67.4%
mul-1-neg67.4%
associate-/l*62.1%
Simplified62.1%
if 1.4999999999999999e128 < y Initial program 65.0%
Taylor expanded in x around 0 17.6%
*-commutative17.6%
associate-/l*57.1%
Applied egg-rr57.1%
Final simplification82.1%
(FPCore (x y z) :precision binary64 (if (<= y -25500000000.0) y (if (<= y 3e-23) (/ x z) (* z (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -25500000000.0) {
tmp = y;
} else if (y <= 3e-23) {
tmp = 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 <= (-25500000000.0d0)) then
tmp = y
else if (y <= 3d-23) then
tmp = 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 <= -25500000000.0) {
tmp = y;
} else if (y <= 3e-23) {
tmp = x / z;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -25500000000.0: tmp = y elif y <= 3e-23: tmp = x / z else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -25500000000.0) tmp = y; elseif (y <= 3e-23) tmp = 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 <= -25500000000.0) tmp = y; elseif (y <= 3e-23) tmp = x / z; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -25500000000.0], y, If[LessEqual[y, 3e-23], N[(x / z), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -25500000000:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3 \cdot 10^{-23}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.55e10Initial program 76.2%
Taylor expanded in x around 0 64.8%
if -2.55e10 < y < 3.00000000000000003e-23Initial program 99.9%
Taylor expanded in y around 0 73.1%
if 3.00000000000000003e-23 < y Initial program 75.1%
Taylor expanded in x around 0 29.1%
*-commutative29.1%
associate-/l*55.2%
Applied egg-rr55.2%
Final simplification66.0%
(FPCore (x y z) :precision binary64 (if (<= y -25500000000.0) y (if (<= y 2.8e-24) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -25500000000.0) {
tmp = y;
} else if (y <= 2.8e-24) {
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 <= (-25500000000.0d0)) then
tmp = y
else if (y <= 2.8d-24) 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 <= -25500000000.0) {
tmp = y;
} else if (y <= 2.8e-24) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -25500000000.0: tmp = y elif y <= 2.8e-24: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -25500000000.0) tmp = y; elseif (y <= 2.8e-24) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -25500000000.0) tmp = y; elseif (y <= 2.8e-24) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -25500000000.0], y, If[LessEqual[y, 2.8e-24], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -25500000000:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-24}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -2.55e10 or 2.8000000000000002e-24 < y Initial program 75.6%
Taylor expanded in x around 0 56.4%
if -2.55e10 < y < 2.8000000000000002e-24Initial program 99.9%
Taylor expanded in y around 0 73.1%
Final simplification64.6%
(FPCore (x y z) :precision binary64 (if (<= y 4.1e+30) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4.1e+30) {
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 <= 4.1d+30) 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 <= 4.1e+30) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 4.1e+30: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 4.1e+30) 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 <= 4.1e+30) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 4.1e+30], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.1 \cdot 10^{+30}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 4.10000000000000005e30Initial program 92.5%
Taylor expanded in y around 0 93.6%
Taylor expanded in x around 0 89.6%
if 4.10000000000000005e30 < y Initial program 73.6%
Taylor expanded in x around 0 25.0%
*-commutative25.0%
associate-/l*52.8%
Applied egg-rr52.8%
Final simplification79.8%
(FPCore (x y z) :precision binary64 (if (<= y 7e-11) (+ y (/ x z)) (/ (* x y) x)))
double code(double x, double y, double z) {
double tmp;
if (y <= 7e-11) {
tmp = y + (x / z);
} else {
tmp = (x * y) / x;
}
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 <= 7d-11) then
tmp = y + (x / z)
else
tmp = (x * y) / x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 7e-11) {
tmp = y + (x / z);
} else {
tmp = (x * y) / x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 7e-11: tmp = y + (x / z) else: tmp = (x * y) / x return tmp
function code(x, y, z) tmp = 0.0 if (y <= 7e-11) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(x * y) / x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 7e-11) tmp = y + (x / z); else tmp = (x * y) / x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 7e-11], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-11}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{x}\\
\end{array}
\end{array}
if y < 7.00000000000000038e-11Initial program 92.7%
Taylor expanded in y around 0 93.3%
Taylor expanded in x around 0 90.2%
if 7.00000000000000038e-11 < y Initial program 74.8%
Taylor expanded in x around inf 72.2%
associate-+r+72.2%
+-commutative72.2%
mul-1-neg72.2%
unsub-neg72.2%
div-sub72.2%
Simplified72.2%
Taylor expanded in z around inf 30.8%
associate-*r/55.8%
Applied egg-rr55.8%
Final simplification80.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 87.5%
Taylor expanded in x around 0 41.7%
Final simplification41.7%
(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 2024095
(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))