
(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 12 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 -9.2e-72) (not (<= z 1e-74))) (+ (/ x z) (* y (- 1.0 (/ x z)))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.2e-72) || !(z <= 1e-74)) {
tmp = (x / z) + (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 ((z <= (-9.2d-72)) .or. (.not. (z <= 1d-74))) then
tmp = (x / z) + (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 ((z <= -9.2e-72) || !(z <= 1e-74)) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.2e-72) or not (z <= 1e-74): tmp = (x / z) + (y * (1.0 - (x / z))) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.2e-72) || !(z <= 1e-74)) tmp = Float64(Float64(x / z) + 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 ((z <= -9.2e-72) || ~((z <= 1e-74))) tmp = (x / z) + (y * (1.0 - (x / z))); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.2e-72], N[Not[LessEqual[z, 1e-74]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $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 -9.2 \cdot 10^{-72} \lor \neg \left(z \leq 10^{-74}\right):\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if z < -9.19999999999999978e-72 or 9.99999999999999958e-75 < z Initial program 77.8%
Taylor expanded in y around 0 100.0%
if -9.19999999999999978e-72 < z < 9.99999999999999958e-75Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y 2.2e+28)
(+ y (/ x z))
(if (or (<= y 3.5e+62) (not (<= y 4.8e+216)))
(* x (/ y (- z)))
(/ z (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.2e+28) {
tmp = y + (x / z);
} else if ((y <= 3.5e+62) || !(y <= 4.8e+216)) {
tmp = x * (y / -z);
} else {
tmp = z / (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 <= 2.2d+28) then
tmp = y + (x / z)
else if ((y <= 3.5d+62) .or. (.not. (y <= 4.8d+216))) then
tmp = x * (y / -z)
else
tmp = z / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 2.2e+28) {
tmp = y + (x / z);
} else if ((y <= 3.5e+62) || !(y <= 4.8e+216)) {
tmp = x * (y / -z);
} else {
tmp = z / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.2e+28: tmp = y + (x / z) elif (y <= 3.5e+62) or not (y <= 4.8e+216): tmp = x * (y / -z) else: tmp = z / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.2e+28) tmp = Float64(y + Float64(x / z)); elseif ((y <= 3.5e+62) || !(y <= 4.8e+216)) tmp = Float64(x * Float64(y / Float64(-z))); else tmp = Float64(z / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.2e+28) tmp = y + (x / z); elseif ((y <= 3.5e+62) || ~((y <= 4.8e+216))) tmp = x * (y / -z); else tmp = z / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.2e+28], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 3.5e+62], N[Not[LessEqual[y, 4.8e+216]], $MachinePrecision]], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision], N[(z / N[(z / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.2 \cdot 10^{+28}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+62} \lor \neg \left(y \leq 4.8 \cdot 10^{+216}\right):\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < 2.19999999999999986e28Initial program 88.5%
Taylor expanded in x around 0 97.4%
Taylor expanded in y around 0 85.0%
if 2.19999999999999986e28 < y < 3.49999999999999984e62 or 4.7999999999999999e216 < y Initial program 83.3%
Taylor expanded in x around inf 68.9%
associate-/l*65.7%
mul-1-neg65.7%
unsub-neg65.7%
Simplified65.7%
Taylor expanded in y around inf 68.9%
mul-1-neg68.9%
associate-/l*65.7%
distribute-rgt-neg-in65.7%
distribute-neg-frac65.7%
Simplified65.7%
if 3.49999999999999984e62 < y < 4.7999999999999999e216Initial program 65.9%
Taylor expanded in x around 0 46.4%
*-commutative46.4%
associate-/l*77.9%
Applied egg-rr77.9%
clear-num77.8%
un-div-inv78.1%
Applied egg-rr78.1%
Final simplification82.2%
(FPCore (x y z)
:precision binary64
(if (<= y 2.6e+28)
(+ y (/ x z))
(if (<= y 3.8e+62)
(* x (/ y (- z)))
(if (<= y 3.3e+216) (/ z (/ z y)) (/ x (/ z (- y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 2.6e+28) {
tmp = y + (x / z);
} else if (y <= 3.8e+62) {
tmp = x * (y / -z);
} else if (y <= 3.3e+216) {
tmp = z / (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 <= 2.6d+28) then
tmp = y + (x / z)
else if (y <= 3.8d+62) then
tmp = x * (y / -z)
else if (y <= 3.3d+216) then
tmp = z / (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 <= 2.6e+28) {
tmp = y + (x / z);
} else if (y <= 3.8e+62) {
tmp = x * (y / -z);
} else if (y <= 3.3e+216) {
tmp = z / (z / y);
} else {
tmp = x / (z / -y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 2.6e+28: tmp = y + (x / z) elif y <= 3.8e+62: tmp = x * (y / -z) elif y <= 3.3e+216: tmp = z / (z / y) else: tmp = x / (z / -y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 2.6e+28) tmp = Float64(y + Float64(x / z)); elseif (y <= 3.8e+62) tmp = Float64(x * Float64(y / Float64(-z))); elseif (y <= 3.3e+216) tmp = Float64(z / Float64(z / y)); else tmp = Float64(x / Float64(z / Float64(-y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 2.6e+28) tmp = y + (x / z); elseif (y <= 3.8e+62) tmp = x * (y / -z); elseif (y <= 3.3e+216) tmp = z / (z / y); else tmp = x / (z / -y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 2.6e+28], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.8e+62], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.3e+216], N[(z / N[(z / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(z / (-y)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.6 \cdot 10^{+28}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{+62}:\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{+216}:\\
\;\;\;\;\frac{z}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{-y}}\\
\end{array}
\end{array}
if y < 2.6000000000000002e28Initial program 88.5%
Taylor expanded in x around 0 97.4%
Taylor expanded in y around 0 85.0%
if 2.6000000000000002e28 < y < 3.79999999999999984e62Initial program 86.8%
Taylor expanded in x around inf 67.5%
associate-/l*61.6%
mul-1-neg61.6%
unsub-neg61.6%
Simplified61.6%
Taylor expanded in y around inf 67.5%
mul-1-neg67.5%
associate-/l*61.6%
distribute-rgt-neg-in61.6%
distribute-neg-frac61.6%
Simplified61.6%
if 3.79999999999999984e62 < y < 3.3e216Initial program 65.9%
Taylor expanded in x around 0 46.4%
*-commutative46.4%
associate-/l*77.9%
Applied egg-rr77.9%
clear-num77.8%
un-div-inv78.1%
Applied egg-rr78.1%
if 3.3e216 < y Initial program 79.1%
Taylor expanded in y around inf 79.1%
Taylor expanded in x around inf 70.5%
*-commutative70.5%
associate-/l*77.5%
sub-neg77.5%
metadata-eval77.5%
distribute-lft-in77.5%
*-commutative77.5%
neg-mul-177.5%
unsub-neg77.5%
rgt-mult-inverse77.5%
*-commutative77.5%
associate-/r/70.6%
Simplified70.6%
Taylor expanded in y around inf 70.6%
associate-*r/70.6%
mul-1-neg70.6%
Simplified70.6%
Final simplification82.3%
(FPCore (x y z) :precision binary64 (if (<= y -6e+43) (* y (- 1.0 (/ x z))) (if (<= y 4.2e+15) (/ (+ x (* y (- z x))) z) (- y (* y (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e+43) {
tmp = y * (1.0 - (x / z));
} else if (y <= 4.2e+15) {
tmp = (x + (y * (z - 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 <= (-6d+43)) then
tmp = y * (1.0d0 - (x / z))
else if (y <= 4.2d+15) then
tmp = (x + (y * (z - 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 <= -6e+43) {
tmp = y * (1.0 - (x / z));
} else if (y <= 4.2e+15) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e+43: tmp = y * (1.0 - (x / z)) elif y <= 4.2e+15: tmp = (x + (y * (z - x))) / z else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e+43) tmp = Float64(y * Float64(1.0 - Float64(x / z))); elseif (y <= 4.2e+15) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e+43) tmp = y * (1.0 - (x / z)); elseif (y <= 4.2e+15) tmp = (x + (y * (z - x))) / z; else tmp = y - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e+43], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.2e+15], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+43}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+15}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -6.00000000000000033e43Initial program 66.0%
Taylor expanded in y around inf 66.0%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if -6.00000000000000033e43 < y < 4.2e15Initial program 99.9%
if 4.2e15 < y Initial program 75.5%
Taylor expanded in y around inf 75.5%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
sub-neg99.9%
distribute-rgt-in99.9%
*-un-lft-identity99.9%
distribute-neg-frac299.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
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 <= 1.0d0))) 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 <= 1.0)) {
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 <= 1.0): 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 <= 1.0)) 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 <= 1.0))) 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, 1.0]], $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 1\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 74.2%
Taylor expanded in y around inf 73.4%
associate-/l*99.1%
div-sub99.1%
*-inverses99.1%
Simplified99.1%
if -1 < y < 1Initial program 99.9%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 99.6%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.5e-71) (not (<= z 6e-120))) (+ y (/ x z)) (* x (/ (- 1.0 y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e-71) || !(z <= 6e-120)) {
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 <= (-8.5d-71)) .or. (.not. (z <= 6d-120))) 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 <= -8.5e-71) || !(z <= 6e-120)) {
tmp = y + (x / z);
} else {
tmp = x * ((1.0 - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.5e-71) or not (z <= 6e-120): tmp = y + (x / z) else: tmp = x * ((1.0 - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.5e-71) || !(z <= 6e-120)) 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 <= -8.5e-71) || ~((z <= 6e-120))) tmp = y + (x / z); else tmp = x * ((1.0 - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.5e-71], N[Not[LessEqual[z, 6e-120]], $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 -8.5 \cdot 10^{-71} \lor \neg \left(z \leq 6 \cdot 10^{-120}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\end{array}
\end{array}
if z < -8.49999999999999988e-71 or 6.00000000000000022e-120 < z Initial program 78.6%
Taylor expanded in x around 0 99.3%
Taylor expanded in y around 0 85.5%
if -8.49999999999999988e-71 < z < 6.00000000000000022e-120Initial program 99.9%
Taylor expanded in x around inf 91.7%
associate-/l*85.4%
mul-1-neg85.4%
unsub-neg85.4%
Simplified85.4%
Final simplification85.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.0) (* y (- 1.0 (/ x z))) (if (<= y 1.0) (+ y (/ x z)) (- y (* y (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = y * (1.0 - (x / z));
} else if (y <= 1.0) {
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 <= (-1.0d0)) then
tmp = y * (1.0d0 - (x / z))
else if (y <= 1.0d0) 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 <= -1.0) {
tmp = y * (1.0 - (x / z));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = y * (1.0 - (x / z)) elif y <= 1.0: tmp = y + (x / z) else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(y * Float64(1.0 - Float64(x / z))); elseif (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = y * (1.0 - (x / z)); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -1Initial program 71.0%
Taylor expanded in y around inf 70.1%
associate-/l*98.9%
div-sub98.9%
*-inverses98.9%
Simplified98.9%
if -1 < y < 1Initial program 99.9%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 99.6%
if 1 < y Initial program 78.3%
Taylor expanded in y around inf 77.9%
associate-/l*99.4%
div-sub99.4%
*-inverses99.4%
Simplified99.4%
sub-neg99.4%
distribute-rgt-in99.5%
*-un-lft-identity99.5%
distribute-neg-frac299.5%
Applied egg-rr99.5%
Final simplification99.3%
(FPCore (x y z) :precision binary64 (if (<= y -3.25e-289) (+ (/ x z) (* y (- 1.0 (/ x z)))) (+ y (* x (- (/ 1.0 z) (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.25e-289) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = y + (x * ((1.0 / 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 <= (-3.25d-289)) then
tmp = (x / z) + (y * (1.0d0 - (x / z)))
else
tmp = y + (x * ((1.0d0 / z) - (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.25e-289) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = y + (x * ((1.0 / z) - (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.25e-289: tmp = (x / z) + (y * (1.0 - (x / z))) else: tmp = y + (x * ((1.0 / z) - (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.25e-289) tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); else tmp = Float64(y + Float64(x * Float64(Float64(1.0 / z) - Float64(y / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.25e-289) tmp = (x / z) + (y * (1.0 - (x / z))); else tmp = y + (x * ((1.0 / z) - (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.25e-289], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x * N[(N[(1.0 / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.25 \cdot 10^{-289}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + x \cdot \left(\frac{1}{z} - \frac{y}{z}\right)\\
\end{array}
\end{array}
if y < -3.24999999999999987e-289Initial program 83.5%
Taylor expanded in y around 0 99.9%
if -3.24999999999999987e-289 < y Initial program 88.4%
Taylor expanded in x around 0 97.4%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (<= y -3.2e-7) (* z (/ y z)) (if (<= y 2.7e-90) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2e-7) {
tmp = z * (y / z);
} else if (y <= 2.7e-90) {
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 <= (-3.2d-7)) then
tmp = z * (y / z)
else if (y <= 2.7d-90) 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 <= -3.2e-7) {
tmp = z * (y / z);
} else if (y <= 2.7e-90) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2e-7: tmp = z * (y / z) elif y <= 2.7e-90: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2e-7) tmp = Float64(z * Float64(y / z)); elseif (y <= 2.7e-90) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.2e-7) tmp = z * (y / z); elseif (y <= 2.7e-90) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2e-7], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e-90], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-7}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-90}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -3.2000000000000001e-7Initial program 71.4%
Taylor expanded in x around 0 34.7%
*-commutative34.7%
associate-/l*66.7%
Applied egg-rr66.7%
if -3.2000000000000001e-7 < y < 2.69999999999999996e-90Initial program 99.9%
Taylor expanded in y around 0 77.6%
if 2.69999999999999996e-90 < y Initial program 82.1%
Taylor expanded in x around 0 53.0%
(FPCore (x y z) :precision binary64 (if (<= y -2.05e-6) y (if (<= y 2.5e-90) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e-6) {
tmp = y;
} else if (y <= 2.5e-90) {
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 <= (-2.05d-6)) then
tmp = y
else if (y <= 2.5d-90) 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 <= -2.05e-6) {
tmp = y;
} else if (y <= 2.5e-90) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.05e-6: tmp = y elif y <= 2.5e-90: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.05e-6) tmp = y; elseif (y <= 2.5e-90) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.05e-6) tmp = y; elseif (y <= 2.5e-90) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.05e-6], y, If[LessEqual[y, 2.5e-90], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{-6}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-90}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -2.0499999999999999e-6 or 2.5000000000000001e-90 < y Initial program 76.5%
Taylor expanded in x around 0 55.3%
if -2.0499999999999999e-6 < y < 2.5000000000000001e-90Initial program 99.9%
Taylor expanded in y around 0 77.6%
(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 85.7%
Taylor expanded in x around 0 96.9%
Taylor expanded in y around 0 77.6%
(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 85.7%
Taylor expanded in x around 0 43.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 2024101
(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))