
(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 10 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 88.9%
Taylor expanded in x around -inf 96.6%
mul-1-neg96.6%
unsub-neg96.6%
associate-/l*97.1%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ (- y) z))) (t_1 (+ y (/ x z))))
(if (<= y -2.05e+272)
t_0
(if (<= y -5.8e+87)
t_1
(if (<= y -3e+39)
t_0
(if (<= y 7300000.0) t_1 (if (<= y 9.2e+120) t_0 (* z (/ y z)))))))))
double code(double x, double y, double z) {
double t_0 = x * (-y / z);
double t_1 = y + (x / z);
double tmp;
if (y <= -2.05e+272) {
tmp = t_0;
} else if (y <= -5.8e+87) {
tmp = t_1;
} else if (y <= -3e+39) {
tmp = t_0;
} else if (y <= 7300000.0) {
tmp = t_1;
} else if (y <= 9.2e+120) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (-y / z)
t_1 = y + (x / z)
if (y <= (-2.05d+272)) then
tmp = t_0
else if (y <= (-5.8d+87)) then
tmp = t_1
else if (y <= (-3d+39)) then
tmp = t_0
else if (y <= 7300000.0d0) then
tmp = t_1
else if (y <= 9.2d+120) then
tmp = t_0
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (-y / z);
double t_1 = y + (x / z);
double tmp;
if (y <= -2.05e+272) {
tmp = t_0;
} else if (y <= -5.8e+87) {
tmp = t_1;
} else if (y <= -3e+39) {
tmp = t_0;
} else if (y <= 7300000.0) {
tmp = t_1;
} else if (y <= 9.2e+120) {
tmp = t_0;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = x * (-y / z) t_1 = y + (x / z) tmp = 0 if y <= -2.05e+272: tmp = t_0 elif y <= -5.8e+87: tmp = t_1 elif y <= -3e+39: tmp = t_0 elif y <= 7300000.0: tmp = t_1 elif y <= 9.2e+120: tmp = t_0 else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(Float64(-y) / z)) t_1 = Float64(y + Float64(x / z)) tmp = 0.0 if (y <= -2.05e+272) tmp = t_0; elseif (y <= -5.8e+87) tmp = t_1; elseif (y <= -3e+39) tmp = t_0; elseif (y <= 7300000.0) tmp = t_1; elseif (y <= 9.2e+120) tmp = t_0; else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (-y / z); t_1 = y + (x / z); tmp = 0.0; if (y <= -2.05e+272) tmp = t_0; elseif (y <= -5.8e+87) tmp = t_1; elseif (y <= -3e+39) tmp = t_0; elseif (y <= 7300000.0) tmp = t_1; elseif (y <= 9.2e+120) tmp = t_0; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.05e+272], t$95$0, If[LessEqual[y, -5.8e+87], t$95$1, If[LessEqual[y, -3e+39], t$95$0, If[LessEqual[y, 7300000.0], t$95$1, If[LessEqual[y, 9.2e+120], t$95$0, N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{-y}{z}\\
t_1 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -2.05 \cdot 10^{+272}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{+87}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -3 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7300000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+120}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.04999999999999989e272 or -5.7999999999999996e87 < y < -3e39 or 7.3e6 < y < 9.1999999999999997e120Initial program 81.9%
Taylor expanded in y around inf 81.9%
associate-/l*99.8%
associate-/r/97.8%
Simplified97.8%
Taylor expanded in z around 0 66.4%
associate-*r/71.9%
associate-*r*71.9%
neg-mul-171.9%
*-commutative71.9%
Simplified71.9%
if -2.04999999999999989e272 < y < -5.7999999999999996e87 or -3e39 < y < 7.3e6Initial program 94.8%
Taylor expanded in x around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
associate-/l*98.5%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 91.3%
mul-1-neg91.3%
distribute-frac-neg91.3%
Simplified91.3%
Taylor expanded in y around 0 91.3%
+-commutative91.3%
Simplified91.3%
if 9.1999999999999997e120 < y Initial program 73.7%
Taylor expanded in x around 0 34.4%
associate-/l*56.2%
associate-/r/67.0%
Applied egg-rr67.0%
Final simplification83.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (/ (- z) x))) (t_1 (+ y (/ x z))))
(if (<= y -2.15e+272)
(* x (/ (- y) z))
(if (<= y -1.5e+89)
t_1
(if (<= y -3.1e+39)
t_0
(if (<= y 1400000000000.0)
t_1
(if (<= y 1.56e+121) t_0 (* z (/ y z)))))))))
double code(double x, double y, double z) {
double t_0 = y / (-z / x);
double t_1 = y + (x / z);
double tmp;
if (y <= -2.15e+272) {
tmp = x * (-y / z);
} else if (y <= -1.5e+89) {
tmp = t_1;
} else if (y <= -3.1e+39) {
tmp = t_0;
} else if (y <= 1400000000000.0) {
tmp = t_1;
} else if (y <= 1.56e+121) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y / (-z / x)
t_1 = y + (x / z)
if (y <= (-2.15d+272)) then
tmp = x * (-y / z)
else if (y <= (-1.5d+89)) then
tmp = t_1
else if (y <= (-3.1d+39)) then
tmp = t_0
else if (y <= 1400000000000.0d0) then
tmp = t_1
else if (y <= 1.56d+121) then
tmp = t_0
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (-z / x);
double t_1 = y + (x / z);
double tmp;
if (y <= -2.15e+272) {
tmp = x * (-y / z);
} else if (y <= -1.5e+89) {
tmp = t_1;
} else if (y <= -3.1e+39) {
tmp = t_0;
} else if (y <= 1400000000000.0) {
tmp = t_1;
} else if (y <= 1.56e+121) {
tmp = t_0;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = y / (-z / x) t_1 = y + (x / z) tmp = 0 if y <= -2.15e+272: tmp = x * (-y / z) elif y <= -1.5e+89: tmp = t_1 elif y <= -3.1e+39: tmp = t_0 elif y <= 1400000000000.0: tmp = t_1 elif y <= 1.56e+121: tmp = t_0 else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(y / Float64(Float64(-z) / x)) t_1 = Float64(y + Float64(x / z)) tmp = 0.0 if (y <= -2.15e+272) tmp = Float64(x * Float64(Float64(-y) / z)); elseif (y <= -1.5e+89) tmp = t_1; elseif (y <= -3.1e+39) tmp = t_0; elseif (y <= 1400000000000.0) tmp = t_1; elseif (y <= 1.56e+121) tmp = t_0; else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (-z / x); t_1 = y + (x / z); tmp = 0.0; if (y <= -2.15e+272) tmp = x * (-y / z); elseif (y <= -1.5e+89) tmp = t_1; elseif (y <= -3.1e+39) tmp = t_0; elseif (y <= 1400000000000.0) tmp = t_1; elseif (y <= 1.56e+121) tmp = t_0; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[((-z) / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.15e+272], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.5e+89], t$95$1, If[LessEqual[y, -3.1e+39], t$95$0, If[LessEqual[y, 1400000000000.0], t$95$1, If[LessEqual[y, 1.56e+121], t$95$0, N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{\frac{-z}{x}}\\
t_1 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -2.15 \cdot 10^{+272}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\mathbf{elif}\;y \leq -1.5 \cdot 10^{+89}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -3.1 \cdot 10^{+39}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1400000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.56 \cdot 10^{+121}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.15000000000000002e272Initial program 88.6%
Taylor expanded in y around inf 88.6%
associate-/l*100.0%
associate-/r/100.0%
Simplified100.0%
Taylor expanded in z around 0 87.9%
associate-*r/87.9%
associate-*r*87.9%
neg-mul-187.9%
*-commutative87.9%
Simplified87.9%
if -2.15000000000000002e272 < y < -1.50000000000000006e89 or -3.1000000000000003e39 < y < 1.4e12Initial program 94.8%
Taylor expanded in x around -inf 99.4%
mul-1-neg99.4%
unsub-neg99.4%
associate-/l*98.5%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 91.3%
mul-1-neg91.3%
distribute-frac-neg91.3%
Simplified91.3%
Taylor expanded in y around 0 91.3%
+-commutative91.3%
Simplified91.3%
if -1.50000000000000006e89 < y < -3.1000000000000003e39 or 1.4e12 < y < 1.5599999999999999e121Initial program 80.6%
Taylor expanded in y around inf 80.6%
associate-/l*99.8%
associate-/r/97.4%
Simplified97.4%
associate-*l/80.6%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 71.0%
associate-*r/71.0%
neg-mul-171.0%
Simplified71.0%
if 1.5599999999999999e121 < y Initial program 73.7%
Taylor expanded in x around 0 34.4%
associate-/l*56.2%
associate-/r/67.0%
Applied egg-rr67.0%
Final simplification84.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))))
(if (<= y -5e-11)
t_0
(if (<= y -2.25e-74)
(/ x z)
(if (<= y -1.26e-85) y (if (<= y 2.2e-26) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -5e-11) {
tmp = t_0;
} else if (y <= -2.25e-74) {
tmp = x / z;
} else if (y <= -1.26e-85) {
tmp = y;
} else if (y <= 2.2e-26) {
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 <= (-5d-11)) then
tmp = t_0
else if (y <= (-2.25d-74)) then
tmp = x / z
else if (y <= (-1.26d-85)) then
tmp = y
else if (y <= 2.2d-26) 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 <= -5e-11) {
tmp = t_0;
} else if (y <= -2.25e-74) {
tmp = x / z;
} else if (y <= -1.26e-85) {
tmp = y;
} else if (y <= 2.2e-26) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) tmp = 0 if y <= -5e-11: tmp = t_0 elif y <= -2.25e-74: tmp = x / z elif y <= -1.26e-85: tmp = y elif y <= 2.2e-26: 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 <= -5e-11) tmp = t_0; elseif (y <= -2.25e-74) tmp = Float64(x / z); elseif (y <= -1.26e-85) tmp = y; elseif (y <= 2.2e-26) 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 <= -5e-11) tmp = t_0; elseif (y <= -2.25e-74) tmp = x / z; elseif (y <= -1.26e-85) tmp = y; elseif (y <= 2.2e-26) 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, -5e-11], t$95$0, If[LessEqual[y, -2.25e-74], N[(x / z), $MachinePrecision], If[LessEqual[y, -1.26e-85], y, If[LessEqual[y, 2.2e-26], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -5 \cdot 10^{-11}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.25 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -1.26 \cdot 10^{-85}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-26}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -5.00000000000000018e-11 or 2.2000000000000001e-26 < y Initial program 80.0%
Taylor expanded in x around 0 31.5%
associate-/l*46.7%
associate-/r/55.5%
Applied egg-rr55.5%
if -5.00000000000000018e-11 < y < -2.25e-74 or -1.26e-85 < y < 2.2000000000000001e-26Initial program 99.9%
Taylor expanded in y around 0 75.7%
if -2.25e-74 < y < -1.26e-85Initial program 99.4%
Taylor expanded in x around 0 100.0%
Final simplification65.0%
(FPCore (x y z)
:precision binary64
(if (<= y -2.2e-18)
y
(if (or (<= y -2.2e-74) (and (not (<= y -1.25e-85)) (<= y 9.5e-27)))
(/ x z)
y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.2e-18) {
tmp = y;
} else if ((y <= -2.2e-74) || (!(y <= -1.25e-85) && (y <= 9.5e-27))) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.2d-18)) then
tmp = y
else if ((y <= (-2.2d-74)) .or. (.not. (y <= (-1.25d-85))) .and. (y <= 9.5d-27)) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.2e-18) {
tmp = y;
} else if ((y <= -2.2e-74) || (!(y <= -1.25e-85) && (y <= 9.5e-27))) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.2e-18: tmp = y elif (y <= -2.2e-74) or (not (y <= -1.25e-85) and (y <= 9.5e-27)): tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.2e-18) tmp = y; elseif ((y <= -2.2e-74) || (!(y <= -1.25e-85) && (y <= 9.5e-27))) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.2e-18) tmp = y; elseif ((y <= -2.2e-74) || (~((y <= -1.25e-85)) && (y <= 9.5e-27))) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.2e-18], y, If[Or[LessEqual[y, -2.2e-74], And[N[Not[LessEqual[y, -1.25e-85]], $MachinePrecision], LessEqual[y, 9.5e-27]]], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-18}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -2.2 \cdot 10^{-74} \lor \neg \left(y \leq -1.25 \cdot 10^{-85}\right) \land y \leq 9.5 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -2.1999999999999998e-18 or -2.2000000000000001e-74 < y < -1.25e-85 or 9.50000000000000037e-27 < y Initial program 80.6%
Taylor expanded in x around 0 48.6%
if -2.1999999999999998e-18 < y < -2.2000000000000001e-74 or -1.25e-85 < y < 9.50000000000000037e-27Initial program 99.9%
Taylor expanded in y around 0 75.7%
Final simplification60.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -10500000000.0) (not (<= y 1.0))) (* (- z x) (/ y z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -10500000000.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 <= (-10500000000.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 <= -10500000000.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 <= -10500000000.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 <= -10500000000.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 <= -10500000000.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, -10500000000.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 -10500000000 \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.05e10 or 1 < y Initial program 78.4%
Taylor expanded in y around inf 78.0%
associate-/l*99.4%
associate-/r/92.9%
Simplified92.9%
if -1.05e10 < y < 1Initial program 99.9%
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 99.5%
mul-1-neg99.5%
distribute-frac-neg99.5%
Simplified99.5%
Taylor expanded in y around 0 99.5%
+-commutative99.5%
Simplified99.5%
Final simplification96.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -10500000000.0) (not (<= y 1.0))) (/ y (/ z (- z x))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -10500000000.0) || !(y <= 1.0)) {
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 <= (-10500000000.0d0)) .or. (.not. (y <= 1.0d0))) 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 <= -10500000000.0) || !(y <= 1.0)) {
tmp = y / (z / (z - x));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -10500000000.0) or not (y <= 1.0): tmp = y / (z / (z - x)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -10500000000.0) || !(y <= 1.0)) 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 <= -10500000000.0) || ~((y <= 1.0))) tmp = y / (z / (z - x)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -10500000000.0], N[Not[LessEqual[y, 1.0]], $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 -10500000000 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1.05e10 or 1 < y Initial program 78.4%
Taylor expanded in y around inf 78.0%
associate-/l*99.4%
associate-/r/92.9%
Simplified92.9%
associate-*l/78.0%
associate-/l*99.4%
Applied egg-rr99.4%
if -1.05e10 < y < 1Initial program 99.9%
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 99.5%
mul-1-neg99.5%
distribute-frac-neg99.5%
Simplified99.5%
Taylor expanded in y around 0 99.5%
+-commutative99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (<= y 11500.0) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 11500.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 <= 11500.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 <= 11500.0) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 11500.0: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 11500.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 <= 11500.0) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 11500.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 11500:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 11500Initial program 93.4%
Taylor expanded in x around -inf 98.5%
mul-1-neg98.5%
unsub-neg98.5%
associate-/l*98.7%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 84.9%
mul-1-neg84.9%
distribute-frac-neg84.9%
Simplified84.9%
Taylor expanded in y around 0 84.9%
+-commutative84.9%
Simplified84.9%
if 11500 < y Initial program 76.6%
Taylor expanded in x around 0 29.4%
associate-/l*47.1%
associate-/r/56.6%
Applied egg-rr56.6%
Final simplification77.4%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (/ z (/ z y))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = z / (z / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = z / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = z / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = z / (z / y) 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(z / y)); 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 / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(z / N[(z / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < 1Initial program 93.3%
Taylor expanded in x around -inf 98.4%
mul-1-neg98.4%
unsub-neg98.4%
associate-/l*98.7%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 85.3%
mul-1-neg85.3%
distribute-frac-neg85.3%
Simplified85.3%
Taylor expanded in y around 0 85.3%
+-commutative85.3%
Simplified85.3%
if 1 < y Initial program 77.3%
Taylor expanded in x around 0 30.0%
associate-/l*47.2%
associate-/r/56.4%
Applied egg-rr56.4%
*-commutative56.4%
clear-num56.3%
un-div-inv56.4%
Applied egg-rr56.4%
Final simplification77.4%
(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.9%
Taylor expanded in x around 0 39.0%
Final simplification39.0%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2023320
(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))