
(FPCore (x) :precision binary64 (sqrt (- 1.0 (* x x))))
double code(double x) {
return sqrt((1.0 - (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((1.0d0 - (x * x)))
end function
public static double code(double x) {
return Math.sqrt((1.0 - (x * x)));
}
def code(x): return math.sqrt((1.0 - (x * x)))
function code(x) return sqrt(Float64(1.0 - Float64(x * x))) end
function tmp = code(x) tmp = sqrt((1.0 - (x * x))); end
code[x_] := N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{1 - x \cdot x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (sqrt (- 1.0 (* x x))))
double code(double x) {
return sqrt((1.0 - (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((1.0d0 - (x * x)))
end function
public static double code(double x) {
return Math.sqrt((1.0 - (x * x)));
}
def code(x): return math.sqrt((1.0 - (x * x)))
function code(x) return sqrt(Float64(1.0 - Float64(x * x))) end
function tmp = code(x) tmp = sqrt((1.0 - (x * x))); end
code[x_] := N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{1 - x \cdot x}
\end{array}
(FPCore (x) :precision binary64 (sqrt (- 1.0 (* x x))))
double code(double x) {
return sqrt((1.0 - (x * x)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = sqrt((1.0d0 - (x * x)))
end function
public static double code(double x) {
return Math.sqrt((1.0 - (x * x)));
}
def code(x): return math.sqrt((1.0 - (x * x)))
function code(x) return sqrt(Float64(1.0 - Float64(x * x))) end
function tmp = code(x) tmp = sqrt((1.0 - (x * x))); end
code[x_] := N[Sqrt[N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\sqrt{1 - x \cdot x}
\end{array}
Initial program 100.0%
(FPCore (x) :precision binary64 (* (- 1.0 (* (* (* x x) (* x x)) (+ 0.25 (* (* x x) (+ 0.125 (* (* x x) 0.078125)))))) (+ 1.0 (* (* x x) (+ -0.5 (* x (* x (+ 0.125 (* (* x x) -0.0625)))))))))
double code(double x) {
return (1.0 - (((x * x) * (x * x)) * (0.25 + ((x * x) * (0.125 + ((x * x) * 0.078125)))))) * (1.0 + ((x * x) * (-0.5 + (x * (x * (0.125 + ((x * x) * -0.0625)))))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - (((x * x) * (x * x)) * (0.25d0 + ((x * x) * (0.125d0 + ((x * x) * 0.078125d0)))))) * (1.0d0 + ((x * x) * ((-0.5d0) + (x * (x * (0.125d0 + ((x * x) * (-0.0625d0))))))))
end function
public static double code(double x) {
return (1.0 - (((x * x) * (x * x)) * (0.25 + ((x * x) * (0.125 + ((x * x) * 0.078125)))))) * (1.0 + ((x * x) * (-0.5 + (x * (x * (0.125 + ((x * x) * -0.0625)))))));
}
def code(x): return (1.0 - (((x * x) * (x * x)) * (0.25 + ((x * x) * (0.125 + ((x * x) * 0.078125)))))) * (1.0 + ((x * x) * (-0.5 + (x * (x * (0.125 + ((x * x) * -0.0625)))))))
function code(x) return Float64(Float64(1.0 - Float64(Float64(Float64(x * x) * Float64(x * x)) * Float64(0.25 + Float64(Float64(x * x) * Float64(0.125 + Float64(Float64(x * x) * 0.078125)))))) * Float64(1.0 + Float64(Float64(x * x) * Float64(-0.5 + Float64(x * Float64(x * Float64(0.125 + Float64(Float64(x * x) * -0.0625)))))))) end
function tmp = code(x) tmp = (1.0 - (((x * x) * (x * x)) * (0.25 + ((x * x) * (0.125 + ((x * x) * 0.078125)))))) * (1.0 + ((x * x) * (-0.5 + (x * (x * (0.125 + ((x * x) * -0.0625))))))); end
code[x_] := N[(N[(1.0 - N[(N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(0.25 + N[(N[(x * x), $MachinePrecision] * N[(0.125 + N[(N[(x * x), $MachinePrecision] * 0.078125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(N[(x * x), $MachinePrecision] * 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]
\begin{array}{l}
\\
\left(1 - \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right) \cdot \left(0.25 + \left(x \cdot x\right) \cdot \left(0.125 + \left(x \cdot x\right) \cdot 0.078125\right)\right)\right) \cdot \left(1 + \left(x \cdot x\right) \cdot \left(-0.5 + x \cdot \left(x \cdot \left(0.125 + \left(x \cdot x\right) \cdot -0.0625\right)\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
*-commutativeN/A
Simplified99.7%
flip-+N/A
div-invN/A
*-lowering-*.f64N/A
Applied egg-rr99.7%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6499.7%
Simplified99.7%
Taylor expanded in x around 0
*-lowering-*.f64N/A
metadata-evalN/A
pow-sqrN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6499.7%
Simplified99.7%
(FPCore (x) :precision binary64 (+ 1.0 (* (* x x) (+ -0.5 (* x (* x (+ -0.125 (* x (* x -0.0625)))))))))
double code(double x) {
return 1.0 + ((x * x) * (-0.5 + (x * (x * (-0.125 + (x * (x * -0.0625)))))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((x * x) * ((-0.5d0) + (x * (x * ((-0.125d0) + (x * (x * (-0.0625d0))))))))
end function
public static double code(double x) {
return 1.0 + ((x * x) * (-0.5 + (x * (x * (-0.125 + (x * (x * -0.0625)))))));
}
def code(x): return 1.0 + ((x * x) * (-0.5 + (x * (x * (-0.125 + (x * (x * -0.0625)))))))
function code(x) return Float64(1.0 + Float64(Float64(x * x) * Float64(-0.5 + Float64(x * Float64(x * Float64(-0.125 + Float64(x * Float64(x * -0.0625)))))))) end
function tmp = code(x) tmp = 1.0 + ((x * x) * (-0.5 + (x * (x * (-0.125 + (x * (x * -0.0625))))))); end
code[x_] := N[(1.0 + N[(N[(x * x), $MachinePrecision] * N[(-0.5 + N[(x * N[(x * N[(-0.125 + N[(x * N[(x * -0.0625), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(x \cdot x\right) \cdot \left(-0.5 + x \cdot \left(x \cdot \left(-0.125 + x \cdot \left(x \cdot -0.0625\right)\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
distribute-rgt-neg-outN/A
mul-1-negN/A
*-commutativeN/A
Simplified99.7%
(FPCore (x) :precision binary64 (+ 1.0 (* x (+ (* (* x x) (* x -0.125)) (* x -0.5)))))
double code(double x) {
return 1.0 + (x * (((x * x) * (x * -0.125)) + (x * -0.5)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + (x * (((x * x) * (x * (-0.125d0))) + (x * (-0.5d0))))
end function
public static double code(double x) {
return 1.0 + (x * (((x * x) * (x * -0.125)) + (x * -0.5)));
}
def code(x): return 1.0 + (x * (((x * x) * (x * -0.125)) + (x * -0.5)))
function code(x) return Float64(1.0 + Float64(x * Float64(Float64(Float64(x * x) * Float64(x * -0.125)) + Float64(x * -0.5)))) end
function tmp = code(x) tmp = 1.0 + (x * (((x * x) * (x * -0.125)) + (x * -0.5))); end
code[x_] := N[(1.0 + N[(x * N[(N[(N[(x * x), $MachinePrecision] * N[(x * -0.125), $MachinePrecision]), $MachinePrecision] + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + x \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot -0.125\right) + x \cdot -0.5\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.4%
Simplified99.4%
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.4%
Applied egg-rr99.4%
(FPCore (x) :precision binary64 (+ 1.0 (* x (* x (+ -0.5 (* x (* x -0.125)))))))
double code(double x) {
return 1.0 + (x * (x * (-0.5 + (x * (x * -0.125)))));
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + (x * (x * ((-0.5d0) + (x * (x * (-0.125d0))))))
end function
public static double code(double x) {
return 1.0 + (x * (x * (-0.5 + (x * (x * -0.125)))));
}
def code(x): return 1.0 + (x * (x * (-0.5 + (x * (x * -0.125)))))
function code(x) return Float64(1.0 + Float64(x * Float64(x * Float64(-0.5 + Float64(x * Float64(x * -0.125)))))) end
function tmp = code(x) tmp = 1.0 + (x * (x * (-0.5 + (x * (x * -0.125))))); end
code[x_] := N[(1.0 + N[(x * N[(x * N[(-0.5 + N[(x * N[(x * -0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + x \cdot \left(x \cdot \left(-0.5 + x \cdot \left(x \cdot -0.125\right)\right)\right)
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6499.4%
Simplified99.4%
(FPCore (x) :precision binary64 (+ 1.0 (* (* x x) -0.5)))
double code(double x) {
return 1.0 + ((x * x) * -0.5);
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0 + ((x * x) * (-0.5d0))
end function
public static double code(double x) {
return 1.0 + ((x * x) * -0.5);
}
def code(x): return 1.0 + ((x * x) * -0.5)
function code(x) return Float64(1.0 + Float64(Float64(x * x) * -0.5)) end
function tmp = code(x) tmp = 1.0 + ((x * x) * -0.5); end
code[x_] := N[(1.0 + N[(N[(x * x), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(x \cdot x\right) \cdot -0.5
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6499.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in x around 0
Simplified98.5%
herbie shell --seed 2024191
(FPCore (x)
:name "Diagrams.TwoD.Ellipse:ellipse from diagrams-lib-1.3.0.3"
:precision binary64
(sqrt (- 1.0 (* x x))))