
(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 9 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 (<= z -1e+33) (not (<= z 1e-10))) (+ (/ x z) (* (- 1.0 (/ x z)) y)) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+33) || !(z <= 1e-10)) {
tmp = (x / z) + ((1.0 - (x / z)) * y);
} 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 ((z <= (-1d+33)) .or. (.not. (z <= 1d-10))) then
tmp = (x / z) + ((1.0d0 - (x / z)) * y)
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 ((z <= -1e+33) || !(z <= 1e-10)) {
tmp = (x / z) + ((1.0 - (x / z)) * y);
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e+33) or not (z <= 1e-10): tmp = (x / z) + ((1.0 - (x / z)) * y) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e+33) || !(z <= 1e-10)) tmp = Float64(Float64(x / z) + Float64(Float64(1.0 - Float64(x / z)) * y)); 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 ((z <= -1e+33) || ~((z <= 1e-10))) tmp = (x / z) + ((1.0 - (x / z)) * y); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e+33], N[Not[LessEqual[z, 1e-10]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] + N[(N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+33} \lor \neg \left(z \leq 10^{-10}\right):\\
\;\;\;\;\frac{x}{z} + \left(1 - \frac{x}{z}\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if z < -9.9999999999999995e32 or 1.00000000000000004e-10 < z Initial program 70.5%
Taylor expanded in y around 0 99.9%
if -9.9999999999999995e32 < z < 1.00000000000000004e-10Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ x z) y)) (t_1 (* (/ x z) (- y))))
(if (<= y -8.5e+181)
t_0
(if (<= y -3.8e+95)
t_1
(if (<= y 2.5e+37) t_0 (if (<= y 2.25e+136) t_1 (* z (/ y z))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) + y;
double t_1 = (x / z) * -y;
double tmp;
if (y <= -8.5e+181) {
tmp = t_0;
} else if (y <= -3.8e+95) {
tmp = t_1;
} else if (y <= 2.5e+37) {
tmp = t_0;
} else if (y <= 2.25e+136) {
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 = (x / z) + y
t_1 = (x / z) * -y
if (y <= (-8.5d+181)) then
tmp = t_0
else if (y <= (-3.8d+95)) then
tmp = t_1
else if (y <= 2.5d+37) then
tmp = t_0
else if (y <= 2.25d+136) 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 = (x / z) + y;
double t_1 = (x / z) * -y;
double tmp;
if (y <= -8.5e+181) {
tmp = t_0;
} else if (y <= -3.8e+95) {
tmp = t_1;
} else if (y <= 2.5e+37) {
tmp = t_0;
} else if (y <= 2.25e+136) {
tmp = t_1;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) + y t_1 = (x / z) * -y tmp = 0 if y <= -8.5e+181: tmp = t_0 elif y <= -3.8e+95: tmp = t_1 elif y <= 2.5e+37: tmp = t_0 elif y <= 2.25e+136: tmp = t_1 else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) + y) t_1 = Float64(Float64(x / z) * Float64(-y)) tmp = 0.0 if (y <= -8.5e+181) tmp = t_0; elseif (y <= -3.8e+95) tmp = t_1; elseif (y <= 2.5e+37) tmp = t_0; elseif (y <= 2.25e+136) tmp = t_1; else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) + y; t_1 = (x / z) * -y; tmp = 0.0; if (y <= -8.5e+181) tmp = t_0; elseif (y <= -3.8e+95) tmp = t_1; elseif (y <= 2.5e+37) tmp = t_0; elseif (y <= 2.25e+136) tmp = t_1; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] + y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]}, If[LessEqual[y, -8.5e+181], t$95$0, If[LessEqual[y, -3.8e+95], t$95$1, If[LessEqual[y, 2.5e+37], t$95$0, If[LessEqual[y, 2.25e+136], t$95$1, N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} + y\\
t_1 := \frac{x}{z} \cdot \left(-y\right)\\
\mathbf{if}\;y \leq -8.5 \cdot 10^{+181}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3.8 \cdot 10^{+95}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+37}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+136}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -8.49999999999999966e181 or -3.7999999999999999e95 < y < 2.49999999999999994e37Initial program 91.5%
Taylor expanded in x around 0 97.7%
Taylor expanded in y around 0 91.3%
if -8.49999999999999966e181 < y < -3.7999999999999999e95 or 2.49999999999999994e37 < y < 2.25e136Initial program 73.3%
Taylor expanded in y around 0 92.7%
Taylor expanded in y around inf 99.7%
Taylor expanded in x around inf 72.5%
mul-1-neg72.5%
distribute-frac-neg72.5%
Simplified72.5%
if 2.25e136 < y Initial program 62.0%
Taylor expanded in y around inf 62.0%
Taylor expanded in z around inf 27.5%
associate-/l*54.6%
associate-/r/59.9%
Applied egg-rr59.9%
Final simplification84.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (/ x z) y)))
(if (<= y -7.5e+182)
t_0
(if (<= y -1.95e+95)
(/ (- y) (/ z x))
(if (<= y 2.3e+38)
t_0
(if (<= y 1.75e+135) (* (/ x z) (- y)) (* z (/ y z))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) + y;
double tmp;
if (y <= -7.5e+182) {
tmp = t_0;
} else if (y <= -1.95e+95) {
tmp = -y / (z / x);
} else if (y <= 2.3e+38) {
tmp = t_0;
} else if (y <= 1.75e+135) {
tmp = (x / z) * -y;
} 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 = (x / z) + y
if (y <= (-7.5d+182)) then
tmp = t_0
else if (y <= (-1.95d+95)) then
tmp = -y / (z / x)
else if (y <= 2.3d+38) then
tmp = t_0
else if (y <= 1.75d+135) then
tmp = (x / z) * -y
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) + y;
double tmp;
if (y <= -7.5e+182) {
tmp = t_0;
} else if (y <= -1.95e+95) {
tmp = -y / (z / x);
} else if (y <= 2.3e+38) {
tmp = t_0;
} else if (y <= 1.75e+135) {
tmp = (x / z) * -y;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) + y tmp = 0 if y <= -7.5e+182: tmp = t_0 elif y <= -1.95e+95: tmp = -y / (z / x) elif y <= 2.3e+38: tmp = t_0 elif y <= 1.75e+135: tmp = (x / z) * -y else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) + y) tmp = 0.0 if (y <= -7.5e+182) tmp = t_0; elseif (y <= -1.95e+95) tmp = Float64(Float64(-y) / Float64(z / x)); elseif (y <= 2.3e+38) tmp = t_0; elseif (y <= 1.75e+135) tmp = Float64(Float64(x / z) * Float64(-y)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) + y; tmp = 0.0; if (y <= -7.5e+182) tmp = t_0; elseif (y <= -1.95e+95) tmp = -y / (z / x); elseif (y <= 2.3e+38) tmp = t_0; elseif (y <= 1.75e+135) tmp = (x / z) * -y; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] + y), $MachinePrecision]}, If[LessEqual[y, -7.5e+182], t$95$0, If[LessEqual[y, -1.95e+95], N[((-y) / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e+38], t$95$0, If[LessEqual[y, 1.75e+135], N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} + y\\
\mathbf{if}\;y \leq -7.5 \cdot 10^{+182}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{+95}:\\
\;\;\;\;\frac{-y}{\frac{z}{x}}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+135}:\\
\;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -7.49999999999999989e182 or -1.9499999999999999e95 < y < 2.3000000000000001e38Initial program 91.5%
Taylor expanded in x around 0 97.7%
Taylor expanded in y around 0 91.3%
if -7.49999999999999989e182 < y < -1.9499999999999999e95Initial program 66.5%
Taylor expanded in y around inf 66.5%
flip--56.0%
associate-*r/51.3%
+-commutative51.3%
Applied egg-rr51.3%
associate-/l*55.9%
difference-of-squares56.6%
+-commutative56.6%
associate-/r*66.5%
*-inverses66.5%
Simplified66.5%
Taylor expanded in z around 0 48.5%
associate-/l*72.2%
associate-*r/72.2%
neg-mul-172.2%
Simplified72.2%
if 2.3000000000000001e38 < y < 1.7500000000000001e135Initial program 79.2%
Taylor expanded in y around 0 86.8%
Taylor expanded in y around inf 99.8%
Taylor expanded in x around inf 73.0%
mul-1-neg73.0%
distribute-frac-neg73.0%
Simplified73.0%
if 1.7500000000000001e135 < y Initial program 62.0%
Taylor expanded in y around inf 62.0%
Taylor expanded in z around inf 27.5%
associate-/l*54.6%
associate-/r/59.9%
Applied egg-rr59.9%
Final simplification84.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -10000000000000.0) (not (<= y 135000000000.0))) (* (- 1.0 (/ x z)) y) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -10000000000000.0) || !(y <= 135000000000.0)) {
tmp = (1.0 - (x / z)) * y;
} 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 <= (-10000000000000.0d0)) .or. (.not. (y <= 135000000000.0d0))) then
tmp = (1.0d0 - (x / z)) * y
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 <= -10000000000000.0) || !(y <= 135000000000.0)) {
tmp = (1.0 - (x / z)) * y;
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -10000000000000.0) or not (y <= 135000000000.0): tmp = (1.0 - (x / z)) * y else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -10000000000000.0) || !(y <= 135000000000.0)) tmp = Float64(Float64(1.0 - Float64(x / z)) * y); 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 <= -10000000000000.0) || ~((y <= 135000000000.0))) tmp = (1.0 - (x / z)) * y; else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -10000000000000.0], N[Not[LessEqual[y, 135000000000.0]], $MachinePrecision]], N[(N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -10000000000000 \lor \neg \left(y \leq 135000000000\right):\\
\;\;\;\;\left(1 - \frac{x}{z}\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if y < -1e13 or 1.35e11 < y Initial program 68.1%
Taylor expanded in y around 0 95.8%
Taylor expanded in y around inf 99.8%
if -1e13 < y < 1.35e11Initial program 100.0%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -11000000000000.0) (not (<= y 2.9e-9))) (* (- 1.0 (/ x z)) y) (+ (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -11000000000000.0) || !(y <= 2.9e-9)) {
tmp = (1.0 - (x / z)) * y;
} else {
tmp = (x / z) + 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 <= (-11000000000000.0d0)) .or. (.not. (y <= 2.9d-9))) then
tmp = (1.0d0 - (x / z)) * y
else
tmp = (x / z) + y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -11000000000000.0) || !(y <= 2.9e-9)) {
tmp = (1.0 - (x / z)) * y;
} else {
tmp = (x / z) + y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -11000000000000.0) or not (y <= 2.9e-9): tmp = (1.0 - (x / z)) * y else: tmp = (x / z) + y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -11000000000000.0) || !(y <= 2.9e-9)) tmp = Float64(Float64(1.0 - Float64(x / z)) * y); else tmp = Float64(Float64(x / z) + y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -11000000000000.0) || ~((y <= 2.9e-9))) tmp = (1.0 - (x / z)) * y; else tmp = (x / z) + y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -11000000000000.0], N[Not[LessEqual[y, 2.9e-9]], $MachinePrecision]], N[(N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision], N[(N[(x / z), $MachinePrecision] + y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -11000000000000 \lor \neg \left(y \leq 2.9 \cdot 10^{-9}\right):\\
\;\;\;\;\left(1 - \frac{x}{z}\right) \cdot y\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} + y\\
\end{array}
\end{array}
if y < -1.1e13 or 2.89999999999999991e-9 < y Initial program 69.9%
Taylor expanded in y around 0 95.9%
Taylor expanded in y around inf 99.4%
if -1.1e13 < y < 2.89999999999999991e-9Initial program 99.2%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around 0 99.4%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.8e-33) (not (<= y 1.6e-41))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.8e-33) || !(y <= 1.6e-41)) {
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 <= (-3.8d-33)) .or. (.not. (y <= 1.6d-41))) 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 <= -3.8e-33) || !(y <= 1.6e-41)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.8e-33) or not (y <= 1.6e-41): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.8e-33) || !(y <= 1.6e-41)) 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 <= -3.8e-33) || ~((y <= 1.6e-41))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.8e-33], N[Not[LessEqual[y, 1.6e-41]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{-33} \lor \neg \left(y \leq 1.6 \cdot 10^{-41}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -3.79999999999999994e-33 or 1.60000000000000006e-41 < y Initial program 72.0%
Taylor expanded in y around inf 69.6%
Taylor expanded in z around inf 32.1%
associate-/l*51.2%
associate-/r/53.0%
Applied egg-rr53.0%
if -3.79999999999999994e-33 < y < 1.60000000000000006e-41Initial program 100.0%
Taylor expanded in y around 0 74.2%
Final simplification62.5%
(FPCore (x y z) :precision binary64 (if (<= y -7.5e-36) y (if (<= y 6.2e-46) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e-36) {
tmp = y;
} else if (y <= 6.2e-46) {
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 <= (-7.5d-36)) then
tmp = y
else if (y <= 6.2d-46) 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 <= -7.5e-36) {
tmp = y;
} else if (y <= 6.2e-46) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e-36: tmp = y elif y <= 6.2e-46: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e-36) tmp = y; elseif (y <= 6.2e-46) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.5e-36) tmp = y; elseif (y <= 6.2e-46) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e-36], y, If[LessEqual[y, 6.2e-46], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{-36}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{-46}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -7.49999999999999972e-36 or 6.2000000000000002e-46 < y Initial program 72.0%
Taylor expanded in x around 0 51.2%
if -7.49999999999999972e-36 < y < 6.2000000000000002e-46Initial program 100.0%
Taylor expanded in y around 0 74.2%
Final simplification61.5%
(FPCore (x y z) :precision binary64 (+ (/ x z) y))
double code(double x, double y, double z) {
return (x / z) + y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x / z) + y
end function
public static double code(double x, double y, double z) {
return (x / z) + y;
}
def code(x, y, z): return (x / z) + y
function code(x, y, z) return Float64(Float64(x / z) + y) end
function tmp = code(x, y, z) tmp = (x / z) + y; end
code[x_, y_, z_] := N[(N[(x / z), $MachinePrecision] + y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z} + y
\end{array}
Initial program 84.5%
Taylor expanded in x around 0 95.8%
Taylor expanded in y around 0 75.4%
Final simplification75.4%
(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 84.5%
Taylor expanded in x around 0 40.7%
Final simplification40.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 2023181
(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))