
(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 (if (or (<= y -1e+56) (not (<= y 2e+57))) (* y (- 1.0 (/ x z))) (+ y (/ (* x (- 1.0 y)) z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+56) || !(y <= 2e+57)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + ((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 ((y <= (-1d+56)) .or. (.not. (y <= 2d+57))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = y + ((x * (1.0d0 - y)) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1e+56) || !(y <= 2e+57)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + ((x * (1.0 - y)) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e+56) or not (y <= 2e+57): tmp = y * (1.0 - (x / z)) else: tmp = y + ((x * (1.0 - y)) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e+56) || !(y <= 2e+57)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(y + Float64(Float64(x * Float64(1.0 - y)) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1e+56) || ~((y <= 2e+57))) tmp = y * (1.0 - (x / z)); else tmp = y + ((x * (1.0 - y)) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e+56], N[Not[LessEqual[y, 2e+57]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{+56} \lor \neg \left(y \leq 2 \cdot 10^{+57}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x \cdot \left(1 - y\right)}{z}\\
\end{array}
\end{array}
if y < -1.00000000000000009e56 or 2.0000000000000001e57 < y Initial program 73.0%
Taylor expanded in x around 0 95.6%
+-commutative95.6%
fma-def95.6%
+-commutative95.6%
mul-1-neg95.6%
unsub-neg95.6%
Simplified95.6%
Taylor expanded in y around inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
if -1.00000000000000009e56 < y < 2.0000000000000001e57Initial program 99.3%
Taylor expanded in x around inf 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (fma x (- (/ 1.0 z) (/ y z)) y))
double code(double x, double y, double z) {
return fma(x, ((1.0 / z) - (y / z)), y);
}
function code(x, y, z) return fma(x, Float64(Float64(1.0 / z) - Float64(y / z)), y) end
code[x_, y_, z_] := N[(x * N[(N[(1.0 / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision] + y), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, \frac{1}{z} - \frac{y}{z}, y\right)
\end{array}
Initial program 88.6%
Taylor expanded in x around 0 98.0%
+-commutative98.0%
fma-def98.0%
+-commutative98.0%
mul-1-neg98.0%
unsub-neg98.0%
Simplified98.0%
Final simplification98.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))))
(if (<= y -1.15e-16)
t_0
(if (<= y 3.3e-109)
(/ x z)
(if (<= y 3.1e-92) y (if (<= y 0.0152) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -1.15e-16) {
tmp = t_0;
} else if (y <= 3.3e-109) {
tmp = x / z;
} else if (y <= 3.1e-92) {
tmp = y;
} else if (y <= 0.0152) {
tmp = x / z;
} else {
tmp = t_0;
}
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 = z * (y / z)
if (y <= (-1.15d-16)) then
tmp = t_0
else if (y <= 3.3d-109) then
tmp = x / z
else if (y <= 3.1d-92) then
tmp = y
else if (y <= 0.0152d0) then
tmp = x / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -1.15e-16) {
tmp = t_0;
} else if (y <= 3.3e-109) {
tmp = x / z;
} else if (y <= 3.1e-92) {
tmp = y;
} else if (y <= 0.0152) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) tmp = 0 if y <= -1.15e-16: tmp = t_0 elif y <= 3.3e-109: tmp = x / z elif y <= 3.1e-92: tmp = y elif y <= 0.0152: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) tmp = 0.0 if (y <= -1.15e-16) tmp = t_0; elseif (y <= 3.3e-109) tmp = Float64(x / z); elseif (y <= 3.1e-92) tmp = y; elseif (y <= 0.0152) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); tmp = 0.0; if (y <= -1.15e-16) tmp = t_0; elseif (y <= 3.3e-109) tmp = x / z; elseif (y <= 3.1e-92) tmp = y; elseif (y <= 0.0152) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.15e-16], t$95$0, If[LessEqual[y, 3.3e-109], N[(x / z), $MachinePrecision], If[LessEqual[y, 3.1e-92], y, If[LessEqual[y, 0.0152], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -1.15 \cdot 10^{-16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-109}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{-92}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.0152:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.15e-16 or 0.0152 < y Initial program 76.6%
Taylor expanded in z around inf 37.9%
Taylor expanded in x around 0 33.1%
associate-/l*50.0%
associate-/r/53.8%
Applied egg-rr53.8%
if -1.15e-16 < y < 3.2999999999999999e-109 or 3.1000000000000001e-92 < y < 0.0152Initial program 100.0%
Taylor expanded in y around 0 74.0%
if 3.2999999999999999e-109 < y < 3.1000000000000001e-92Initial program 100.0%
Taylor expanded in x around 0 100.0%
Final simplification64.8%
(FPCore (x y z)
:precision binary64
(if (<= y -2e-17)
y
(if (or (<= y 3.3e-109) (and (not (<= y 3.1e-92)) (<= y 0.0135)))
(/ x z)
y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-17) {
tmp = y;
} else if ((y <= 3.3e-109) || (!(y <= 3.1e-92) && (y <= 0.0135))) {
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 <= (-2d-17)) then
tmp = y
else if ((y <= 3.3d-109) .or. (.not. (y <= 3.1d-92)) .and. (y <= 0.0135d0)) 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 <= -2e-17) {
tmp = y;
} else if ((y <= 3.3e-109) || (!(y <= 3.1e-92) && (y <= 0.0135))) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e-17: tmp = y elif (y <= 3.3e-109) or (not (y <= 3.1e-92) and (y <= 0.0135)): tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e-17) tmp = y; elseif ((y <= 3.3e-109) || (!(y <= 3.1e-92) && (y <= 0.0135))) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e-17) tmp = y; elseif ((y <= 3.3e-109) || (~((y <= 3.1e-92)) && (y <= 0.0135))) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e-17], y, If[Or[LessEqual[y, 3.3e-109], And[N[Not[LessEqual[y, 3.1e-92]], $MachinePrecision], LessEqual[y, 0.0135]]], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-17}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-109} \lor \neg \left(y \leq 3.1 \cdot 10^{-92}\right) \land y \leq 0.0135:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -2.00000000000000014e-17 or 3.2999999999999999e-109 < y < 3.1000000000000001e-92 or 0.0134999999999999998 < y Initial program 77.7%
Taylor expanded in x around 0 52.3%
if -2.00000000000000014e-17 < y < 3.2999999999999999e-109 or 3.1000000000000001e-92 < y < 0.0134999999999999998Initial program 100.0%
Taylor expanded in y around 0 74.0%
Final simplification63.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (if (<= y 1e+224) (- y (/ x z)) (if (<= y 6.9e+274) (* y (- (/ x z))) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else if (y <= 1e+224) {
tmp = y - (x / z);
} else if (y <= 6.9e+274) {
tmp = y * -(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 <= 1.0d0) then
tmp = y + (x / z)
else if (y <= 1d+224) then
tmp = y - (x / z)
else if (y <= 6.9d+274) then
tmp = y * -(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 <= 1.0) {
tmp = y + (x / z);
} else if (y <= 1e+224) {
tmp = y - (x / z);
} else if (y <= 6.9e+274) {
tmp = y * -(x / z);
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) elif y <= 1e+224: tmp = y - (x / z) elif y <= 6.9e+274: tmp = y * -(x / z) else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) tmp = Float64(y + Float64(x / z)); elseif (y <= 1e+224) tmp = Float64(y - Float64(x / z)); elseif (y <= 6.9e+274) tmp = Float64(y * Float64(-Float64(x / z))); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.0) tmp = y + (x / z); elseif (y <= 1e+224) tmp = y - (x / z); elseif (y <= 6.9e+274) tmp = y * -(x / z); else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1e+224], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.9e+274], N[(y * (-N[(x / z), $MachinePrecision])), $MachinePrecision], y]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 10^{+224}:\\
\;\;\;\;y - \frac{x}{z}\\
\mathbf{elif}\;y \leq 6.9 \cdot 10^{+274}:\\
\;\;\;\;y \cdot \left(-\frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < 1Initial program 93.9%
Taylor expanded in z around inf 85.2%
Taylor expanded in x around 0 89.8%
if 1 < y < 9.9999999999999997e223Initial program 79.7%
Taylor expanded in z around inf 34.0%
Taylor expanded in x around 0 51.0%
div-inv51.0%
add-sqr-sqrt23.9%
sqrt-unprod68.1%
sqr-neg68.1%
sqrt-unprod41.1%
add-sqr-sqrt66.1%
cancel-sign-sub-inv66.1%
div-inv66.1%
Applied egg-rr66.1%
if 9.9999999999999997e223 < y < 6.8999999999999997e274Initial program 73.4%
Taylor expanded in y around inf 73.4%
associate-*l/86.5%
Simplified86.5%
Taylor expanded in z around 0 57.9%
associate-*l/65.4%
associate-*l*65.4%
*-commutative65.4%
associate-*r/65.4%
neg-mul-165.4%
Simplified65.4%
if 6.8999999999999997e274 < y Initial program 39.4%
Taylor expanded in x around 0 70.4%
Final simplification83.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.6e+38) (not (<= y 1.2e+57))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.6e+38) || !(y <= 1.2e+57)) {
tmp = 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 ((y <= (-2.6d+38)) .or. (.not. (y <= 1.2d+57))) then
tmp = 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 ((y <= -2.6e+38) || !(y <= 1.2e+57)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.6e+38) or not (y <= 1.2e+57): tmp = y * (1.0 - (x / z)) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.6e+38) || !(y <= 1.2e+57)) tmp = 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 ((y <= -2.6e+38) || ~((y <= 1.2e+57))) tmp = y * (1.0 - (x / z)); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.6e+38], N[Not[LessEqual[y, 1.2e+57]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.6 \cdot 10^{+38} \lor \neg \left(y \leq 1.2 \cdot 10^{+57}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if y < -2.5999999999999999e38 or 1.20000000000000002e57 < y Initial program 72.9%
Taylor expanded in x around 0 95.7%
+-commutative95.7%
fma-def95.7%
+-commutative95.7%
mul-1-neg95.7%
unsub-neg95.7%
Simplified95.7%
Taylor expanded in y around inf 99.9%
mul-1-neg99.9%
unsub-neg99.9%
Simplified99.9%
if -2.5999999999999999e38 < y < 1.20000000000000002e57Initial program 100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.8e+71) (not (<= x 2.65e+38))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.8e+71) || !(x <= 2.65e+38)) {
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 <= (-8.8d+71)) .or. (.not. (x <= 2.65d+38))) 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 <= -8.8e+71) || !(x <= 2.65e+38)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.8e+71) or not (x <= 2.65e+38): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.8e+71) || !(x <= 2.65e+38)) 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 <= -8.8e+71) || ~((x <= 2.65e+38))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.8e+71], N[Not[LessEqual[x, 2.65e+38]], $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 -8.8 \cdot 10^{+71} \lor \neg \left(x \leq 2.65 \cdot 10^{+38}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -8.79999999999999978e71 or 2.65000000000000012e38 < x Initial program 87.5%
Taylor expanded in x around 0 99.6%
+-commutative99.6%
fma-def99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
Simplified99.6%
Taylor expanded in x around inf 86.5%
div-sub86.5%
Simplified86.5%
if -8.79999999999999978e71 < x < 2.65000000000000012e38Initial program 89.4%
Taylor expanded in z around inf 77.5%
Taylor expanded in x around 0 88.0%
Final simplification87.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.8e+46) (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.8e+46) || !(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.8d+46)) .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.8e+46) || !(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.8e+46) 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.8e+46) || !(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.8e+46) || ~((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.8e+46], 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.8 \cdot 10^{+46} \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.80000000000000018e46 or 1 < y Initial program 75.0%
Taylor expanded in x around 0 96.0%
+-commutative96.0%
fma-def96.0%
+-commutative96.0%
mul-1-neg96.0%
unsub-neg96.0%
Simplified96.0%
Taylor expanded in y around inf 98.9%
mul-1-neg98.9%
unsub-neg98.9%
Simplified98.9%
if -2.80000000000000018e46 < y < 1Initial program 100.0%
Taylor expanded in z around inf 98.9%
Taylor expanded in x around 0 98.9%
Final simplification98.9%
(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.9%
Taylor expanded in z around inf 85.2%
Taylor expanded in x around 0 89.8%
if 1 < y Initial program 75.2%
Taylor expanded in z around inf 29.7%
Taylor expanded in x around 0 47.2%
div-inv47.2%
add-sqr-sqrt20.2%
sqrt-unprod64.9%
sqr-neg64.9%
sqrt-unprod38.7%
add-sqr-sqrt59.6%
cancel-sign-sub-inv59.6%
div-inv59.6%
Applied egg-rr59.6%
Final simplification81.3%
(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 88.6%
Taylor expanded in z around inf 69.6%
Taylor expanded in x around 0 77.8%
Final simplification77.8%
(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 88.6%
Taylor expanded in x around 0 40.1%
Final simplification40.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 2024017
(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))