
(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 (<= y -2.05e+15) (not (<= y 1.0))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.05e+15) || !(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 <= (-2.05d+15)) .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 <= -2.05e+15) || !(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 <= -2.05e+15) 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 <= -2.05e+15) || !(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 <= -2.05e+15) || ~((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, -2.05e+15], 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 -2.05 \cdot 10^{+15} \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 < -2.05e15 or 1 < y Initial program 71.3%
Taylor expanded in y around inf 71.3%
associate-/l*99.8%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if -2.05e15 < y < 1Initial program 99.9%
Taylor expanded in x around 0 99.8%
Taylor expanded in y around 0 98.4%
Final simplification99.1%
(FPCore (x y z)
:precision binary64
(if (<= y -4.8e-58)
y
(if (<= y -5.8e-109)
(/ x z)
(if (<= y -1.7e-156) y (if (<= y 1.68e-49) (/ x z) (* z (/ y z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.8e-58) {
tmp = y;
} else if (y <= -5.8e-109) {
tmp = x / z;
} else if (y <= -1.7e-156) {
tmp = y;
} else if (y <= 1.68e-49) {
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 <= (-4.8d-58)) then
tmp = y
else if (y <= (-5.8d-109)) then
tmp = x / z
else if (y <= (-1.7d-156)) then
tmp = y
else if (y <= 1.68d-49) 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 <= -4.8e-58) {
tmp = y;
} else if (y <= -5.8e-109) {
tmp = x / z;
} else if (y <= -1.7e-156) {
tmp = y;
} else if (y <= 1.68e-49) {
tmp = x / z;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.8e-58: tmp = y elif y <= -5.8e-109: tmp = x / z elif y <= -1.7e-156: tmp = y elif y <= 1.68e-49: tmp = x / z else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.8e-58) tmp = y; elseif (y <= -5.8e-109) tmp = Float64(x / z); elseif (y <= -1.7e-156) tmp = y; elseif (y <= 1.68e-49) 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 <= -4.8e-58) tmp = y; elseif (y <= -5.8e-109) tmp = x / z; elseif (y <= -1.7e-156) tmp = y; elseif (y <= 1.68e-49) tmp = x / z; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.8e-58], y, If[LessEqual[y, -5.8e-109], N[(x / z), $MachinePrecision], If[LessEqual[y, -1.7e-156], y, If[LessEqual[y, 1.68e-49], N[(x / z), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{-58}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-109}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-156}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.68 \cdot 10^{-49}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -4.8000000000000001e-58 or -5.8e-109 < y < -1.69999999999999995e-156Initial program 82.5%
Taylor expanded in x around 0 59.0%
if -4.8000000000000001e-58 < y < -5.8e-109 or -1.69999999999999995e-156 < y < 1.6800000000000001e-49Initial program 100.0%
Taylor expanded in y around 0 81.2%
if 1.6800000000000001e-49 < y Initial program 73.1%
Taylor expanded in y around inf 68.7%
Taylor expanded in z around inf 26.0%
*-commutative26.0%
associate-/l*54.9%
Applied egg-rr54.9%
Final simplification66.6%
(FPCore (x y z)
:precision binary64
(if (<= y 5.5e+58)
(+ y (/ x z))
(if (or (<= y 1.85e+140) (not (<= y 2.1e+219)))
(* x (/ y (- z)))
(* z (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 5.5e+58) {
tmp = y + (x / z);
} else if ((y <= 1.85e+140) || !(y <= 2.1e+219)) {
tmp = x * (y / -z);
} else {
tmp = z * (y / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 5.5d+58) then
tmp = y + (x / z)
else if ((y <= 1.85d+140) .or. (.not. (y <= 2.1d+219))) then
tmp = x * (y / -z)
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 5.5e+58) {
tmp = y + (x / z);
} else if ((y <= 1.85e+140) || !(y <= 2.1e+219)) {
tmp = x * (y / -z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 5.5e+58: tmp = y + (x / z) elif (y <= 1.85e+140) or not (y <= 2.1e+219): tmp = x * (y / -z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 5.5e+58) tmp = Float64(y + Float64(x / z)); elseif ((y <= 1.85e+140) || !(y <= 2.1e+219)) tmp = Float64(x * Float64(y / 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 <= 5.5e+58) tmp = y + (x / z); elseif ((y <= 1.85e+140) || ~((y <= 2.1e+219))) tmp = x * (y / -z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 5.5e+58], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.85e+140], N[Not[LessEqual[y, 2.1e+219]], $MachinePrecision]], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{+58}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+140} \lor \neg \left(y \leq 2.1 \cdot 10^{+219}\right):\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 5.4999999999999999e58Initial program 91.6%
Taylor expanded in x around 0 97.5%
Taylor expanded in y around 0 88.4%
if 5.4999999999999999e58 < y < 1.85000000000000001e140 or 2.09999999999999988e219 < y Initial program 69.6%
Taylor expanded in y around inf 69.6%
Taylor expanded in z around 0 63.1%
mul-1-neg63.1%
distribute-lft-neg-out63.1%
*-commutative63.1%
Simplified63.1%
frac-2neg63.1%
distribute-frac-neg63.1%
add-sqr-sqrt33.0%
sqrt-unprod33.6%
sqr-neg33.6%
sqrt-unprod0.4%
add-sqr-sqrt0.7%
remove-double-neg0.7%
distribute-rgt-neg-out0.7%
frac-2neg0.7%
*-commutative0.7%
associate-/l*0.8%
add-sqr-sqrt0.3%
sqrt-unprod26.0%
sqr-neg26.0%
sqrt-unprod32.8%
add-sqr-sqrt70.8%
Applied egg-rr70.8%
if 1.85000000000000001e140 < y < 2.09999999999999988e219Initial program 63.7%
Taylor expanded in y around inf 63.7%
Taylor expanded in z around inf 27.3%
*-commutative27.3%
associate-/l*63.0%
Applied egg-rr63.0%
Final simplification84.4%
(FPCore (x y z)
:precision binary64
(if (<= y 1.6e+57)
(+ y (/ x z))
(if (<= y 1e+141)
(- (/ x (/ z y)))
(if (<= y 2.8e+219) (* z (/ y z)) (* x (/ y (- z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+57) {
tmp = y + (x / z);
} else if (y <= 1e+141) {
tmp = -(x / (z / y));
} else if (y <= 2.8e+219) {
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.6d+57) then
tmp = y + (x / z)
else if (y <= 1d+141) then
tmp = -(x / (z / y))
else if (y <= 2.8d+219) 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.6e+57) {
tmp = y + (x / z);
} else if (y <= 1e+141) {
tmp = -(x / (z / y));
} else if (y <= 2.8e+219) {
tmp = z * (y / z);
} else {
tmp = x * (y / -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.6e+57: tmp = y + (x / z) elif y <= 1e+141: tmp = -(x / (z / y)) elif y <= 2.8e+219: tmp = z * (y / z) else: tmp = x * (y / -z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.6e+57) tmp = Float64(y + Float64(x / z)); elseif (y <= 1e+141) tmp = Float64(-Float64(x / Float64(z / y))); elseif (y <= 2.8e+219) tmp = Float64(z * Float64(y / z)); else tmp = Float64(x * Float64(y / Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.6e+57) tmp = y + (x / z); elseif (y <= 1e+141) tmp = -(x / (z / y)); elseif (y <= 2.8e+219) tmp = z * (y / z); else tmp = x * (y / -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.6e+57], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+141], (-N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]), If[LessEqual[y, 2.8e+219], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+57}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 10^{+141}:\\
\;\;\;\;-\frac{x}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+219}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\end{array}
\end{array}
if y < 1.60000000000000015e57Initial program 91.6%
Taylor expanded in x around 0 97.5%
Taylor expanded in y around 0 88.4%
if 1.60000000000000015e57 < y < 1.00000000000000002e141Initial program 67.0%
Taylor expanded in y around inf 67.0%
Taylor expanded in z around 0 57.0%
mul-1-neg57.0%
distribute-lft-neg-out57.0%
*-commutative57.0%
Simplified57.0%
frac-2neg57.0%
distribute-frac-neg57.0%
add-sqr-sqrt31.0%
sqrt-unprod31.7%
sqr-neg31.7%
sqrt-unprod0.6%
add-sqr-sqrt0.9%
remove-double-neg0.9%
distribute-rgt-neg-out0.9%
frac-2neg0.9%
*-commutative0.9%
associate-/l*1.0%
add-sqr-sqrt0.3%
sqrt-unprod18.9%
sqr-neg18.9%
sqrt-unprod30.9%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
clear-num70.2%
un-div-inv70.3%
Applied egg-rr70.3%
if 1.00000000000000002e141 < y < 2.80000000000000015e219Initial program 63.7%
Taylor expanded in y around inf 63.7%
Taylor expanded in z around inf 27.3%
*-commutative27.3%
associate-/l*63.0%
Applied egg-rr63.0%
if 2.80000000000000015e219 < y Initial program 73.0%
Taylor expanded in y around inf 73.0%
Taylor expanded in z around 0 71.3%
mul-1-neg71.3%
distribute-lft-neg-out71.3%
*-commutative71.3%
Simplified71.3%
frac-2neg71.3%
distribute-frac-neg71.3%
add-sqr-sqrt35.7%
sqrt-unprod36.1%
sqr-neg36.1%
sqrt-unprod0.2%
add-sqr-sqrt0.5%
remove-double-neg0.5%
distribute-rgt-neg-out0.5%
frac-2neg0.5%
*-commutative0.5%
associate-/l*0.5%
add-sqr-sqrt0.3%
sqrt-unprod35.6%
sqr-neg35.6%
sqrt-unprod35.4%
add-sqr-sqrt71.5%
Applied egg-rr71.5%
Final simplification84.4%
(FPCore (x y z) :precision binary64 (if (<= y 880.0) (+ y (* (/ 1.0 z) (/ x (/ 1.0 (- 1.0 y))))) (* y (- 1.0 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 880.0) {
tmp = y + ((1.0 / z) * (x / (1.0 / (1.0 - y))));
} 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 <= 880.0d0) then
tmp = y + ((1.0d0 / z) * (x / (1.0d0 / (1.0d0 - y))))
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 <= 880.0) {
tmp = y + ((1.0 / z) * (x / (1.0 / (1.0 - y))));
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 880.0: tmp = y + ((1.0 / z) * (x / (1.0 / (1.0 - y)))) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 880.0) tmp = Float64(y + Float64(Float64(1.0 / z) * Float64(x / Float64(1.0 / Float64(1.0 - y))))); 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 <= 880.0) tmp = y + ((1.0 / z) * (x / (1.0 / (1.0 - y)))); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 880.0], N[(y + N[(N[(1.0 / z), $MachinePrecision] * N[(x / N[(1.0 / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 880:\\
\;\;\;\;y + \frac{1}{z} \cdot \frac{x}{\frac{1}{1 - y}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < 880Initial program 92.2%
Taylor expanded in x around 0 97.4%
+-commutative97.4%
mul-1-neg97.4%
sub-neg97.4%
div-sub97.4%
clear-num97.4%
un-div-inv98.0%
Applied egg-rr98.0%
*-un-lft-identity98.0%
div-inv97.9%
times-frac98.8%
Applied egg-rr98.8%
if 880 < y Initial program 69.1%
Taylor expanded in y around inf 69.1%
associate-/l*99.8%
div-sub99.8%
*-inverses99.8%
Simplified99.8%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (<= z -9.5e-17) y (if (<= z 2.35e-30) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e-17) {
tmp = y;
} else if (z <= 2.35e-30) {
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 (z <= (-9.5d-17)) then
tmp = y
else if (z <= 2.35d-30) 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 (z <= -9.5e-17) {
tmp = y;
} else if (z <= 2.35e-30) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9.5e-17: tmp = y elif z <= 2.35e-30: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9.5e-17) tmp = y; elseif (z <= 2.35e-30) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9.5e-17) tmp = y; elseif (z <= 2.35e-30) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9.5e-17], y, If[LessEqual[z, 2.35e-30], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{-17}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 2.35 \cdot 10^{-30}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if z < -9.50000000000000029e-17 or 2.34999999999999985e-30 < z Initial program 76.8%
Taylor expanded in x around 0 65.2%
if -9.50000000000000029e-17 < z < 2.34999999999999985e-30Initial program 99.9%
Taylor expanded in y around 0 57.8%
Final simplification62.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
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.0d0) 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.0) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) 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 <= 1.0) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], 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:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 1Initial program 92.2%
Taylor expanded in x around 0 97.4%
Taylor expanded in y around 0 88.4%
if 1 < y Initial program 69.1%
Taylor expanded in y around inf 69.1%
Taylor expanded in z around inf 20.1%
*-commutative20.1%
associate-/l*53.2%
Applied egg-rr53.2%
Final simplification80.0%
(FPCore (x y z) :precision binary64 (+ y (/ x (/ z (- 1.0 y)))))
double code(double x, double y, double z) {
return y + (x / (z / (1.0 - 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 + (x / (z / (1.0d0 - y)))
end function
public static double code(double x, double y, double z) {
return y + (x / (z / (1.0 - y)));
}
def code(x, y, z): return y + (x / (z / (1.0 - y)))
function code(x, y, z) return Float64(y + Float64(x / Float64(z / Float64(1.0 - y)))) end
function tmp = code(x, y, z) tmp = y + (x / (z / (1.0 - y))); end
code[x_, y_, z_] := N[(y + N[(x / N[(z / N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{\frac{z}{1 - y}}
\end{array}
Initial program 86.7%
Taylor expanded in x around 0 96.5%
+-commutative96.5%
mul-1-neg96.5%
sub-neg96.5%
div-sub96.5%
clear-num96.5%
un-div-inv97.0%
Applied egg-rr97.0%
Final simplification97.0%
(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 86.7%
Taylor expanded in x around 0 41.1%
Final simplification41.1%
(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 2024071
(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))