
(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) (- 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(Float64(x / 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[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{z} \cdot \left(1 - y\right)
\end{array}
Initial program 89.4%
Taylor expanded in x around -inf 97.1%
mul-1-neg97.1%
unsub-neg97.1%
associate-/l*96.6%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))) (t_1 (* (/ x z) (- y))))
(if (<= y -5.4e+243)
t_0
(if (<= y -1.35e+164)
t_1
(if (<= y -5.2e-122) t_0 (if (<= y 7.8e-15) (/ x z) t_1))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double t_1 = (x / z) * -y;
double tmp;
if (y <= -5.4e+243) {
tmp = t_0;
} else if (y <= -1.35e+164) {
tmp = t_1;
} else if (y <= -5.2e-122) {
tmp = t_0;
} else if (y <= 7.8e-15) {
tmp = x / z;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = z * (y / z)
t_1 = (x / z) * -y
if (y <= (-5.4d+243)) then
tmp = t_0
else if (y <= (-1.35d+164)) then
tmp = t_1
else if (y <= (-5.2d-122)) then
tmp = t_0
else if (y <= 7.8d-15) then
tmp = x / z
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y / z);
double t_1 = (x / z) * -y;
double tmp;
if (y <= -5.4e+243) {
tmp = t_0;
} else if (y <= -1.35e+164) {
tmp = t_1;
} else if (y <= -5.2e-122) {
tmp = t_0;
} else if (y <= 7.8e-15) {
tmp = x / z;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) t_1 = (x / z) * -y tmp = 0 if y <= -5.4e+243: tmp = t_0 elif y <= -1.35e+164: tmp = t_1 elif y <= -5.2e-122: tmp = t_0 elif y <= 7.8e-15: tmp = x / z else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) t_1 = Float64(Float64(x / z) * Float64(-y)) tmp = 0.0 if (y <= -5.4e+243) tmp = t_0; elseif (y <= -1.35e+164) tmp = t_1; elseif (y <= -5.2e-122) tmp = t_0; elseif (y <= 7.8e-15) tmp = Float64(x / z); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); t_1 = (x / z) * -y; tmp = 0.0; if (y <= -5.4e+243) tmp = t_0; elseif (y <= -1.35e+164) tmp = t_1; elseif (y <= -5.2e-122) tmp = t_0; elseif (y <= 7.8e-15) tmp = x / z; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]}, If[LessEqual[y, -5.4e+243], t$95$0, If[LessEqual[y, -1.35e+164], t$95$1, If[LessEqual[y, -5.2e-122], t$95$0, If[LessEqual[y, 7.8e-15], N[(x / z), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
t_1 := \frac{x}{z} \cdot \left(-y\right)\\
\mathbf{if}\;y \leq -5.4 \cdot 10^{+243}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{+164}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-122}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -5.4000000000000003e243 or -1.35000000000000003e164 < y < -5.1999999999999995e-122Initial program 78.7%
Taylor expanded in x around 0 41.5%
associate-/l*60.4%
associate-/r/65.3%
Applied egg-rr65.3%
if -5.4000000000000003e243 < y < -1.35000000000000003e164 or 7.80000000000000053e-15 < y Initial program 86.1%
Taylor expanded in x around inf 63.0%
associate-/l*63.1%
associate-/r/65.2%
mul-1-neg65.2%
unsub-neg65.2%
Simplified65.2%
Taylor expanded in y around inf 62.9%
mul-1-neg62.9%
associate-*r/63.0%
*-commutative63.0%
distribute-rgt-neg-out63.0%
Simplified63.0%
Taylor expanded in y around 0 62.9%
mul-1-neg62.9%
associate-*l/65.1%
distribute-lft-neg-in65.1%
*-commutative65.1%
distribute-neg-frac65.1%
Simplified65.1%
if -5.1999999999999995e-122 < y < 7.80000000000000053e-15Initial program 100.0%
Taylor expanded in y around 0 81.0%
Final simplification71.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))))
(if (<= y -2.2e+241)
t_0
(if (<= y -1.1e+164)
(* x (/ (- y) z))
(if (<= y -5.2e-122)
t_0
(if (<= y 7.8e-15) (/ x z) (* (/ x z) (- y))))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -2.2e+241) {
tmp = t_0;
} else if (y <= -1.1e+164) {
tmp = x * (-y / z);
} else if (y <= -5.2e-122) {
tmp = t_0;
} else if (y <= 7.8e-15) {
tmp = x / z;
} 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) :: t_0
real(8) :: tmp
t_0 = z * (y / z)
if (y <= (-2.2d+241)) then
tmp = t_0
else if (y <= (-1.1d+164)) then
tmp = x * (-y / z)
else if (y <= (-5.2d-122)) then
tmp = t_0
else if (y <= 7.8d-15) then
tmp = x / z
else
tmp = (x / z) * -y
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 <= -2.2e+241) {
tmp = t_0;
} else if (y <= -1.1e+164) {
tmp = x * (-y / z);
} else if (y <= -5.2e-122) {
tmp = t_0;
} else if (y <= 7.8e-15) {
tmp = x / z;
} else {
tmp = (x / z) * -y;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) tmp = 0 if y <= -2.2e+241: tmp = t_0 elif y <= -1.1e+164: tmp = x * (-y / z) elif y <= -5.2e-122: tmp = t_0 elif y <= 7.8e-15: tmp = x / z else: tmp = (x / z) * -y return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) tmp = 0.0 if (y <= -2.2e+241) tmp = t_0; elseif (y <= -1.1e+164) tmp = Float64(x * Float64(Float64(-y) / z)); elseif (y <= -5.2e-122) tmp = t_0; elseif (y <= 7.8e-15) tmp = Float64(x / z); else tmp = Float64(Float64(x / z) * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); tmp = 0.0; if (y <= -2.2e+241) tmp = t_0; elseif (y <= -1.1e+164) tmp = x * (-y / z); elseif (y <= -5.2e-122) tmp = t_0; elseif (y <= 7.8e-15) tmp = x / z; else tmp = (x / z) * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.2e+241], t$95$0, If[LessEqual[y, -1.1e+164], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.2e-122], t$95$0, If[LessEqual[y, 7.8e-15], N[(x / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -2.2 \cdot 10^{+241}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.1 \cdot 10^{+164}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-122}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7.8 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\
\end{array}
\end{array}
if y < -2.2e241 or -1.10000000000000003e164 < y < -5.1999999999999995e-122Initial program 78.7%
Taylor expanded in x around 0 41.5%
associate-/l*60.4%
associate-/r/65.3%
Applied egg-rr65.3%
if -2.2e241 < y < -1.10000000000000003e164Initial program 83.2%
Taylor expanded in x around inf 77.0%
associate-/l*77.2%
associate-/r/77.1%
mul-1-neg77.1%
unsub-neg77.1%
Simplified77.1%
Taylor expanded in y around inf 77.0%
mul-1-neg77.0%
associate-*r/77.3%
*-commutative77.3%
distribute-rgt-neg-out77.3%
Simplified77.3%
if -5.1999999999999995e-122 < y < 7.80000000000000053e-15Initial program 100.0%
Taylor expanded in y around 0 81.0%
if 7.80000000000000053e-15 < y Initial program 86.9%
Taylor expanded in x around inf 59.3%
associate-/l*59.3%
associate-/r/62.1%
mul-1-neg62.1%
unsub-neg62.1%
Simplified62.1%
Taylor expanded in y around inf 59.1%
mul-1-neg59.1%
associate-*r/59.2%
*-commutative59.2%
distribute-rgt-neg-out59.2%
Simplified59.2%
Taylor expanded in y around 0 59.1%
mul-1-neg59.1%
associate-*l/61.9%
distribute-lft-neg-in61.9%
*-commutative61.9%
distribute-neg-frac61.9%
Simplified61.9%
Final simplification71.4%
(FPCore (x y z)
:precision binary64
(if (<= y -3.2e+244)
(* z (/ y z))
(if (<= y -7e+164)
(* x (/ (- y) z))
(if (<= y 2.3) (+ y (/ x z)) (* (/ x z) (- y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2e+244) {
tmp = z * (y / z);
} else if (y <= -7e+164) {
tmp = x * (-y / z);
} else if (y <= 2.3) {
tmp = y + (x / z);
} 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 <= (-3.2d+244)) then
tmp = z * (y / z)
else if (y <= (-7d+164)) then
tmp = x * (-y / z)
else if (y <= 2.3d0) then
tmp = y + (x / z)
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 <= -3.2e+244) {
tmp = z * (y / z);
} else if (y <= -7e+164) {
tmp = x * (-y / z);
} else if (y <= 2.3) {
tmp = y + (x / z);
} else {
tmp = (x / z) * -y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2e+244: tmp = z * (y / z) elif y <= -7e+164: tmp = x * (-y / z) elif y <= 2.3: tmp = y + (x / z) else: tmp = (x / z) * -y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2e+244) tmp = Float64(z * Float64(y / z)); elseif (y <= -7e+164) tmp = Float64(x * Float64(Float64(-y) / z)); elseif (y <= 2.3) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(x / z) * Float64(-y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.2e+244) tmp = z * (y / z); elseif (y <= -7e+164) tmp = x * (-y / z); elseif (y <= 2.3) tmp = y + (x / z); else tmp = (x / z) * -y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2e+244], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -7e+164], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+244}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq -7 \cdot 10^{+164}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\mathbf{elif}\;y \leq 2.3:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(-y\right)\\
\end{array}
\end{array}
if y < -3.2000000000000002e244Initial program 57.7%
Taylor expanded in x around 0 29.1%
associate-/l*71.4%
associate-/r/85.8%
Applied egg-rr85.8%
if -3.2000000000000002e244 < y < -6.9999999999999995e164Initial program 83.2%
Taylor expanded in x around inf 77.0%
associate-/l*77.2%
associate-/r/77.1%
mul-1-neg77.1%
unsub-neg77.1%
Simplified77.1%
Taylor expanded in y around inf 77.0%
mul-1-neg77.0%
associate-*r/77.3%
*-commutative77.3%
distribute-rgt-neg-out77.3%
Simplified77.3%
if -6.9999999999999995e164 < y < 2.2999999999999998Initial program 93.6%
Taylor expanded in x around -inf 98.3%
mul-1-neg98.3%
unsub-neg98.3%
associate-/l*99.4%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 92.1%
mul-1-neg92.1%
distribute-frac-neg92.1%
Simplified92.1%
if 2.2999999999999998 < y Initial program 86.3%
Taylor expanded in x around inf 62.0%
associate-/l*62.1%
associate-/r/64.9%
mul-1-neg64.9%
unsub-neg64.9%
Simplified64.9%
Taylor expanded in y around inf 61.9%
mul-1-neg61.9%
associate-*r/61.9%
*-commutative61.9%
distribute-rgt-neg-out61.9%
Simplified61.9%
Taylor expanded in y around 0 61.9%
mul-1-neg61.9%
associate-*l/64.8%
distribute-lft-neg-in64.8%
*-commutative64.8%
distribute-neg-frac64.8%
Simplified64.8%
Final simplification84.3%
(FPCore (x y z)
:precision binary64
(if (<= y -9.5e+243)
(* z (/ y z))
(if (<= y -1.7e+165)
(* x (/ (- y) z))
(if (<= y 2.3) (+ y (/ x z)) (/ y (/ (- z) x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9.5e+243) {
tmp = z * (y / z);
} else if (y <= -1.7e+165) {
tmp = x * (-y / z);
} else if (y <= 2.3) {
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 <= (-9.5d+243)) then
tmp = z * (y / z)
else if (y <= (-1.7d+165)) then
tmp = x * (-y / z)
else if (y <= 2.3d0) 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 <= -9.5e+243) {
tmp = z * (y / z);
} else if (y <= -1.7e+165) {
tmp = x * (-y / z);
} else if (y <= 2.3) {
tmp = y + (x / z);
} else {
tmp = y / (-z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9.5e+243: tmp = z * (y / z) elif y <= -1.7e+165: tmp = x * (-y / z) elif y <= 2.3: tmp = y + (x / z) else: tmp = y / (-z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9.5e+243) tmp = Float64(z * Float64(y / z)); elseif (y <= -1.7e+165) tmp = Float64(x * Float64(Float64(-y) / z)); elseif (y <= 2.3) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y / Float64(Float64(-z) / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9.5e+243) tmp = z * (y / z); elseif (y <= -1.7e+165) tmp = x * (-y / z); elseif (y <= 2.3) tmp = y + (x / z); else tmp = y / (-z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9.5e+243], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.7e+165], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y / N[((-z) / x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+243}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{+165}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\mathbf{elif}\;y \leq 2.3:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{-z}{x}}\\
\end{array}
\end{array}
if y < -9.49999999999999957e243Initial program 57.7%
Taylor expanded in x around 0 29.1%
associate-/l*71.4%
associate-/r/85.8%
Applied egg-rr85.8%
if -9.49999999999999957e243 < y < -1.70000000000000005e165Initial program 83.2%
Taylor expanded in x around inf 77.0%
associate-/l*77.2%
associate-/r/77.1%
mul-1-neg77.1%
unsub-neg77.1%
Simplified77.1%
Taylor expanded in y around inf 77.0%
mul-1-neg77.0%
associate-*r/77.3%
*-commutative77.3%
distribute-rgt-neg-out77.3%
Simplified77.3%
if -1.70000000000000005e165 < y < 2.2999999999999998Initial program 93.6%
Taylor expanded in x around -inf 98.3%
mul-1-neg98.3%
unsub-neg98.3%
associate-/l*99.4%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 92.1%
mul-1-neg92.1%
distribute-frac-neg92.1%
Simplified92.1%
if 2.2999999999999998 < y Initial program 86.3%
Taylor expanded in y around inf 86.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 64.8%
associate-*r/64.8%
neg-mul-164.8%
Simplified64.8%
Final simplification84.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -125000.0) (not (<= z 3e-71))) (+ y (/ x z)) (* (/ x z) (- 1.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -125000.0) || !(z <= 3e-71)) {
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 <= (-125000.0d0)) .or. (.not. (z <= 3d-71))) 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 <= -125000.0) || !(z <= 3e-71)) {
tmp = y + (x / z);
} else {
tmp = (x / z) * (1.0 - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -125000.0) or not (z <= 3e-71): tmp = y + (x / z) else: tmp = (x / z) * (1.0 - y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -125000.0) || !(z <= 3e-71)) 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 <= -125000.0) || ~((z <= 3e-71))) tmp = y + (x / z); else tmp = (x / z) * (1.0 - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -125000.0], N[Not[LessEqual[z, 3e-71]], $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 -125000 \lor \neg \left(z \leq 3 \cdot 10^{-71}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - y\right)\\
\end{array}
\end{array}
if z < -125000 or 3.0000000000000001e-71 < z Initial program 80.9%
Taylor expanded in x around -inf 94.7%
mul-1-neg94.7%
unsub-neg94.7%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 90.2%
mul-1-neg90.2%
distribute-frac-neg90.2%
Simplified90.2%
if -125000 < z < 3.0000000000000001e-71Initial program 99.9%
Taylor expanded in x around inf 88.9%
associate-/l*86.5%
associate-/r/88.9%
mul-1-neg88.9%
unsub-neg88.9%
Simplified88.9%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 1.0))) (* (- z x) (/ y z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 1.0)) {
tmp = (z - x) * (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 ((y <= (-1.0d0)) .or. (.not. (y <= 1.0d0))) then
tmp = (z - x) * (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 ((y <= -1.0) || !(y <= 1.0)) {
tmp = (z - x) * (y / 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 = (z - x) * (y / 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(Float64(z - x) * Float64(y / 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 = (z - x) * (y / 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[(N[(z - x), $MachinePrecision] * N[(y / 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):\\
\;\;\;\;\left(z - x\right) \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 1 < y Initial program 79.9%
Taylor expanded in y around inf 78.8%
associate-/l*98.9%
associate-/r/92.6%
Simplified92.6%
if -1 < y < 1Initial program 100.0%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
mul-1-neg98.7%
distribute-frac-neg98.7%
Simplified98.7%
Final simplification95.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 7.8e-15))) (/ y (/ z (- z x))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 7.8e-15)) {
tmp = y / (z / (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 <= (-1.0d0)) .or. (.not. (y <= 7.8d-15))) then
tmp = y / (z / (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 <= -1.0) || !(y <= 7.8e-15)) {
tmp = y / (z / (z - x));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 7.8e-15): tmp = y / (z / (z - x)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 7.8e-15)) tmp = Float64(y / Float64(z / Float64(z - x))); 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 <= 7.8e-15))) tmp = y / (z / (z - x)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 7.8e-15]], $MachinePrecision]], N[(y / N[(z / N[(z - x), $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 7.8 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1 or 7.80000000000000053e-15 < y Initial program 80.3%
Taylor expanded in y around inf 79.3%
associate-/l*99.0%
Simplified99.0%
if -1 < y < 7.80000000000000053e-15Initial program 100.0%
Taylor expanded in x around -inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
associate-/l*100.0%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 98.7%
mul-1-neg98.7%
distribute-frac-neg98.7%
Simplified98.7%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.2e-122) (not (<= y 1.58e-25))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e-122) || !(y <= 1.58e-25)) {
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 <= (-5.2d-122)) .or. (.not. (y <= 1.58d-25))) 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 <= -5.2e-122) || !(y <= 1.58e-25)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.2e-122) or not (y <= 1.58e-25): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.2e-122) || !(y <= 1.58e-25)) 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 <= -5.2e-122) || ~((y <= 1.58e-25))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.2e-122], N[Not[LessEqual[y, 1.58e-25]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-122} \lor \neg \left(y \leq 1.58 \cdot 10^{-25}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -5.1999999999999995e-122 or 1.57999999999999989e-25 < y Initial program 82.8%
Taylor expanded in x around 0 34.6%
associate-/l*48.3%
associate-/r/55.3%
Applied egg-rr55.3%
if -5.1999999999999995e-122 < y < 1.57999999999999989e-25Initial program 100.0%
Taylor expanded in y around 0 81.7%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (if (<= y -5.2e-122) y (if (<= y 1.4e-25) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.2e-122) {
tmp = y;
} else if (y <= 1.4e-25) {
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 <= (-5.2d-122)) then
tmp = y
else if (y <= 1.4d-25) 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 <= -5.2e-122) {
tmp = y;
} else if (y <= 1.4e-25) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.2e-122: tmp = y elif y <= 1.4e-25: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.2e-122) tmp = y; elseif (y <= 1.4e-25) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.2e-122) tmp = y; elseif (y <= 1.4e-25) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.2e-122], y, If[LessEqual[y, 1.4e-25], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{-122}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-25}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -5.1999999999999995e-122 or 1.39999999999999994e-25 < y Initial program 82.8%
Taylor expanded in x around 0 48.3%
if -5.1999999999999995e-122 < y < 1.39999999999999994e-25Initial program 100.0%
Taylor expanded in y around 0 81.7%
Final simplification61.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 89.4%
Taylor expanded in x around 0 37.7%
Final simplification37.7%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2024021
(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))