
(FPCore (x) :precision binary64 (- 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]
\begin{array}{l}
\\
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (- 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]
\begin{array}{l}
\\
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 0.5 (/ 0.5 (hypot 1.0 x)))))
(/
(+ (/ 0.25 t_0) (* (/ 1.0 t_0) (/ -0.25 (+ 1.0 (* x x)))))
(+ 1.0 (sqrt t_0)))))
double code(double x) {
double t_0 = 0.5 + (0.5 / hypot(1.0, x));
return ((0.25 / t_0) + ((1.0 / t_0) * (-0.25 / (1.0 + (x * x))))) / (1.0 + sqrt(t_0));
}
public static double code(double x) {
double t_0 = 0.5 + (0.5 / Math.hypot(1.0, x));
return ((0.25 / t_0) + ((1.0 / t_0) * (-0.25 / (1.0 + (x * x))))) / (1.0 + Math.sqrt(t_0));
}
def code(x): t_0 = 0.5 + (0.5 / math.hypot(1.0, x)) return ((0.25 / t_0) + ((1.0 / t_0) * (-0.25 / (1.0 + (x * x))))) / (1.0 + math.sqrt(t_0))
function code(x) t_0 = Float64(0.5 + Float64(0.5 / hypot(1.0, x))) return Float64(Float64(Float64(0.25 / t_0) + Float64(Float64(1.0 / t_0) * Float64(-0.25 / Float64(1.0 + Float64(x * x))))) / Float64(1.0 + sqrt(t_0))) end
function tmp = code(x) t_0 = 0.5 + (0.5 / hypot(1.0, x)); tmp = ((0.25 / t_0) + ((1.0 / t_0) * (-0.25 / (1.0 + (x * x))))) / (1.0 + sqrt(t_0)); end
code[x_] := Block[{t$95$0 = N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(0.25 / t$95$0), $MachinePrecision] + N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(-0.25 / N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{\frac{0.25}{t\_0} + \frac{1}{t\_0} \cdot \frac{-0.25}{1 + x \cdot x}}{1 + \sqrt{t\_0}}
\end{array}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
flip-+N/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr99.9%
*-commutativeN/A
sub-negN/A
distribute-lft-inN/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f64N/A
Applied egg-rr99.9%
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6499.9%
Applied egg-rr99.9%
(FPCore (x) :precision binary64 (let* ((t_0 (+ 0.5 (/ 0.5 (hypot 1.0 x))))) (/ (* (/ 1.0 t_0) (+ 0.25 (/ 0.25 (- -1.0 (* x x))))) (+ 1.0 (sqrt t_0)))))
double code(double x) {
double t_0 = 0.5 + (0.5 / hypot(1.0, x));
return ((1.0 / t_0) * (0.25 + (0.25 / (-1.0 - (x * x))))) / (1.0 + sqrt(t_0));
}
public static double code(double x) {
double t_0 = 0.5 + (0.5 / Math.hypot(1.0, x));
return ((1.0 / t_0) * (0.25 + (0.25 / (-1.0 - (x * x))))) / (1.0 + Math.sqrt(t_0));
}
def code(x): t_0 = 0.5 + (0.5 / math.hypot(1.0, x)) return ((1.0 / t_0) * (0.25 + (0.25 / (-1.0 - (x * x))))) / (1.0 + math.sqrt(t_0))
function code(x) t_0 = Float64(0.5 + Float64(0.5 / hypot(1.0, x))) return Float64(Float64(Float64(1.0 / t_0) * Float64(0.25 + Float64(0.25 / Float64(-1.0 - Float64(x * x))))) / Float64(1.0 + sqrt(t_0))) end
function tmp = code(x) t_0 = 0.5 + (0.5 / hypot(1.0, x)); tmp = ((1.0 / t_0) * (0.25 + (0.25 / (-1.0 - (x * x))))) / (1.0 + sqrt(t_0)); end
code[x_] := Block[{t$95$0 = N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[(N[(1.0 / t$95$0), $MachinePrecision] * N[(0.25 + N[(0.25 / N[(-1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{\frac{1}{t\_0} \cdot \left(0.25 + \frac{0.25}{-1 - x \cdot x}\right)}{1 + \sqrt{t\_0}}
\end{array}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
flip-+N/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x) :precision binary64 (/ (/ (- (/ 0.25 (+ 1.0 (* x x))) 0.25) (- (/ -0.5 (hypot 1.0 x)) 0.5)) (+ 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x)))))))
double code(double x) {
return (((0.25 / (1.0 + (x * x))) - 0.25) / ((-0.5 / hypot(1.0, x)) - 0.5)) / (1.0 + sqrt((0.5 + (0.5 / hypot(1.0, x)))));
}
public static double code(double x) {
return (((0.25 / (1.0 + (x * x))) - 0.25) / ((-0.5 / Math.hypot(1.0, x)) - 0.5)) / (1.0 + Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x)))));
}
def code(x): return (((0.25 / (1.0 + (x * x))) - 0.25) / ((-0.5 / math.hypot(1.0, x)) - 0.5)) / (1.0 + math.sqrt((0.5 + (0.5 / math.hypot(1.0, x)))))
function code(x) return Float64(Float64(Float64(Float64(0.25 / Float64(1.0 + Float64(x * x))) - 0.25) / Float64(Float64(-0.5 / hypot(1.0, x)) - 0.5)) / Float64(1.0 + sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x)))))) end
function tmp = code(x) tmp = (((0.25 / (1.0 + (x * x))) - 0.25) / ((-0.5 / hypot(1.0, x)) - 0.5)) / (1.0 + sqrt((0.5 + (0.5 / hypot(1.0, x))))); end
code[x_] := N[(N[(N[(N[(0.25 / N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 0.25), $MachinePrecision] / N[(N[(-0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{0.25}{1 + x \cdot x} - 0.25}{\frac{-0.5}{\mathsf{hypot}\left(1, x\right)} - 0.5}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
+-commutativeN/A
flip-+N/A
frac-timesN/A
metadata-evalN/A
metadata-evalN/A
frac-timesN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 0.5 (hypot 1.0 x)))) (/ 1.0 (/ (+ 1.0 (sqrt (+ 0.5 t_0))) (- 0.5 t_0)))))
double code(double x) {
double t_0 = 0.5 / hypot(1.0, x);
return 1.0 / ((1.0 + sqrt((0.5 + t_0))) / (0.5 - t_0));
}
public static double code(double x) {
double t_0 = 0.5 / Math.hypot(1.0, x);
return 1.0 / ((1.0 + Math.sqrt((0.5 + t_0))) / (0.5 - t_0));
}
def code(x): t_0 = 0.5 / math.hypot(1.0, x) return 1.0 / ((1.0 + math.sqrt((0.5 + t_0))) / (0.5 - t_0))
function code(x) t_0 = Float64(0.5 / hypot(1.0, x)) return Float64(1.0 / Float64(Float64(1.0 + sqrt(Float64(0.5 + t_0))) / Float64(0.5 - t_0))) end
function tmp = code(x) t_0 = 0.5 / hypot(1.0, x); tmp = 1.0 / ((1.0 + sqrt((0.5 + t_0))) / (0.5 - t_0)); end
code[x_] := Block[{t$95$0 = N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(N[(1.0 + N[Sqrt[N[(0.5 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(0.5 - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\frac{1}{\frac{1 + \sqrt{0.5 + t\_0}}{0.5 - t\_0}}
\end{array}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
clear-numN/A
/-lowering-/.f64N/A
div-invN/A
metadata-evalN/A
cancel-sign-sub-invN/A
div-invN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
(FPCore (x) :precision binary64 (/ (+ 0.5 (/ -0.5 (hypot 1.0 x))) (+ 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x)))))))
double code(double x) {
return (0.5 + (-0.5 / hypot(1.0, x))) / (1.0 + sqrt((0.5 + (0.5 / hypot(1.0, x)))));
}
public static double code(double x) {
return (0.5 + (-0.5 / Math.hypot(1.0, x))) / (1.0 + Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x)))));
}
def code(x): return (0.5 + (-0.5 / math.hypot(1.0, x))) / (1.0 + math.sqrt((0.5 + (0.5 / math.hypot(1.0, x)))))
function code(x) return Float64(Float64(0.5 + Float64(-0.5 / hypot(1.0, x))) / Float64(1.0 + sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x)))))) end
function tmp = code(x) tmp = (0.5 + (-0.5 / hypot(1.0, x))) / (1.0 + sqrt((0.5 + (0.5 / hypot(1.0, x))))); end
code[x_] := N[(N[(0.5 + N[(-0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
(FPCore (x) :precision binary64 (- 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x))))))
double code(double x) {
return 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x))));
}
public static double code(double x) {
return 1.0 - Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x))));
}
def code(x): return 1.0 - math.sqrt((0.5 + (0.5 / math.hypot(1.0, x))))
function code(x) return Float64(1.0 - sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x))))) end
function tmp = code(x) tmp = 1.0 - sqrt((0.5 + (0.5 / hypot(1.0, x)))); end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
(FPCore (x) :precision binary64 (let* ((t_0 (+ 0.5 (/ (+ 0.5 (/ -0.25 (* x x))) x)))) (/ (- 1.0 t_0) (+ 1.0 (sqrt t_0)))))
double code(double x) {
double t_0 = 0.5 + ((0.5 + (-0.25 / (x * x))) / x);
return (1.0 - t_0) / (1.0 + sqrt(t_0));
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
t_0 = 0.5d0 + ((0.5d0 + ((-0.25d0) / (x * x))) / x)
code = (1.0d0 - t_0) / (1.0d0 + sqrt(t_0))
end function
public static double code(double x) {
double t_0 = 0.5 + ((0.5 + (-0.25 / (x * x))) / x);
return (1.0 - t_0) / (1.0 + Math.sqrt(t_0));
}
def code(x): t_0 = 0.5 + ((0.5 + (-0.25 / (x * x))) / x) return (1.0 - t_0) / (1.0 + math.sqrt(t_0))
function code(x) t_0 = Float64(0.5 + Float64(Float64(0.5 + Float64(-0.25 / Float64(x * x))) / x)) return Float64(Float64(1.0 - t_0) / Float64(1.0 + sqrt(t_0))) end
function tmp = code(x) t_0 = 0.5 + ((0.5 + (-0.25 / (x * x))) / x); tmp = (1.0 - t_0) / (1.0 + sqrt(t_0)); end
code[x_] := Block[{t$95$0 = N[(0.5 + N[(N[(0.5 + N[(-0.25 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 + \frac{0.5 + \frac{-0.25}{x \cdot x}}{x}\\
\frac{1 - t\_0}{1 + \sqrt{t\_0}}
\end{array}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
Taylor expanded in x around inf
associate--l+N/A
associate-*r/N/A
metadata-evalN/A
unpow3N/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
Simplified96.0%
flip--N/A
/-lowering-/.f64N/A
metadata-evalN/A
rem-square-sqrtN/A
--lowering--.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
Applied egg-rr97.4%
(FPCore (x) :precision binary64 (/ 0.5 (+ 1.0 (sqrt 0.5))))
double code(double x) {
return 0.5 / (1.0 + sqrt(0.5));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.5d0 / (1.0d0 + sqrt(0.5d0))
end function
public static double code(double x) {
return 0.5 / (1.0 + Math.sqrt(0.5));
}
def code(x): return 0.5 / (1.0 + math.sqrt(0.5))
function code(x) return Float64(0.5 / Float64(1.0 + sqrt(0.5))) end
function tmp = code(x) tmp = 0.5 / (1.0 + sqrt(0.5)); end
code[x_] := N[(0.5 / N[(1.0 + N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5}{1 + \sqrt{0.5}}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
Taylor expanded in x around inf
--lowering--.f64N/A
sqrt-lowering-sqrt.f6495.6%
Simplified95.6%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
metadata-evalN/A
/-lowering-/.f64N/A
+-lowering-+.f64N/A
sqrt-lowering-sqrt.f6497.1%
Applied egg-rr97.1%
(FPCore (x) :precision binary64 (- 1.0 (sqrt 0.5)))
double code(double x) {
return 1.0 - sqrt(0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 - sqrt(0.5d0)
end function
public static double code(double x) {
return 1.0 - Math.sqrt(0.5);
}
def code(x): return 1.0 - math.sqrt(0.5)
function code(x) return Float64(1.0 - sqrt(0.5)) end
function tmp = code(x) tmp = 1.0 - sqrt(0.5); end
code[x_] := N[(1.0 - N[Sqrt[0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 - \sqrt{0.5}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
Taylor expanded in x around inf
--lowering--.f64N/A
sqrt-lowering-sqrt.f6495.6%
Simplified95.6%
(FPCore (x)
:precision binary64
(/
(+
0.5
(/
-0.5
(+ 1.0 (* x (* x (+ 0.5 (* x (* x (+ -0.125 (* (* x x) 0.0625))))))))))
2.0))
double code(double x) {
return (0.5 + (-0.5 / (1.0 + (x * (x * (0.5 + (x * (x * (-0.125 + ((x * x) * 0.0625)))))))))) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 + ((-0.5d0) / (1.0d0 + (x * (x * (0.5d0 + (x * (x * ((-0.125d0) + ((x * x) * 0.0625d0)))))))))) / 2.0d0
end function
public static double code(double x) {
return (0.5 + (-0.5 / (1.0 + (x * (x * (0.5 + (x * (x * (-0.125 + ((x * x) * 0.0625)))))))))) / 2.0;
}
def code(x): return (0.5 + (-0.5 / (1.0 + (x * (x * (0.5 + (x * (x * (-0.125 + ((x * x) * 0.0625)))))))))) / 2.0
function code(x) return Float64(Float64(0.5 + Float64(-0.5 / Float64(1.0 + Float64(x * Float64(x * Float64(0.5 + Float64(x * Float64(x * Float64(-0.125 + Float64(Float64(x * x) * 0.0625)))))))))) / 2.0) end
function tmp = code(x) tmp = (0.5 + (-0.5 / (1.0 + (x * (x * (0.5 + (x * (x * (-0.125 + ((x * x) * 0.0625)))))))))) / 2.0; end
code[x_] := N[(N[(0.5 + N[(-0.5 / N[(1.0 + N[(x * N[(x * N[(0.5 + N[(x * N[(x * N[(-0.125 + N[(N[(x * x), $MachinePrecision] * 0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 + \frac{-0.5}{1 + x \cdot \left(x \cdot \left(0.5 + x \cdot \left(x \cdot \left(-0.125 + \left(x \cdot x\right) \cdot 0.0625\right)\right)\right)\right)}}{2}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified22.8%
Taylor expanded in x around 0
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6422.8%
Simplified22.8%
(FPCore (x) :precision binary64 (/ (+ 0.5 (/ -0.5 (+ 1.0 (* (* x x) (+ 0.5 (* (* x x) -0.125)))))) 2.0))
double code(double x) {
return (0.5 + (-0.5 / (1.0 + ((x * x) * (0.5 + ((x * x) * -0.125)))))) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 + ((-0.5d0) / (1.0d0 + ((x * x) * (0.5d0 + ((x * x) * (-0.125d0))))))) / 2.0d0
end function
public static double code(double x) {
return (0.5 + (-0.5 / (1.0 + ((x * x) * (0.5 + ((x * x) * -0.125)))))) / 2.0;
}
def code(x): return (0.5 + (-0.5 / (1.0 + ((x * x) * (0.5 + ((x * x) * -0.125)))))) / 2.0
function code(x) return Float64(Float64(0.5 + Float64(-0.5 / Float64(1.0 + Float64(Float64(x * x) * Float64(0.5 + Float64(Float64(x * x) * -0.125)))))) / 2.0) end
function tmp = code(x) tmp = (0.5 + (-0.5 / (1.0 + ((x * x) * (0.5 + ((x * x) * -0.125)))))) / 2.0; end
code[x_] := N[(N[(0.5 + N[(-0.5 / N[(1.0 + N[(N[(x * x), $MachinePrecision] * N[(0.5 + N[(N[(x * x), $MachinePrecision] * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 + \frac{-0.5}{1 + \left(x \cdot x\right) \cdot \left(0.5 + \left(x \cdot x\right) \cdot -0.125\right)}}{2}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified22.8%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6422.8%
Simplified22.8%
(FPCore (x) :precision binary64 (/ (+ 0.5 (/ -0.5 (+ 1.0 (* 0.5 (* x x))))) 2.0))
double code(double x) {
return (0.5 + (-0.5 / (1.0 + (0.5 * (x * x))))) / 2.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (0.5d0 + ((-0.5d0) / (1.0d0 + (0.5d0 * (x * x))))) / 2.0d0
end function
public static double code(double x) {
return (0.5 + (-0.5 / (1.0 + (0.5 * (x * x))))) / 2.0;
}
def code(x): return (0.5 + (-0.5 / (1.0 + (0.5 * (x * x))))) / 2.0
function code(x) return Float64(Float64(0.5 + Float64(-0.5 / Float64(1.0 + Float64(0.5 * Float64(x * x))))) / 2.0) end
function tmp = code(x) tmp = (0.5 + (-0.5 / (1.0 + (0.5 * (x * x))))) / 2.0; end
code[x_] := N[(N[(0.5 + N[(-0.5 / N[(1.0 + N[(0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{0.5 + \frac{-0.5}{1 + 0.5 \cdot \left(x \cdot x\right)}}{2}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified22.8%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6422.8%
Simplified22.8%
Final simplification22.8%
(FPCore (x) :precision binary64 (+ 0.25 (/ (+ -0.25 (/ 0.125 (* x x))) x)))
double code(double x) {
return 0.25 + ((-0.25 + (0.125 / (x * x))) / x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.25d0 + (((-0.25d0) + (0.125d0 / (x * x))) / x)
end function
public static double code(double x) {
return 0.25 + ((-0.25 + (0.125 / (x * x))) / x);
}
def code(x): return 0.25 + ((-0.25 + (0.125 / (x * x))) / x)
function code(x) return Float64(0.25 + Float64(Float64(-0.25 + Float64(0.125 / Float64(x * x))) / x)) end
function tmp = code(x) tmp = 0.25 + ((-0.25 + (0.125 / (x * x))) / x); end
code[x_] := N[(0.25 + N[(N[(-0.25 + N[(0.125 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.25 + \frac{-0.25 + \frac{0.125}{x \cdot x}}{x}
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified22.8%
Taylor expanded in x around inf
associate--l+N/A
unpow3N/A
unpow2N/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
+-lowering-+.f64N/A
/-lowering-/.f64N/A
Simplified22.6%
(FPCore (x) :precision binary64 0.25)
double code(double x) {
return 0.25;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.25d0
end function
public static double code(double x) {
return 0.25;
}
def code(x): return 0.25
function code(x) return 0.25 end
function tmp = code(x) tmp = 0.25; end
code[x_] := 0.25
\begin{array}{l}
\\
0.25
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
flip--N/A
metadata-evalN/A
rem-square-sqrtN/A
associate--r+N/A
metadata-evalN/A
/-lowering-/.f64N/A
Applied egg-rr99.9%
Taylor expanded in x around 0
Simplified22.8%
Taylor expanded in x around inf
Simplified22.6%
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 98.4%
--lowering--.f64N/A
sqrt-lowering-sqrt.f64N/A
distribute-rgt-inN/A
metadata-evalN/A
+-lowering-+.f64N/A
associate-*l/N/A
metadata-evalN/A
/-lowering-/.f64N/A
hypot-undefineN/A
hypot-lowering-hypot.f6498.4%
Simplified98.4%
Taylor expanded in x around 0
Simplified3.1%
metadata-eval3.1%
Applied egg-rr3.1%
herbie shell --seed 2024138
(FPCore (x)
:name "Given's Rotation SVD example, simplified"
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))