
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y): return (1.0 - x) + (y * math.sqrt(x))
function code(x, y) return Float64(Float64(1.0 - x) + Float64(y * sqrt(x))) end
function tmp = code(x, y) tmp = (1.0 - x) + (y * sqrt(x)); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) + y \cdot \sqrt{x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y): return (1.0 - x) + (y * math.sqrt(x))
function code(x, y) return Float64(Float64(1.0 - x) + Float64(y * sqrt(x))) end
function tmp = code(x, y) tmp = (1.0 - x) + (y * sqrt(x)); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) + y \cdot \sqrt{x}
\end{array}
(FPCore (x y) :precision binary64 (+ (- 1.0 x) (* y (sqrt x))))
double code(double x, double y) {
return (1.0 - x) + (y * sqrt(x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (1.0d0 - x) + (y * sqrt(x))
end function
public static double code(double x, double y) {
return (1.0 - x) + (y * Math.sqrt(x));
}
def code(x, y): return (1.0 - x) + (y * math.sqrt(x))
function code(x, y) return Float64(Float64(1.0 - x) + Float64(y * sqrt(x))) end
function tmp = code(x, y) tmp = (1.0 - x) + (y * sqrt(x)); end
code[x_, y_] := N[(N[(1.0 - x), $MachinePrecision] + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(1 - x\right) + y \cdot \sqrt{x}
\end{array}
Initial program 99.9%
(FPCore (x y) :precision binary64 (if (or (<= y -1.26e+82) (not (<= y 1.06e+55))) (+ 1.0 (* y (sqrt x))) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -1.26e+82) || !(y <= 1.06e+55)) {
tmp = 1.0 + (y * sqrt(x));
} else {
tmp = 1.0 - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-1.26d+82)) .or. (.not. (y <= 1.06d+55))) then
tmp = 1.0d0 + (y * sqrt(x))
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -1.26e+82) || !(y <= 1.06e+55)) {
tmp = 1.0 + (y * Math.sqrt(x));
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -1.26e+82) or not (y <= 1.06e+55): tmp = 1.0 + (y * math.sqrt(x)) else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -1.26e+82) || !(y <= 1.06e+55)) tmp = Float64(1.0 + Float64(y * sqrt(x))); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -1.26e+82) || ~((y <= 1.06e+55))) tmp = 1.0 + (y * sqrt(x)); else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -1.26e+82], N[Not[LessEqual[y, 1.06e+55]], $MachinePrecision]], N[(1.0 + N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.26 \cdot 10^{+82} \lor \neg \left(y \leq 1.06 \cdot 10^{+55}\right):\\
\;\;\;\;1 + y \cdot \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -1.2600000000000001e82 or 1.06000000000000004e55 < y Initial program 99.8%
Taylor expanded in x around 0 95.1%
if -1.2600000000000001e82 < y < 1.06000000000000004e55Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
add-sqr-sqrt100.0%
associate-*l*100.0%
fma-define100.0%
pow1/2100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow1/2100.0%
sqrt-pow1100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 96.9%
Final simplification96.1%
(FPCore (x y) :precision binary64 (if (or (<= y -4.2e+85) (not (<= y 3.7e+63))) (* y (sqrt x)) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if ((y <= -4.2e+85) || !(y <= 3.7e+63)) {
tmp = y * sqrt(x);
} else {
tmp = 1.0 - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-4.2d+85)) .or. (.not. (y <= 3.7d+63))) then
tmp = y * sqrt(x)
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -4.2e+85) || !(y <= 3.7e+63)) {
tmp = y * Math.sqrt(x);
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -4.2e+85) or not (y <= 3.7e+63): tmp = y * math.sqrt(x) else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if ((y <= -4.2e+85) || !(y <= 3.7e+63)) tmp = Float64(y * sqrt(x)); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -4.2e+85) || ~((y <= 3.7e+63))) tmp = y * sqrt(x); else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -4.2e+85], N[Not[LessEqual[y, 3.7e+63]], $MachinePrecision]], N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+85} \lor \neg \left(y \leq 3.7 \cdot 10^{+63}\right):\\
\;\;\;\;y \cdot \sqrt{x}\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -4.2000000000000002e85 or 3.69999999999999968e63 < y Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt99.6%
associate-*l*99.5%
fma-define99.5%
pow1/299.5%
sqrt-pow199.6%
metadata-eval99.6%
pow1/299.6%
sqrt-pow199.5%
metadata-eval99.5%
Applied egg-rr99.5%
Taylor expanded in y around inf 89.2%
if -4.2000000000000002e85 < y < 3.69999999999999968e63Initial program 100.0%
+-commutative100.0%
*-commutative100.0%
add-sqr-sqrt100.0%
associate-*l*100.0%
fma-define100.0%
pow1/2100.0%
sqrt-pow1100.0%
metadata-eval100.0%
pow1/2100.0%
sqrt-pow1100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 96.9%
Final simplification93.7%
(FPCore (x y) :precision binary64 (let* ((t_0 (* y (sqrt x)))) (if (<= x 1.0) (+ 1.0 t_0) (- t_0 x))))
double code(double x, double y) {
double t_0 = y * sqrt(x);
double tmp;
if (x <= 1.0) {
tmp = 1.0 + t_0;
} else {
tmp = t_0 - x;
}
return tmp;
}
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 = y * sqrt(x)
if (x <= 1.0d0) then
tmp = 1.0d0 + t_0
else
tmp = t_0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = y * Math.sqrt(x);
double tmp;
if (x <= 1.0) {
tmp = 1.0 + t_0;
} else {
tmp = t_0 - x;
}
return tmp;
}
def code(x, y): t_0 = y * math.sqrt(x) tmp = 0 if x <= 1.0: tmp = 1.0 + t_0 else: tmp = t_0 - x return tmp
function code(x, y) t_0 = Float64(y * sqrt(x)) tmp = 0.0 if (x <= 1.0) tmp = Float64(1.0 + t_0); else tmp = Float64(t_0 - x); end return tmp end
function tmp_2 = code(x, y) t_0 = y * sqrt(x); tmp = 0.0; if (x <= 1.0) tmp = 1.0 + t_0; else tmp = t_0 - x; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(y * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 1.0], N[(1.0 + t$95$0), $MachinePrecision], N[(t$95$0 - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \sqrt{x}\\
\mathbf{if}\;x \leq 1:\\
\;\;\;\;1 + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 - x\\
\end{array}
\end{array}
if x < 1Initial program 99.8%
Taylor expanded in x around 0 98.3%
if 1 < x Initial program 99.9%
Taylor expanded in x around inf 99.4%
neg-mul-199.4%
Simplified99.4%
Taylor expanded in y around 0 99.4%
Final simplification98.9%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (* x x))))
(if (<= y -1.35e+154)
(/ t_0 (+ 1.0 x))
(if (<= y 1.02e+127) (- 1.0 x) (/ t_0 (- 1.0 x))))))
double code(double x, double y) {
double t_0 = 1.0 - (x * x);
double tmp;
if (y <= -1.35e+154) {
tmp = t_0 / (1.0 + x);
} else if (y <= 1.02e+127) {
tmp = 1.0 - x;
} else {
tmp = t_0 / (1.0 - x);
}
return tmp;
}
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 = 1.0d0 - (x * x)
if (y <= (-1.35d+154)) then
tmp = t_0 / (1.0d0 + x)
else if (y <= 1.02d+127) then
tmp = 1.0d0 - x
else
tmp = t_0 / (1.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x * x);
double tmp;
if (y <= -1.35e+154) {
tmp = t_0 / (1.0 + x);
} else if (y <= 1.02e+127) {
tmp = 1.0 - x;
} else {
tmp = t_0 / (1.0 - x);
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x * x) tmp = 0 if y <= -1.35e+154: tmp = t_0 / (1.0 + x) elif y <= 1.02e+127: tmp = 1.0 - x else: tmp = t_0 / (1.0 - x) return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x * x)) tmp = 0.0 if (y <= -1.35e+154) tmp = Float64(t_0 / Float64(1.0 + x)); elseif (y <= 1.02e+127) tmp = Float64(1.0 - x); else tmp = Float64(t_0 / Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x * x); tmp = 0.0; if (y <= -1.35e+154) tmp = t_0 / (1.0 + x); elseif (y <= 1.02e+127) tmp = 1.0 - x; else tmp = t_0 / (1.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.35e+154], N[(t$95$0 / N[(1.0 + x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.02e+127], N[(1.0 - x), $MachinePrecision], N[(t$95$0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - x \cdot x\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+154}:\\
\;\;\;\;\frac{t\_0}{1 + x}\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{+127}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{1 - x}\\
\end{array}
\end{array}
if y < -1.35000000000000003e154Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt99.5%
associate-*l*99.5%
fma-define99.5%
pow1/299.5%
sqrt-pow199.5%
metadata-eval99.5%
pow1/299.5%
sqrt-pow199.5%
metadata-eval99.5%
Applied egg-rr99.5%
Taylor expanded in y around 0 3.6%
sub-neg3.6%
flip-+18.9%
metadata-eval18.9%
Applied egg-rr18.9%
if -1.35000000000000003e154 < y < 1.02e127Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
add-sqr-sqrt99.9%
associate-*l*99.9%
fma-define99.9%
pow1/299.9%
sqrt-pow199.9%
metadata-eval99.9%
pow1/299.9%
sqrt-pow199.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 85.6%
if 1.02e127 < y Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt99.8%
associate-*l*99.5%
fma-define99.5%
pow1/299.5%
sqrt-pow199.6%
metadata-eval99.6%
pow1/299.6%
sqrt-pow199.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 4.7%
sub-neg4.7%
flip-+4.6%
metadata-eval4.6%
Applied egg-rr4.6%
neg-sub04.6%
sub-neg4.6%
add-sqr-sqrt0.0%
sqrt-unprod5.0%
sqr-neg5.0%
sqrt-unprod28.9%
add-sqr-sqrt28.9%
Applied egg-rr28.9%
+-lft-identity28.9%
Simplified28.9%
Final simplification67.5%
(FPCore (x y)
:precision binary64
(let* ((t_0 (- 1.0 (* x x))))
(if (<= y -2e+181)
(/ t_0 x)
(if (<= y 1e+127) (- 1.0 x) (/ t_0 (- 1.0 x))))))
double code(double x, double y) {
double t_0 = 1.0 - (x * x);
double tmp;
if (y <= -2e+181) {
tmp = t_0 / x;
} else if (y <= 1e+127) {
tmp = 1.0 - x;
} else {
tmp = t_0 / (1.0 - x);
}
return tmp;
}
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 = 1.0d0 - (x * x)
if (y <= (-2d+181)) then
tmp = t_0 / x
else if (y <= 1d+127) then
tmp = 1.0d0 - x
else
tmp = t_0 / (1.0d0 - x)
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = 1.0 - (x * x);
double tmp;
if (y <= -2e+181) {
tmp = t_0 / x;
} else if (y <= 1e+127) {
tmp = 1.0 - x;
} else {
tmp = t_0 / (1.0 - x);
}
return tmp;
}
def code(x, y): t_0 = 1.0 - (x * x) tmp = 0 if y <= -2e+181: tmp = t_0 / x elif y <= 1e+127: tmp = 1.0 - x else: tmp = t_0 / (1.0 - x) return tmp
function code(x, y) t_0 = Float64(1.0 - Float64(x * x)) tmp = 0.0 if (y <= -2e+181) tmp = Float64(t_0 / x); elseif (y <= 1e+127) tmp = Float64(1.0 - x); else tmp = Float64(t_0 / Float64(1.0 - x)); end return tmp end
function tmp_2 = code(x, y) t_0 = 1.0 - (x * x); tmp = 0.0; if (y <= -2e+181) tmp = t_0 / x; elseif (y <= 1e+127) tmp = 1.0 - x; else tmp = t_0 / (1.0 - x); end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2e+181], N[(t$95$0 / x), $MachinePrecision], If[LessEqual[y, 1e+127], N[(1.0 - x), $MachinePrecision], N[(t$95$0 / N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - x \cdot x\\
\mathbf{if}\;y \leq -2 \cdot 10^{+181}:\\
\;\;\;\;\frac{t\_0}{x}\\
\mathbf{elif}\;y \leq 10^{+127}:\\
\;\;\;\;1 - x\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{1 - x}\\
\end{array}
\end{array}
if y < -1.9999999999999998e181Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt99.5%
associate-*l*99.6%
fma-define99.6%
pow1/299.6%
sqrt-pow199.6%
metadata-eval99.6%
pow1/299.6%
sqrt-pow199.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 3.5%
sub-neg3.5%
flip-+22.6%
metadata-eval22.6%
Applied egg-rr22.6%
Taylor expanded in x around inf 22.4%
if -1.9999999999999998e181 < y < 9.99999999999999955e126Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
add-sqr-sqrt99.9%
associate-*l*99.9%
fma-define99.9%
pow1/299.9%
sqrt-pow199.9%
metadata-eval99.9%
pow1/299.9%
sqrt-pow199.9%
metadata-eval99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 81.7%
if 9.99999999999999955e126 < y Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt99.8%
associate-*l*99.5%
fma-define99.5%
pow1/299.5%
sqrt-pow199.6%
metadata-eval99.6%
pow1/299.6%
sqrt-pow199.4%
metadata-eval99.4%
Applied egg-rr99.4%
Taylor expanded in y around 0 4.7%
sub-neg4.7%
flip-+4.6%
metadata-eval4.6%
Applied egg-rr4.6%
neg-sub04.6%
sub-neg4.6%
add-sqr-sqrt0.0%
sqrt-unprod5.0%
sqr-neg5.0%
sqrt-unprod28.9%
add-sqr-sqrt28.9%
Applied egg-rr28.9%
+-lft-identity28.9%
Simplified28.9%
Final simplification67.4%
(FPCore (x y) :precision binary64 (if (<= y -1.5e+181) (/ (- 1.0 (* x x)) x) (- 1.0 x)))
double code(double x, double y) {
double tmp;
if (y <= -1.5e+181) {
tmp = (1.0 - (x * x)) / x;
} else {
tmp = 1.0 - x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-1.5d+181)) then
tmp = (1.0d0 - (x * x)) / x
else
tmp = 1.0d0 - x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -1.5e+181) {
tmp = (1.0 - (x * x)) / x;
} else {
tmp = 1.0 - x;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.5e+181: tmp = (1.0 - (x * x)) / x else: tmp = 1.0 - x return tmp
function code(x, y) tmp = 0.0 if (y <= -1.5e+181) tmp = Float64(Float64(1.0 - Float64(x * x)) / x); else tmp = Float64(1.0 - x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -1.5e+181) tmp = (1.0 - (x * x)) / x; else tmp = 1.0 - x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.5e+181], N[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+181}:\\
\;\;\;\;\frac{1 - x \cdot x}{x}\\
\mathbf{else}:\\
\;\;\;\;1 - x\\
\end{array}
\end{array}
if y < -1.50000000000000006e181Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
add-sqr-sqrt99.5%
associate-*l*99.6%
fma-define99.6%
pow1/299.6%
sqrt-pow199.6%
metadata-eval99.6%
pow1/299.6%
sqrt-pow199.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 3.5%
sub-neg3.5%
flip-+22.6%
metadata-eval22.6%
Applied egg-rr22.6%
Taylor expanded in x around inf 22.4%
if -1.50000000000000006e181 < y Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
add-sqr-sqrt99.9%
associate-*l*99.8%
fma-define99.8%
pow1/299.8%
sqrt-pow199.9%
metadata-eval99.9%
pow1/299.9%
sqrt-pow199.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 71.3%
Final simplification64.6%
(FPCore (x y) :precision binary64 (if (<= x 1.0) 1.0 (- x)))
double code(double x, double y) {
double tmp;
if (x <= 1.0) {
tmp = 1.0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= 1.0d0) then
tmp = 1.0d0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= 1.0) {
tmp = 1.0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= 1.0: tmp = 1.0 else: tmp = -x return tmp
function code(x, y) tmp = 0.0 if (x <= 1.0) tmp = 1.0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= 1.0) tmp = 1.0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, 1.0], 1.0, (-x)]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if x < 1Initial program 99.8%
Taylor expanded in x around 0 98.3%
Taylor expanded in y around 0 57.9%
if 1 < x Initial program 99.9%
Taylor expanded in x around inf 99.4%
neg-mul-199.4%
Simplified99.4%
Taylor expanded in y around 0 99.4%
Taylor expanded in y around 0 64.2%
neg-mul-164.2%
Simplified64.2%
(FPCore (x y) :precision binary64 (- 1.0 x))
double code(double x, double y) {
return 1.0 - x;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 - x
end function
public static double code(double x, double y) {
return 1.0 - x;
}
def code(x, y): return 1.0 - x
function code(x, y) return Float64(1.0 - x) end
function tmp = code(x, y) tmp = 1.0 - x; end
code[x_, y_] := N[(1.0 - x), $MachinePrecision]
\begin{array}{l}
\\
1 - x
\end{array}
Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
add-sqr-sqrt99.8%
associate-*l*99.8%
fma-define99.8%
pow1/299.8%
sqrt-pow199.8%
metadata-eval99.8%
pow1/299.8%
sqrt-pow199.8%
metadata-eval99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 62.0%
(FPCore (x y) :precision binary64 1.0)
double code(double x, double y) {
return 1.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0
end function
public static double code(double x, double y) {
return 1.0;
}
def code(x, y): return 1.0
function code(x, y) return 1.0 end
function tmp = code(x, y) tmp = 1.0; end
code[x_, y_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in x around 0 67.1%
Taylor expanded in y around 0 29.0%
herbie shell --seed 2024165
(FPCore (x y)
:name "Numeric.SpecFunctions:invIncompleteBetaWorker from math-functions-0.1.5.2, E"
:precision binary64
(+ (- 1.0 x) (* y (sqrt x))))