
(FPCore (x) :precision binary64 :pre TRUE (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
double code(double x) {
return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
public static double code(double x) {
return 1.0 - Math.sqrt((0.5 * (1.0 + (1.0 / Math.hypot(1.0, x)))));
}
def code(x): return 1.0 - math.sqrt((0.5 * (1.0 + (1.0 / math.hypot(1.0, x)))))
function code(x) return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x)))))) end
function tmp = code(x) tmp = 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x))))); end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) - (sqrt(((5e-1) * ((1) + ((1) / (sqrt((((1) ^ (2)) + (x ^ (2)))))))))) END code
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 :pre TRUE (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
double code(double x) {
return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
public static double code(double x) {
return 1.0 - Math.sqrt((0.5 * (1.0 + (1.0 / Math.hypot(1.0, x)))));
}
def code(x): return 1.0 - math.sqrt((0.5 * (1.0 + (1.0 / math.hypot(1.0, x)))))
function code(x) return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x)))))) end
function tmp = code(x) tmp = 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x))))); end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = (1) - (sqrt(((5e-1) * ((1) + ((1) / (sqrt((((1) ^ (2)) + (x ^ (2)))))))))) END code
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
(FPCore (x)
:precision binary64
:pre TRUE
(let* ((t_0 (/ 0.5 (sqrt (fma (fabs x) (fabs x) 1.0))))
(t_1 (pow (fabs x) 2.0)))
(if (<= (fabs x) 0.0018)
(* t_1 (+ 0.125 (* -0.0859375 t_1)))
(* (/ -1.0 (- (sqrt (- t_0 -0.5)) -1.0)) (- t_0 0.5)))))double code(double x) {
double t_0 = 0.5 / sqrt(fma(fabs(x), fabs(x), 1.0));
double t_1 = pow(fabs(x), 2.0);
double tmp;
if (fabs(x) <= 0.0018) {
tmp = t_1 * (0.125 + (-0.0859375 * t_1));
} else {
tmp = (-1.0 / (sqrt((t_0 - -0.5)) - -1.0)) * (t_0 - 0.5);
}
return tmp;
}
function code(x) t_0 = Float64(0.5 / sqrt(fma(abs(x), abs(x), 1.0))) t_1 = abs(x) ^ 2.0 tmp = 0.0 if (abs(x) <= 0.0018) tmp = Float64(t_1 * Float64(0.125 + Float64(-0.0859375 * t_1))); else tmp = Float64(Float64(-1.0 / Float64(sqrt(Float64(t_0 - -0.5)) - -1.0)) * Float64(t_0 - 0.5)); end return tmp end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Abs[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 0.0018], N[(t$95$1 * N[(0.125 + N[(-0.0859375 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-1.0 / N[(N[Sqrt[N[(t$95$0 - -0.5), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET t_0 = ((5e-1) / (sqrt((((abs(x)) * (abs(x))) + (1))))) IN LET t_1 = ((abs(x)) ^ (2)) IN LET tmp = IF ((abs(x)) <= (17999999999999999507338532822586785187013447284698486328125e-61)) THEN (t_1 * ((125e-3) + ((-859375e-7) * t_1))) ELSE (((-1) / ((sqrt((t_0 - (-5e-1)))) - (-1))) * (t_0 - (5e-1))) ENDIF IN tmp END code
\begin{array}{l}
t_0 := \frac{0.5}{\sqrt{\mathsf{fma}\left(\left|x\right|, \left|x\right|, 1\right)}}\\
t_1 := {\left(\left|x\right|\right)}^{2}\\
\mathbf{if}\;\left|x\right| \leq 0.0018:\\
\;\;\;\;t\_1 \cdot \left(0.125 + -0.0859375 \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sqrt{t\_0 - -0.5} - -1} \cdot \left(t\_0 - 0.5\right)\\
\end{array}
if x < 0.0018Initial program 75.4%
Taylor expanded in x around 0
Applied rewrites49.9%
if 0.0018 < x Initial program 75.4%
Applied rewrites76.2%
Applied rewrites76.2%
(FPCore (x)
:precision binary64
:pre TRUE
(let* ((t_0 (/ 0.5 (sqrt (fma (fabs x) (fabs x) 1.0)))))
(if (<= (fabs x) 1.2)
(* (* (fabs x) (fabs x)) 0.125)
(* (/ -1.0 (- (sqrt (- t_0 -0.5)) -1.0)) (- t_0 0.5)))))double code(double x) {
double t_0 = 0.5 / sqrt(fma(fabs(x), fabs(x), 1.0));
double tmp;
if (fabs(x) <= 1.2) {
tmp = (fabs(x) * fabs(x)) * 0.125;
} else {
tmp = (-1.0 / (sqrt((t_0 - -0.5)) - -1.0)) * (t_0 - 0.5);
}
return tmp;
}
function code(x) t_0 = Float64(0.5 / sqrt(fma(abs(x), abs(x), 1.0))) tmp = 0.0 if (abs(x) <= 1.2) tmp = Float64(Float64(abs(x) * abs(x)) * 0.125); else tmp = Float64(Float64(-1.0 / Float64(sqrt(Float64(t_0 - -0.5)) - -1.0)) * Float64(t_0 - 0.5)); end return tmp end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 1.2], N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision], N[(N[(-1.0 / N[(N[Sqrt[N[(t$95$0 - -0.5), $MachinePrecision]], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision] * N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET t_0 = ((5e-1) / (sqrt((((abs(x)) * (abs(x))) + (1))))) IN LET tmp = IF ((abs(x)) <= (11999999999999999555910790149937383830547332763671875e-52)) THEN (((abs(x)) * (abs(x))) * (125e-3)) ELSE (((-1) / ((sqrt((t_0 - (-5e-1)))) - (-1))) * (t_0 - (5e-1))) ENDIF IN tmp END code
\begin{array}{l}
t_0 := \frac{0.5}{\sqrt{\mathsf{fma}\left(\left|x\right|, \left|x\right|, 1\right)}}\\
\mathbf{if}\;\left|x\right| \leq 1.2:\\
\;\;\;\;\left(\left|x\right| \cdot \left|x\right|\right) \cdot 0.125\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\sqrt{t\_0 - -0.5} - -1} \cdot \left(t\_0 - 0.5\right)\\
\end{array}
if x < 1.2Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
if 1.2 < x Initial program 75.4%
Applied rewrites76.2%
Applied rewrites76.2%
(FPCore (x)
:precision binary64
:pre TRUE
(let* ((t_0 (- (/ 0.5 (sqrt (fma (fabs x) (fabs x) 1.0))) -0.5)))
(if (<= (fabs x) 1.2)
(* (* (fabs x) (fabs x)) 0.125)
(/ (- 1.0 t_0) (+ 1.0 (sqrt t_0))))))double code(double x) {
double t_0 = (0.5 / sqrt(fma(fabs(x), fabs(x), 1.0))) - -0.5;
double tmp;
if (fabs(x) <= 1.2) {
tmp = (fabs(x) * fabs(x)) * 0.125;
} else {
tmp = (1.0 - t_0) / (1.0 + sqrt(t_0));
}
return tmp;
}
function code(x) t_0 = Float64(Float64(0.5 / sqrt(fma(abs(x), abs(x), 1.0))) - -0.5) tmp = 0.0 if (abs(x) <= 1.2) tmp = Float64(Float64(abs(x) * abs(x)) * 0.125); else tmp = Float64(Float64(1.0 - t_0) / Float64(1.0 + sqrt(t_0))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[(0.5 / N[Sqrt[N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -0.5), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 1.2], N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET t_0 = (((5e-1) / (sqrt((((abs(x)) * (abs(x))) + (1))))) - (-5e-1)) IN LET tmp = IF ((abs(x)) <= (11999999999999999555910790149937383830547332763671875e-52)) THEN (((abs(x)) * (abs(x))) * (125e-3)) ELSE (((1) - t_0) / ((1) + (sqrt(t_0)))) ENDIF IN tmp END code
\begin{array}{l}
t_0 := \frac{0.5}{\sqrt{\mathsf{fma}\left(\left|x\right|, \left|x\right|, 1\right)}} - -0.5\\
\mathbf{if}\;\left|x\right| \leq 1.2:\\
\;\;\;\;\left(\left|x\right| \cdot \left|x\right|\right) \cdot 0.125\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_0}{1 + \sqrt{t\_0}}\\
\end{array}
if x < 1.2Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
if 1.2 < x Initial program 75.4%
Applied rewrites76.2%
(FPCore (x)
:precision binary64
:pre TRUE
(let* ((t_0 (- (/ 0.5 (fabs x)) -0.5)))
(if (<= (fabs x) 2.2)
(* (* (fabs x) (fabs x)) 0.125)
(/ (- 1.0 t_0) (+ 1.0 (sqrt t_0))))))double code(double x) {
double t_0 = (0.5 / fabs(x)) - -0.5;
double tmp;
if (fabs(x) <= 2.2) {
tmp = (fabs(x) * fabs(x)) * 0.125;
} else {
tmp = (1.0 - t_0) / (1.0 + sqrt(t_0));
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (0.5d0 / abs(x)) - (-0.5d0)
if (abs(x) <= 2.2d0) then
tmp = (abs(x) * abs(x)) * 0.125d0
else
tmp = (1.0d0 - t_0) / (1.0d0 + sqrt(t_0))
end if
code = tmp
end function
public static double code(double x) {
double t_0 = (0.5 / Math.abs(x)) - -0.5;
double tmp;
if (Math.abs(x) <= 2.2) {
tmp = (Math.abs(x) * Math.abs(x)) * 0.125;
} else {
tmp = (1.0 - t_0) / (1.0 + Math.sqrt(t_0));
}
return tmp;
}
def code(x): t_0 = (0.5 / math.fabs(x)) - -0.5 tmp = 0 if math.fabs(x) <= 2.2: tmp = (math.fabs(x) * math.fabs(x)) * 0.125 else: tmp = (1.0 - t_0) / (1.0 + math.sqrt(t_0)) return tmp
function code(x) t_0 = Float64(Float64(0.5 / abs(x)) - -0.5) tmp = 0.0 if (abs(x) <= 2.2) tmp = Float64(Float64(abs(x) * abs(x)) * 0.125); else tmp = Float64(Float64(1.0 - t_0) / Float64(1.0 + sqrt(t_0))); end return tmp end
function tmp_2 = code(x) t_0 = (0.5 / abs(x)) - -0.5; tmp = 0.0; if (abs(x) <= 2.2) tmp = (abs(x) * abs(x)) * 0.125; else tmp = (1.0 - t_0) / (1.0 + sqrt(t_0)); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[(0.5 / N[Abs[x], $MachinePrecision]), $MachinePrecision] - -0.5), $MachinePrecision]}, If[LessEqual[N[Abs[x], $MachinePrecision], 2.2], N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision], N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET t_0 = (((5e-1) / (abs(x))) - (-5e-1)) IN LET tmp = IF ((abs(x)) <= (220000000000000017763568394002504646778106689453125e-50)) THEN (((abs(x)) * (abs(x))) * (125e-3)) ELSE (((1) - t_0) / ((1) + (sqrt(t_0)))) ENDIF IN tmp END code
\begin{array}{l}
t_0 := \frac{0.5}{\left|x\right|} - -0.5\\
\mathbf{if}\;\left|x\right| \leq 2.2:\\
\;\;\;\;\left(\left|x\right| \cdot \left|x\right|\right) \cdot 0.125\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - t\_0}{1 + \sqrt{t\_0}}\\
\end{array}
if x < 2.2000000000000002Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
if 2.2000000000000002 < x Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around inf
Applied rewrites50.0%
(FPCore (x) :precision binary64 :pre TRUE (if (<= (fabs x) 1.2) (* (* (fabs x) (fabs x)) 0.125) (- 1.0 (sqrt (- (/ 0.5 (sqrt (fma (fabs x) (fabs x) 1.0))) -0.5)))))
double code(double x) {
double tmp;
if (fabs(x) <= 1.2) {
tmp = (fabs(x) * fabs(x)) * 0.125;
} else {
tmp = 1.0 - sqrt(((0.5 / sqrt(fma(fabs(x), fabs(x), 1.0))) - -0.5));
}
return tmp;
}
function code(x) tmp = 0.0 if (abs(x) <= 1.2) tmp = Float64(Float64(abs(x) * abs(x)) * 0.125); else tmp = Float64(1.0 - sqrt(Float64(Float64(0.5 / sqrt(fma(abs(x), abs(x), 1.0))) - -0.5))); end return tmp end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1.2], N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision], N[(1.0 - N[Sqrt[N[(N[(0.5 / N[Sqrt[N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET tmp = IF ((abs(x)) <= (11999999999999999555910790149937383830547332763671875e-52)) THEN (((abs(x)) * (abs(x))) * (125e-3)) ELSE ((1) - (sqrt((((5e-1) / (sqrt((((abs(x)) * (abs(x))) + (1))))) - (-5e-1))))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1.2:\\
\;\;\;\;\left(\left|x\right| \cdot \left|x\right|\right) \cdot 0.125\\
\mathbf{else}:\\
\;\;\;\;1 - \sqrt{\frac{0.5}{\sqrt{\mathsf{fma}\left(\left|x\right|, \left|x\right|, 1\right)}} - -0.5}\\
\end{array}
if x < 1.2Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
if 1.2 < x Initial program 75.4%
Applied rewrites75.5%
(FPCore (x) :precision binary64 :pre TRUE (if (<= (fabs x) 1.25) (* (* (fabs x) (fabs x)) 0.125) (/ 0.5 (+ 1.0 (sqrt 0.5)))))
double code(double x) {
double tmp;
if (fabs(x) <= 1.25) {
tmp = (fabs(x) * fabs(x)) * 0.125;
} else {
tmp = 0.5 / (1.0 + sqrt(0.5));
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (abs(x) <= 1.25d0) then
tmp = (abs(x) * abs(x)) * 0.125d0
else
tmp = 0.5d0 / (1.0d0 + sqrt(0.5d0))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 1.25) {
tmp = (Math.abs(x) * Math.abs(x)) * 0.125;
} else {
tmp = 0.5 / (1.0 + Math.sqrt(0.5));
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 1.25: tmp = (math.fabs(x) * math.fabs(x)) * 0.125 else: tmp = 0.5 / (1.0 + math.sqrt(0.5)) return tmp
function code(x) tmp = 0.0 if (abs(x) <= 1.25) tmp = Float64(Float64(abs(x) * abs(x)) * 0.125); else tmp = Float64(0.5 / Float64(1.0 + sqrt(0.5))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 1.25) tmp = (abs(x) * abs(x)) * 0.125; else tmp = 0.5 / (1.0 + sqrt(0.5)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1.25], N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision], N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET tmp = IF ((abs(x)) <= (125e-2)) THEN (((abs(x)) * (abs(x))) * (125e-3)) ELSE ((5e-1) / ((1) + (sqrt((5e-1))))) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1.25:\\
\;\;\;\;\left(\left|x\right| \cdot \left|x\right|\right) \cdot 0.125\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\end{array}
if x < 1.25Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
if 1.25 < x Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around inf
Applied rewrites51.3%
(FPCore (x) :precision binary64 :pre TRUE (if (<= (fabs x) 1.25) (* (* (fabs x) (fabs x)) 0.125) 0.2928932188134524))
double code(double x) {
double tmp;
if (fabs(x) <= 1.25) {
tmp = (fabs(x) * fabs(x)) * 0.125;
} else {
tmp = 0.2928932188134524;
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (abs(x) <= 1.25d0) then
tmp = (abs(x) * abs(x)) * 0.125d0
else
tmp = 0.2928932188134524d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 1.25) {
tmp = (Math.abs(x) * Math.abs(x)) * 0.125;
} else {
tmp = 0.2928932188134524;
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 1.25: tmp = (math.fabs(x) * math.fabs(x)) * 0.125 else: tmp = 0.2928932188134524 return tmp
function code(x) tmp = 0.0 if (abs(x) <= 1.25) tmp = Float64(Float64(abs(x) * abs(x)) * 0.125); else tmp = 0.2928932188134524; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 1.25) tmp = (abs(x) * abs(x)) * 0.125; else tmp = 0.2928932188134524; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 1.25], N[(N[(N[Abs[x], $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision], 0.2928932188134524]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET tmp = IF ((abs(x)) <= (125e-2)) THEN (((abs(x)) * (abs(x))) * (125e-3)) ELSE (29289321881345242726268907063058577477931976318359375e-53) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1.25:\\
\;\;\;\;\left(\left|x\right| \cdot \left|x\right|\right) \cdot 0.125\\
\mathbf{else}:\\
\;\;\;\;0.2928932188134524\\
\end{array}
if x < 1.25Initial program 75.4%
Applied rewrites76.2%
Taylor expanded in x around 0
Applied rewrites51.4%
Applied rewrites51.4%
if 1.25 < x Initial program 75.4%
Applied rewrites51.5%
Evaluated real constant51.5%
Taylor expanded in x around inf
Applied rewrites50.5%
(FPCore (x) :precision binary64 :pre TRUE (if (<= (fabs x) 5.5e-79) (- 1.0 (sqrt 1.0)) 0.2928932188134524))
double code(double x) {
double tmp;
if (fabs(x) <= 5.5e-79) {
tmp = 1.0 - sqrt(1.0);
} else {
tmp = 0.2928932188134524;
}
return tmp;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (abs(x) <= 5.5d-79) then
tmp = 1.0d0 - sqrt(1.0d0)
else
tmp = 0.2928932188134524d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (Math.abs(x) <= 5.5e-79) {
tmp = 1.0 - Math.sqrt(1.0);
} else {
tmp = 0.2928932188134524;
}
return tmp;
}
def code(x): tmp = 0 if math.fabs(x) <= 5.5e-79: tmp = 1.0 - math.sqrt(1.0) else: tmp = 0.2928932188134524 return tmp
function code(x) tmp = 0.0 if (abs(x) <= 5.5e-79) tmp = Float64(1.0 - sqrt(1.0)); else tmp = 0.2928932188134524; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (abs(x) <= 5.5e-79) tmp = 1.0 - sqrt(1.0); else tmp = 0.2928932188134524; end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[Abs[x], $MachinePrecision], 5.5e-79], N[(1.0 - N[Sqrt[1.0], $MachinePrecision]), $MachinePrecision], 0.2928932188134524]
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = LET tmp = IF ((abs(x)) <= (54999999999999996942057192297876001245053568316894463337206637269566867377234666277132519617507187437460990248639054916944318873802304893281316808212413385913220564905970669705645035915602216770869947737310212687589228153228759765625e-311)) THEN ((1) - (sqrt((1)))) ELSE (29289321881345242726268907063058577477931976318359375e-53) ENDIF IN tmp END code
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5.5 \cdot 10^{-79}:\\
\;\;\;\;1 - \sqrt{1}\\
\mathbf{else}:\\
\;\;\;\;0.2928932188134524\\
\end{array}
if x < 5.4999999999999997e-79Initial program 75.4%
Taylor expanded in x around inf
Applied rewrites50.5%
Taylor expanded in x around 0
Applied rewrites26.9%
if 5.4999999999999997e-79 < x Initial program 75.4%
Applied rewrites51.5%
Evaluated real constant51.5%
Taylor expanded in x around inf
Applied rewrites50.5%
(FPCore (x) :precision binary64 :pre TRUE 0.2928932188134524)
double code(double x) {
return 0.2928932188134524;
}
real(8) function code(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 0.2928932188134524d0
end function
public static double code(double x) {
return 0.2928932188134524;
}
def code(x): return 0.2928932188134524
function code(x) return 0.2928932188134524 end
function tmp = code(x) tmp = 0.2928932188134524; end
code[x_] := 0.2928932188134524
f(x): x in [-inf, +inf] code: THEORY BEGIN f(x: real): real = 29289321881345242726268907063058577477931976318359375e-53 END code
0.2928932188134524
Initial program 75.4%
Applied rewrites51.5%
Evaluated real constant51.5%
Taylor expanded in x around inf
Applied rewrites50.5%
herbie shell --seed 2025355
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))