
(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 8 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 88.3%
Taylor expanded in x around -inf 94.0%
mul-1-neg94.0%
unsub-neg94.0%
associate-/l*96.3%
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 (- (* y (/ x z)))))
(if (<= y -1.16e+109)
t_0
(if (<= y -1.45e+57)
t_1
(if (<= y -6.2e-62)
y
(if (<= y 5e-15) (/ x z) (if (<= y 4e+203) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double t_1 = -(y * (x / z));
double tmp;
if (y <= -1.16e+109) {
tmp = t_0;
} else if (y <= -1.45e+57) {
tmp = t_1;
} else if (y <= -6.2e-62) {
tmp = y;
} else if (y <= 5e-15) {
tmp = x / z;
} else if (y <= 4e+203) {
tmp = t_0;
} 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 = -(y * (x / z))
if (y <= (-1.16d+109)) then
tmp = t_0
else if (y <= (-1.45d+57)) then
tmp = t_1
else if (y <= (-6.2d-62)) then
tmp = y
else if (y <= 5d-15) then
tmp = x / z
else if (y <= 4d+203) then
tmp = t_0
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 = -(y * (x / z));
double tmp;
if (y <= -1.16e+109) {
tmp = t_0;
} else if (y <= -1.45e+57) {
tmp = t_1;
} else if (y <= -6.2e-62) {
tmp = y;
} else if (y <= 5e-15) {
tmp = x / z;
} else if (y <= 4e+203) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) t_1 = -(y * (x / z)) tmp = 0 if y <= -1.16e+109: tmp = t_0 elif y <= -1.45e+57: tmp = t_1 elif y <= -6.2e-62: tmp = y elif y <= 5e-15: tmp = x / z elif y <= 4e+203: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) t_1 = Float64(-Float64(y * Float64(x / z))) tmp = 0.0 if (y <= -1.16e+109) tmp = t_0; elseif (y <= -1.45e+57) tmp = t_1; elseif (y <= -6.2e-62) tmp = y; elseif (y <= 5e-15) tmp = Float64(x / z); elseif (y <= 4e+203) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); t_1 = -(y * (x / z)); tmp = 0.0; if (y <= -1.16e+109) tmp = t_0; elseif (y <= -1.45e+57) tmp = t_1; elseif (y <= -6.2e-62) tmp = y; elseif (y <= 5e-15) tmp = x / z; elseif (y <= 4e+203) tmp = t_0; 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[(y * N[(x / z), $MachinePrecision]), $MachinePrecision])}, If[LessEqual[y, -1.16e+109], t$95$0, If[LessEqual[y, -1.45e+57], t$95$1, If[LessEqual[y, -6.2e-62], y, If[LessEqual[y, 5e-15], N[(x / z), $MachinePrecision], If[LessEqual[y, 4e+203], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
t_1 := -y \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -1.16 \cdot 10^{+109}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{+57}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-62}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+203}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -1.16000000000000003e109 or 4.99999999999999999e-15 < y < 4e203Initial program 70.7%
Taylor expanded in y around inf 70.0%
Taylor expanded in z around inf 38.2%
associate-/l*61.6%
associate-/r/67.5%
Applied egg-rr67.5%
if -1.16000000000000003e109 < y < -1.4500000000000001e57 or 4e203 < y Initial program 92.4%
Taylor expanded in x around inf 77.2%
associate-/l*77.3%
associate-/r/80.7%
mul-1-neg80.7%
unsub-neg80.7%
Simplified80.7%
Taylor expanded in y around inf 77.2%
mul-1-neg77.2%
associate-*r/77.2%
*-commutative77.2%
distribute-rgt-neg-out77.2%
Simplified77.2%
Taylor expanded in y around 0 77.2%
associate-*l/80.7%
associate-*r*80.7%
neg-mul-180.7%
*-commutative80.7%
distribute-neg-frac80.7%
Simplified80.7%
if -1.4500000000000001e57 < y < -6.1999999999999999e-62Initial program 96.0%
Taylor expanded in x around 0 71.6%
if -6.1999999999999999e-62 < y < 4.99999999999999999e-15Initial program 99.9%
Taylor expanded in y around 0 76.0%
Final simplification72.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))))
(if (<= y -2.35e+110)
t_0
(if (<= y -2.4e+60)
(* x (/ (- y) z))
(if (<= y -6e-62)
y
(if (<= y 6e-15)
(/ x z)
(if (<= y 8.5e+200) t_0 (* y (/ (- x) z)))))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -2.35e+110) {
tmp = t_0;
} else if (y <= -2.4e+60) {
tmp = x * (-y / z);
} else if (y <= -6e-62) {
tmp = y;
} else if (y <= 6e-15) {
tmp = x / z;
} else if (y <= 8.5e+200) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = z * (y / z)
if (y <= (-2.35d+110)) then
tmp = t_0
else if (y <= (-2.4d+60)) then
tmp = x * (-y / z)
else if (y <= (-6d-62)) then
tmp = y
else if (y <= 6d-15) then
tmp = x / z
else if (y <= 8.5d+200) then
tmp = t_0
else
tmp = y * (-x / z)
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.35e+110) {
tmp = t_0;
} else if (y <= -2.4e+60) {
tmp = x * (-y / z);
} else if (y <= -6e-62) {
tmp = y;
} else if (y <= 6e-15) {
tmp = x / z;
} else if (y <= 8.5e+200) {
tmp = t_0;
} else {
tmp = y * (-x / z);
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) tmp = 0 if y <= -2.35e+110: tmp = t_0 elif y <= -2.4e+60: tmp = x * (-y / z) elif y <= -6e-62: tmp = y elif y <= 6e-15: tmp = x / z elif y <= 8.5e+200: tmp = t_0 else: tmp = y * (-x / z) return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) tmp = 0.0 if (y <= -2.35e+110) tmp = t_0; elseif (y <= -2.4e+60) tmp = Float64(x * Float64(Float64(-y) / z)); elseif (y <= -6e-62) tmp = y; elseif (y <= 6e-15) tmp = Float64(x / z); elseif (y <= 8.5e+200) tmp = t_0; else tmp = Float64(y * Float64(Float64(-x) / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); tmp = 0.0; if (y <= -2.35e+110) tmp = t_0; elseif (y <= -2.4e+60) tmp = x * (-y / z); elseif (y <= -6e-62) tmp = y; elseif (y <= 6e-15) tmp = x / z; elseif (y <= 8.5e+200) tmp = t_0; else tmp = y * (-x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.35e+110], t$95$0, If[LessEqual[y, -2.4e+60], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -6e-62], y, If[LessEqual[y, 6e-15], N[(x / z), $MachinePrecision], If[LessEqual[y, 8.5e+200], t$95$0, N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -2.35 \cdot 10^{+110}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.4 \cdot 10^{+60}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\mathbf{elif}\;y \leq -6 \cdot 10^{-62}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+200}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\end{array}
\end{array}
if y < -2.3499999999999999e110 or 6e-15 < y < 8.5e200Initial program 70.7%
Taylor expanded in y around inf 70.0%
Taylor expanded in z around inf 38.2%
associate-/l*61.6%
associate-/r/67.5%
Applied egg-rr67.5%
if -2.3499999999999999e110 < y < -2.4e60Initial program 82.8%
Taylor expanded in x around inf 74.2%
associate-/l*82.4%
associate-/r/82.2%
mul-1-neg82.2%
unsub-neg82.2%
Simplified82.2%
Taylor expanded in y around inf 74.2%
mul-1-neg74.2%
associate-*r/82.2%
*-commutative82.2%
distribute-rgt-neg-out82.2%
Simplified82.2%
if -2.4e60 < y < -6.0000000000000002e-62Initial program 96.0%
Taylor expanded in x around 0 71.6%
if -6.0000000000000002e-62 < y < 6e-15Initial program 99.9%
Taylor expanded in y around 0 76.0%
if 8.5e200 < y Initial program 100.0%
Taylor expanded in x around inf 79.5%
associate-/l*73.3%
associate-/r/79.5%
mul-1-neg79.5%
unsub-neg79.5%
Simplified79.5%
Taylor expanded in y around inf 79.5%
mul-1-neg79.5%
associate-*r/73.3%
*-commutative73.3%
distribute-rgt-neg-out73.3%
Simplified73.3%
Taylor expanded in y around 0 79.5%
associate-*l/79.5%
associate-*r*79.5%
neg-mul-179.5%
*-commutative79.5%
distribute-neg-frac79.5%
Simplified79.5%
Final simplification72.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))))
(if (<= y -1.78e+106)
t_0
(if (<= y -1.75e+59)
(* x (/ (- y) z))
(if (<= y 8.5e+202) t_0 (* y (/ (- x) z)))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -1.78e+106) {
tmp = t_0;
} else if (y <= -1.75e+59) {
tmp = x * (-y / z);
} else if (y <= 8.5e+202) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y + (x / z)
if (y <= (-1.78d+106)) then
tmp = t_0
else if (y <= (-1.75d+59)) then
tmp = x * (-y / z)
else if (y <= 8.5d+202) then
tmp = t_0
else
tmp = y * (-x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -1.78e+106) {
tmp = t_0;
} else if (y <= -1.75e+59) {
tmp = x * (-y / z);
} else if (y <= 8.5e+202) {
tmp = t_0;
} else {
tmp = y * (-x / z);
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) tmp = 0 if y <= -1.78e+106: tmp = t_0 elif y <= -1.75e+59: tmp = x * (-y / z) elif y <= 8.5e+202: tmp = t_0 else: tmp = y * (-x / z) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) tmp = 0.0 if (y <= -1.78e+106) tmp = t_0; elseif (y <= -1.75e+59) tmp = Float64(x * Float64(Float64(-y) / z)); elseif (y <= 8.5e+202) tmp = t_0; else tmp = Float64(y * Float64(Float64(-x) / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); tmp = 0.0; if (y <= -1.78e+106) tmp = t_0; elseif (y <= -1.75e+59) tmp = x * (-y / z); elseif (y <= 8.5e+202) tmp = t_0; else tmp = y * (-x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.78e+106], t$95$0, If[LessEqual[y, -1.75e+59], N[(x * N[((-y) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.5e+202], t$95$0, N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -1.78 \cdot 10^{+106}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{+59}:\\
\;\;\;\;x \cdot \frac{-y}{z}\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+202}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\end{array}
\end{array}
if y < -1.77999999999999995e106 or -1.75e59 < y < 8.5000000000000003e202Initial program 87.8%
Taylor expanded in x around -inf 93.8%
mul-1-neg93.8%
unsub-neg93.8%
associate-/l*96.6%
associate-/r/100.0%
sub-neg100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 85.9%
mul-1-neg85.9%
distribute-frac-neg85.9%
Simplified85.9%
if -1.77999999999999995e106 < y < -1.75e59Initial program 82.8%
Taylor expanded in x around inf 74.2%
associate-/l*82.4%
associate-/r/82.2%
mul-1-neg82.2%
unsub-neg82.2%
Simplified82.2%
Taylor expanded in y around inf 74.2%
mul-1-neg74.2%
associate-*r/82.2%
*-commutative82.2%
distribute-rgt-neg-out82.2%
Simplified82.2%
if 8.5000000000000003e202 < y Initial program 100.0%
Taylor expanded in x around inf 79.5%
associate-/l*73.3%
associate-/r/79.5%
mul-1-neg79.5%
unsub-neg79.5%
Simplified79.5%
Taylor expanded in y around inf 79.5%
mul-1-neg79.5%
associate-*r/73.3%
*-commutative73.3%
distribute-rgt-neg-out73.3%
Simplified73.3%
Taylor expanded in y around 0 79.5%
associate-*l/79.5%
associate-*r*79.5%
neg-mul-179.5%
*-commutative79.5%
distribute-neg-frac79.5%
Simplified79.5%
Final simplification85.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.5e+30) (not (<= y 2.15e-13))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.5e+30) || !(y <= 2.15e-13)) {
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 <= (-5.5d+30)) .or. (.not. (y <= 2.15d-13))) 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 <= -5.5e+30) || !(y <= 2.15e-13)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.5e+30) or not (y <= 2.15e-13): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.5e+30) || !(y <= 2.15e-13)) 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 <= -5.5e+30) || ~((y <= 2.15e-13))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.5e+30], N[Not[LessEqual[y, 2.15e-13]], $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 -5.5 \cdot 10^{+30} \lor \neg \left(y \leq 2.15 \cdot 10^{-13}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -5.50000000000000025e30 or 2.1499999999999999e-13 < y Initial program 75.9%
Taylor expanded in x around -inf 87.7%
mul-1-neg87.7%
unsub-neg87.7%
associate-/l*92.3%
associate-/r/99.9%
sub-neg99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 99.4%
if -5.50000000000000025e30 < y < 2.1499999999999999e-13Initial 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 98.9%
mul-1-neg98.9%
distribute-frac-neg98.9%
Simplified98.9%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -5e-62) (not (<= y 1.25e-13))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5e-62) || !(y <= 1.25e-13)) {
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 <= (-5d-62)) .or. (.not. (y <= 1.25d-13))) 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 <= -5e-62) || !(y <= 1.25e-13)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5e-62) or not (y <= 1.25e-13): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5e-62) || !(y <= 1.25e-13)) 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 <= -5e-62) || ~((y <= 1.25e-13))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5e-62], N[Not[LessEqual[y, 1.25e-13]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{-62} \lor \neg \left(y \leq 1.25 \cdot 10^{-13}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -5.0000000000000002e-62 or 1.24999999999999997e-13 < y Initial program 79.1%
Taylor expanded in y around inf 76.2%
Taylor expanded in z around inf 40.2%
associate-/l*56.0%
associate-/r/59.1%
Applied egg-rr59.1%
if -5.0000000000000002e-62 < y < 1.24999999999999997e-13Initial program 99.9%
Taylor expanded in y around 0 76.0%
Final simplification66.6%
(FPCore (x y z) :precision binary64 (if (<= y -7e-64) y (if (<= y 6.5e-15) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7e-64) {
tmp = y;
} else if (y <= 6.5e-15) {
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 <= (-7d-64)) then
tmp = y
else if (y <= 6.5d-15) 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 <= -7e-64) {
tmp = y;
} else if (y <= 6.5e-15) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7e-64: tmp = y elif y <= 6.5e-15: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7e-64) tmp = y; elseif (y <= 6.5e-15) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7e-64) tmp = y; elseif (y <= 6.5e-15) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7e-64], y, If[LessEqual[y, 6.5e-15], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{-64}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{-15}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -7.0000000000000006e-64 or 6.49999999999999991e-15 < y Initial program 79.1%
Taylor expanded in x around 0 56.0%
if -7.0000000000000006e-64 < y < 6.49999999999999991e-15Initial program 99.9%
Taylor expanded in y around 0 76.0%
Final simplification64.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.3%
Taylor expanded in x around 0 42.8%
Final simplification42.8%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2023332
(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))