
(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 87.8%
Taylor expanded in y around inf 85.4%
Taylor expanded in z around -inf 95.9%
mul-1-neg95.9%
unsub-neg95.9%
distribute-rgt-out95.9%
associate-/l*97.4%
+-commutative97.4%
Simplified97.4%
Taylor expanded in x around 0 95.9%
sub-neg95.9%
metadata-eval95.9%
+-commutative95.9%
associate-*r/100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.1e-15) (not (<= z 7.8e-62))) (+ y (/ x z)) (* (/ x z) (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.1e-15) || !(z <= 7.8e-62)) {
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 <= (-3.1d-15)) .or. (.not. (z <= 7.8d-62))) 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 <= -3.1e-15) || !(z <= 7.8e-62)) {
tmp = y + (x / z);
} else {
tmp = (x / z) * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.1e-15) or not (z <= 7.8e-62): tmp = y + (x / z) else: tmp = (x / z) * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.1e-15) || !(z <= 7.8e-62)) 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 <= -3.1e-15) || ~((z <= 7.8e-62))) tmp = y + (x / z); else tmp = (x / z) * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.1e-15], N[Not[LessEqual[z, 7.8e-62]], $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 -3.1 \cdot 10^{-15} \lor \neg \left(z \leq 7.8 \cdot 10^{-62}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -3.0999999999999999e-15 or 7.8000000000000007e-62 < z Initial program 76.4%
Taylor expanded in y around inf 76.4%
Taylor expanded in z around inf 84.5%
if -3.0999999999999999e-15 < z < 7.8000000000000007e-62Initial program 99.9%
Taylor expanded in y around inf 95.1%
Taylor expanded in z around -inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
distribute-rgt-out99.9%
associate-/l*94.6%
+-commutative94.6%
Simplified94.6%
Taylor expanded in x around 0 99.9%
sub-neg99.9%
metadata-eval99.9%
+-commutative99.9%
associate-*r/100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around -inf 89.8%
sub-neg89.8%
metadata-eval89.8%
associate-*r/89.8%
associate-*l*89.8%
neg-mul-189.8%
*-commutative89.8%
neg-sub089.8%
+-commutative89.8%
associate--r+89.8%
metadata-eval89.8%
Simplified89.8%
Final simplification87.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* y (/ (- z x) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = y * ((z - 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 * ((z - 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 * ((z - 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 * ((z - 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(Float64(z - 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 * ((z - 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[(N[(z - x), $MachinePrecision] / z), $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 \frac{z - x}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 74.4%
Taylor expanded in y around inf 73.8%
*-commutative73.8%
associate-/l*93.3%
associate-/r/99.2%
Simplified99.2%
if -1 < y < 1Initial program 99.9%
Taylor expanded in y around inf 98.4%
Taylor expanded in z around inf 98.9%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.8e+122) (not (<= y 4.9e+225))) (* (/ y z) (- x)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.8e+122) || !(y <= 4.9e+225)) {
tmp = (y / z) * -x;
} 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 <= (-7.8d+122)) .or. (.not. (y <= 4.9d+225))) then
tmp = (y / z) * -x
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 <= -7.8e+122) || !(y <= 4.9e+225)) {
tmp = (y / z) * -x;
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.8e+122) or not (y <= 4.9e+225): tmp = (y / z) * -x else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.8e+122) || !(y <= 4.9e+225)) tmp = Float64(Float64(y / z) * Float64(-x)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.8e+122) || ~((y <= 4.9e+225))) tmp = (y / z) * -x; else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.8e+122], N[Not[LessEqual[y, 4.9e+225]], $MachinePrecision]], N[(N[(y / z), $MachinePrecision] * (-x)), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.8 \cdot 10^{+122} \lor \neg \left(y \leq 4.9 \cdot 10^{+225}\right):\\
\;\;\;\;\frac{y}{z} \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -7.7999999999999999e122 or 4.90000000000000032e225 < y Initial program 79.9%
Taylor expanded in y around inf 79.9%
Taylor expanded in z around 0 60.9%
mul-1-neg60.9%
associate-*l/65.4%
distribute-rgt-neg-out65.4%
Simplified65.4%
if -7.7999999999999999e122 < y < 4.90000000000000032e225Initial program 90.2%
Taylor expanded in y around inf 88.2%
Taylor expanded in z around inf 88.4%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (<= y -3.6e+123) (* y (- (/ x z))) (if (<= y 1.1e+225) (+ y (/ x z)) (* (/ y z) (- x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.6e+123) {
tmp = y * -(x / z);
} else if (y <= 1.1e+225) {
tmp = y + (x / z);
} else {
tmp = (y / z) * -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 <= (-3.6d+123)) then
tmp = y * -(x / z)
else if (y <= 1.1d+225) then
tmp = y + (x / z)
else
tmp = (y / z) * -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.6e+123) {
tmp = y * -(x / z);
} else if (y <= 1.1e+225) {
tmp = y + (x / z);
} else {
tmp = (y / z) * -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.6e+123: tmp = y * -(x / z) elif y <= 1.1e+225: tmp = y + (x / z) else: tmp = (y / z) * -x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.6e+123) tmp = Float64(y * Float64(-Float64(x / z))); elseif (y <= 1.1e+225) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(y / z) * Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.6e+123) tmp = y * -(x / z); elseif (y <= 1.1e+225) tmp = y + (x / z); else tmp = (y / z) * -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.6e+123], N[(y * (-N[(x / z), $MachinePrecision])), $MachinePrecision], If[LessEqual[y, 1.1e+225], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * (-x)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+123}:\\
\;\;\;\;y \cdot \left(-\frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+225}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot \left(-x\right)\\
\end{array}
\end{array}
if y < -3.59999999999999998e123Initial program 83.0%
Taylor expanded in y around inf 83.0%
*-commutative83.0%
associate-/l*95.8%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in z around 0 65.9%
neg-mul-165.9%
distribute-neg-frac65.9%
Simplified65.9%
if -3.59999999999999998e123 < y < 1.10000000000000007e225Initial program 90.2%
Taylor expanded in y around inf 88.2%
Taylor expanded in z around inf 88.4%
if 1.10000000000000007e225 < y Initial program 71.4%
Taylor expanded in y around inf 71.4%
Taylor expanded in z around 0 52.8%
mul-1-neg52.8%
associate-*l/66.4%
distribute-rgt-neg-out66.4%
Simplified66.4%
Final simplification83.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.06e+123) (/ y (/ (- z) x)) (if (<= y 1.3e+225) (+ y (/ x z)) (* (/ y z) (- x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.06e+123) {
tmp = y / (-z / x);
} else if (y <= 1.3e+225) {
tmp = y + (x / z);
} else {
tmp = (y / z) * -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 <= (-1.06d+123)) then
tmp = y / (-z / x)
else if (y <= 1.3d+225) then
tmp = y + (x / z)
else
tmp = (y / z) * -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.06e+123) {
tmp = y / (-z / x);
} else if (y <= 1.3e+225) {
tmp = y + (x / z);
} else {
tmp = (y / z) * -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.06e+123: tmp = y / (-z / x) elif y <= 1.3e+225: tmp = y + (x / z) else: tmp = (y / z) * -x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.06e+123) tmp = Float64(y / Float64(Float64(-z) / x)); elseif (y <= 1.3e+225) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(y / z) * Float64(-x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.06e+123) tmp = y / (-z / x); elseif (y <= 1.3e+225) tmp = y + (x / z); else tmp = (y / z) * -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.06e+123], N[(y / N[((-z) / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e+225], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * (-x)), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.06 \cdot 10^{+123}:\\
\;\;\;\;\frac{y}{\frac{-z}{x}}\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+225}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot \left(-x\right)\\
\end{array}
\end{array}
if y < -1.06e123Initial program 83.0%
Taylor expanded in y around inf 83.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 66.0%
mul-1-neg66.0%
Simplified66.0%
if -1.06e123 < y < 1.30000000000000002e225Initial program 90.2%
Taylor expanded in y around inf 88.2%
Taylor expanded in z around inf 88.4%
if 1.30000000000000002e225 < y Initial program 71.4%
Taylor expanded in y around inf 71.4%
Taylor expanded in z around 0 52.8%
mul-1-neg52.8%
associate-*l/66.4%
distribute-rgt-neg-out66.4%
Simplified66.4%
Final simplification83.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.6e-34) (not (<= y 0.0029))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.6e-34) || !(y <= 0.0029)) {
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.6d-34)) .or. (.not. (y <= 0.0029d0))) 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.6e-34) || !(y <= 0.0029)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.6e-34) or not (y <= 0.0029): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.6e-34) || !(y <= 0.0029)) 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.6e-34) || ~((y <= 0.0029))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.6e-34], N[Not[LessEqual[y, 0.0029]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{-34} \lor \neg \left(y \leq 0.0029\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -3.60000000000000008e-34 or 0.0029 < y Initial program 76.3%
Taylor expanded in y around inf 74.4%
Taylor expanded in z around inf 32.3%
associate-/l*49.2%
associate-/r/55.3%
Applied egg-rr55.3%
if -3.60000000000000008e-34 < y < 0.0029Initial program 99.9%
Taylor expanded in y around 0 80.6%
Final simplification67.5%
(FPCore (x y z) :precision binary64 (if (<= y -3.2e-35) y (if (<= y 0.0026) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2e-35) {
tmp = y;
} else if (y <= 0.0026) {
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-35)) then
tmp = y
else if (y <= 0.0026d0) 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-35) {
tmp = y;
} else if (y <= 0.0026) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2e-35: tmp = y elif y <= 0.0026: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2e-35) tmp = y; elseif (y <= 0.0026) 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-35) tmp = y; elseif (y <= 0.0026) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2e-35], y, If[LessEqual[y, 0.0026], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{-35}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.0026:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -3.1999999999999998e-35 or 0.0025999999999999999 < y Initial program 76.3%
Taylor expanded in x around 0 49.2%
if -3.1999999999999998e-35 < y < 0.0025999999999999999Initial program 99.9%
Taylor expanded in y around 0 80.6%
Final simplification64.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (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) then
tmp = y + (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) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) tmp = Float64(y + 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) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 1Initial program 93.1%
Taylor expanded in y around inf 92.1%
Taylor expanded in z around inf 84.3%
if 1 < y Initial program 65.4%
Taylor expanded in y around inf 57.2%
Taylor expanded in z around inf 46.7%
div-inv46.7%
add-sqr-sqrt28.9%
sqrt-unprod47.2%
sqr-neg47.2%
sqrt-unprod18.6%
add-sqr-sqrt56.2%
cancel-sign-sub-inv56.2%
div-inv56.2%
Applied egg-rr56.2%
Final simplification78.9%
(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 87.8%
Taylor expanded in y around inf 85.4%
Taylor expanded in z around inf 77.1%
Final simplification77.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.8%
Taylor expanded in x around 0 35.8%
Final simplification35.8%
(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 2023182
(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))