| Alternative 1 | |
|---|---|
| Error | 5.8 |
| Cost | 1097 |
(FPCore (x y) :precision binary64 (- (/ x (* y y)) 3.0))
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (* y y))))
(if (<= t_0 -5e+178)
(* (/ x y) (/ 1.0 y))
(if (<= t_0 5e+14) (+ t_0 -3.0) (/ (/ x y) y)))))double code(double x, double y) {
return (x / (y * y)) - 3.0;
}
double code(double x, double y) {
double t_0 = x / (y * y);
double tmp;
if (t_0 <= -5e+178) {
tmp = (x / y) * (1.0 / y);
} else if (t_0 <= 5e+14) {
tmp = t_0 + -3.0;
} else {
tmp = (x / y) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / (y * y)) - 3.0d0
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x / (y * y)
if (t_0 <= (-5d+178)) then
tmp = (x / y) * (1.0d0 / y)
else if (t_0 <= 5d+14) then
tmp = t_0 + (-3.0d0)
else
tmp = (x / y) / y
end if
code = tmp
end function
public static double code(double x, double y) {
return (x / (y * y)) - 3.0;
}
public static double code(double x, double y) {
double t_0 = x / (y * y);
double tmp;
if (t_0 <= -5e+178) {
tmp = (x / y) * (1.0 / y);
} else if (t_0 <= 5e+14) {
tmp = t_0 + -3.0;
} else {
tmp = (x / y) / y;
}
return tmp;
}
def code(x, y): return (x / (y * y)) - 3.0
def code(x, y): t_0 = x / (y * y) tmp = 0 if t_0 <= -5e+178: tmp = (x / y) * (1.0 / y) elif t_0 <= 5e+14: tmp = t_0 + -3.0 else: tmp = (x / y) / y return tmp
function code(x, y) return Float64(Float64(x / Float64(y * y)) - 3.0) end
function code(x, y) t_0 = Float64(x / Float64(y * y)) tmp = 0.0 if (t_0 <= -5e+178) tmp = Float64(Float64(x / y) * Float64(1.0 / y)); elseif (t_0 <= 5e+14) tmp = Float64(t_0 + -3.0); else tmp = Float64(Float64(x / y) / y); end return tmp end
function tmp = code(x, y) tmp = (x / (y * y)) - 3.0; end
function tmp_2 = code(x, y) t_0 = x / (y * y); tmp = 0.0; if (t_0 <= -5e+178) tmp = (x / y) * (1.0 / y); elseif (t_0 <= 5e+14) tmp = t_0 + -3.0; else tmp = (x / y) / y; end tmp_2 = tmp; end
code[x_, y_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] - 3.0), $MachinePrecision]
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+178], N[(N[(x / y), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+14], N[(t$95$0 + -3.0), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]]]]
\frac{x}{y \cdot y} - 3
\begin{array}{l}
t_0 := \frac{x}{y \cdot y}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+178}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{1}{y}\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+14}:\\
\;\;\;\;t_0 + -3\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{y}\\
\end{array}
Results
| Original | 4.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.2 |
if (/.f64 x (*.f64 y y)) < -4.9999999999999999e178Initial program 30.8
Taylor expanded in x around 0 30.8
Simplified31.6
[Start]30.8 | \[ \frac{x}{{y}^{2}} - 3
\] |
|---|---|
unpow2 [=>]30.8 | \[ \frac{x}{\color{blue}{y \cdot y}} - 3
\] |
*-lft-identity [<=]30.8 | \[ \frac{\color{blue}{1 \cdot x}}{y \cdot y} - 3
\] |
times-frac [=>]0.4 | \[ \color{blue}{\frac{1}{y} \cdot \frac{x}{y}} - 3
\] |
unpow-1 [<=]0.4 | \[ \color{blue}{{y}^{-1}} \cdot \frac{x}{y} - 3
\] |
metadata-eval [<=]0.4 | \[ {y}^{\color{blue}{\left(\frac{-2}{2}\right)}} \cdot \frac{x}{y} - 3
\] |
*-commutative [<=]0.4 | \[ \color{blue}{\frac{x}{y} \cdot {y}^{\left(\frac{-2}{2}\right)}} - 3
\] |
*-lft-identity [<=]0.4 | \[ \frac{\color{blue}{1 \cdot x}}{y} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
associate-*l/ [<=]0.6 | \[ \color{blue}{\left(\frac{1}{y} \cdot x\right)} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
*-commutative [=>]0.6 | \[ \color{blue}{\left(x \cdot \frac{1}{y}\right)} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
unpow-1 [<=]0.6 | \[ \left(x \cdot \color{blue}{{y}^{-1}}\right) \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
metadata-eval [<=]0.6 | \[ \left(x \cdot {y}^{\color{blue}{\left(\frac{-2}{2}\right)}}\right) \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
associate-*r* [<=]31.7 | \[ \color{blue}{x \cdot \left({y}^{\left(\frac{-2}{2}\right)} \cdot {y}^{\left(\frac{-2}{2}\right)}\right)} - 3
\] |
sqr-pow [<=]31.6 | \[ x \cdot \color{blue}{{y}^{-2}} - 3
\] |
fma-neg [=>]31.6 | \[ \color{blue}{\mathsf{fma}\left(x, {y}^{-2}, -3\right)}
\] |
metadata-eval [=>]31.6 | \[ \mathsf{fma}\left(x, {y}^{-2}, \color{blue}{-3}\right)
\] |
Taylor expanded in x around inf 30.8
Simplified30.8
[Start]30.8 | \[ \frac{x}{{y}^{2}}
\] |
|---|---|
unpow2 [=>]30.8 | \[ \frac{x}{\color{blue}{y \cdot y}}
\] |
Applied egg-rr0.4
if -4.9999999999999999e178 < (/.f64 x (*.f64 y y)) < 5e14Initial program 0.1
if 5e14 < (/.f64 x (*.f64 y y)) Initial program 15.8
Taylor expanded in x around 0 15.8
Simplified16.9
[Start]15.8 | \[ \frac{x}{{y}^{2}} - 3
\] |
|---|---|
unpow2 [=>]15.8 | \[ \frac{x}{\color{blue}{y \cdot y}} - 3
\] |
*-lft-identity [<=]15.8 | \[ \frac{\color{blue}{1 \cdot x}}{y \cdot y} - 3
\] |
times-frac [=>]0.4 | \[ \color{blue}{\frac{1}{y} \cdot \frac{x}{y}} - 3
\] |
unpow-1 [<=]0.4 | \[ \color{blue}{{y}^{-1}} \cdot \frac{x}{y} - 3
\] |
metadata-eval [<=]0.4 | \[ {y}^{\color{blue}{\left(\frac{-2}{2}\right)}} \cdot \frac{x}{y} - 3
\] |
*-commutative [<=]0.4 | \[ \color{blue}{\frac{x}{y} \cdot {y}^{\left(\frac{-2}{2}\right)}} - 3
\] |
*-lft-identity [<=]0.4 | \[ \frac{\color{blue}{1 \cdot x}}{y} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
associate-*l/ [<=]0.5 | \[ \color{blue}{\left(\frac{1}{y} \cdot x\right)} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
*-commutative [=>]0.5 | \[ \color{blue}{\left(x \cdot \frac{1}{y}\right)} \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
unpow-1 [<=]0.5 | \[ \left(x \cdot \color{blue}{{y}^{-1}}\right) \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
metadata-eval [<=]0.5 | \[ \left(x \cdot {y}^{\color{blue}{\left(\frac{-2}{2}\right)}}\right) \cdot {y}^{\left(\frac{-2}{2}\right)} - 3
\] |
associate-*r* [<=]17.1 | \[ \color{blue}{x \cdot \left({y}^{\left(\frac{-2}{2}\right)} \cdot {y}^{\left(\frac{-2}{2}\right)}\right)} - 3
\] |
sqr-pow [<=]16.9 | \[ x \cdot \color{blue}{{y}^{-2}} - 3
\] |
fma-neg [=>]16.9 | \[ \color{blue}{\mathsf{fma}\left(x, {y}^{-2}, -3\right)}
\] |
metadata-eval [=>]16.9 | \[ \mathsf{fma}\left(x, {y}^{-2}, \color{blue}{-3}\right)
\] |
Taylor expanded in x around inf 15.8
Simplified0.3
[Start]15.8 | \[ \frac{x}{{y}^{2}}
\] |
|---|---|
unpow2 [=>]15.8 | \[ \frac{x}{\color{blue}{y \cdot y}}
\] |
associate-/r* [=>]0.3 | \[ \color{blue}{\frac{\frac{x}{y}}{y}}
\] |
Final simplification0.2
| Alternative 1 | |
|---|---|
| Error | 5.8 |
| Cost | 1097 |
| Alternative 2 | |
|---|---|
| Error | 1.3 |
| Cost | 1097 |
| Alternative 3 | |
|---|---|
| Error | 0.1 |
| Cost | 448 |
| Alternative 4 | |
|---|---|
| Error | 20.9 |
| Cost | 64 |
herbie shell --seed 2023018
(FPCore (x y)
:name "Statistics.Sample:$skurtosis from math-functions-0.1.5.2"
:precision binary64
:herbie-target
(- (/ (/ x y) y) 3.0)
(- (/ x (* y y)) 3.0))