(FPCore (F B x) :precision binary64 (+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))
(FPCore (F B x)
:precision binary64
(let* ((t_0 (/ x (tan B))))
(if (<= F -108889265.59650335)
(- (/ -1.0 (sin B)) t_0)
(if (<= F 69448571.11480942)
(-
(* (sqrt (/ 1.0 (+ 2.0 (pow F 2.0)))) (/ F (sin B)))
(* (/ x (sin B)) (cos B)))
(- (/ 1.0 (sin B)) t_0)))))double code(double F, double B, double x) {
return -(x * (1.0 / tan(B))) + ((F / sin(B)) * pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
double code(double F, double B, double x) {
double t_0 = x / tan(B);
double tmp;
if (F <= -108889265.59650335) {
tmp = (-1.0 / sin(B)) - t_0;
} else if (F <= 69448571.11480942) {
tmp = (sqrt((1.0 / (2.0 + pow(F, 2.0)))) * (F / sin(B))) - ((x / sin(B)) * cos(B));
} else {
tmp = (1.0 / sin(B)) - t_0;
}
return tmp;
}
real(8) function code(f, b, x)
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
code = -(x * (1.0d0 / tan(b))) + ((f / sin(b)) * ((((f * f) + 2.0d0) + (2.0d0 * x)) ** -(1.0d0 / 2.0d0)))
end function
real(8) function code(f, b, x)
real(8), intent (in) :: f
real(8), intent (in) :: b
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = x / tan(b)
if (f <= (-108889265.59650335d0)) then
tmp = ((-1.0d0) / sin(b)) - t_0
else if (f <= 69448571.11480942d0) then
tmp = (sqrt((1.0d0 / (2.0d0 + (f ** 2.0d0)))) * (f / sin(b))) - ((x / sin(b)) * cos(b))
else
tmp = (1.0d0 / sin(b)) - t_0
end if
code = tmp
end function
public static double code(double F, double B, double x) {
return -(x * (1.0 / Math.tan(B))) + ((F / Math.sin(B)) * Math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)));
}
public static double code(double F, double B, double x) {
double t_0 = x / Math.tan(B);
double tmp;
if (F <= -108889265.59650335) {
tmp = (-1.0 / Math.sin(B)) - t_0;
} else if (F <= 69448571.11480942) {
tmp = (Math.sqrt((1.0 / (2.0 + Math.pow(F, 2.0)))) * (F / Math.sin(B))) - ((x / Math.sin(B)) * Math.cos(B));
} else {
tmp = (1.0 / Math.sin(B)) - t_0;
}
return tmp;
}
def code(F, B, x): return -(x * (1.0 / math.tan(B))) + ((F / math.sin(B)) * math.pow((((F * F) + 2.0) + (2.0 * x)), -(1.0 / 2.0)))
def code(F, B, x): t_0 = x / math.tan(B) tmp = 0 if F <= -108889265.59650335: tmp = (-1.0 / math.sin(B)) - t_0 elif F <= 69448571.11480942: tmp = (math.sqrt((1.0 / (2.0 + math.pow(F, 2.0)))) * (F / math.sin(B))) - ((x / math.sin(B)) * math.cos(B)) else: tmp = (1.0 / math.sin(B)) - t_0 return tmp
function code(F, B, x) return Float64(Float64(-Float64(x * Float64(1.0 / tan(B)))) + Float64(Float64(F / sin(B)) * (Float64(Float64(Float64(F * F) + 2.0) + Float64(2.0 * x)) ^ Float64(-Float64(1.0 / 2.0))))) end
function code(F, B, x) t_0 = Float64(x / tan(B)) tmp = 0.0 if (F <= -108889265.59650335) tmp = Float64(Float64(-1.0 / sin(B)) - t_0); elseif (F <= 69448571.11480942) tmp = Float64(Float64(sqrt(Float64(1.0 / Float64(2.0 + (F ^ 2.0)))) * Float64(F / sin(B))) - Float64(Float64(x / sin(B)) * cos(B))); else tmp = Float64(Float64(1.0 / sin(B)) - t_0); end return tmp end
function tmp = code(F, B, x) tmp = -(x * (1.0 / tan(B))) + ((F / sin(B)) * ((((F * F) + 2.0) + (2.0 * x)) ^ -(1.0 / 2.0))); end
function tmp_2 = code(F, B, x) t_0 = x / tan(B); tmp = 0.0; if (F <= -108889265.59650335) tmp = (-1.0 / sin(B)) - t_0; elseif (F <= 69448571.11480942) tmp = (sqrt((1.0 / (2.0 + (F ^ 2.0)))) * (F / sin(B))) - ((x / sin(B)) * cos(B)); else tmp = (1.0 / sin(B)) - t_0; end tmp_2 = tmp; end
code[F_, B_, x_] := N[((-N[(x * N[(1.0 / N[Tan[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]) + N[(N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Power[N[(N[(N[(F * F), $MachinePrecision] + 2.0), $MachinePrecision] + N[(2.0 * x), $MachinePrecision]), $MachinePrecision], (-N[(1.0 / 2.0), $MachinePrecision])], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[F_, B_, x_] := Block[{t$95$0 = N[(x / N[Tan[B], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[F, -108889265.59650335], N[(N[(-1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[F, 69448571.11480942], N[(N[(N[Sqrt[N[(1.0 / N[(2.0 + N[Power[F, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(F / N[Sin[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(x / N[Sin[B], $MachinePrecision]), $MachinePrecision] * N[Cos[B], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / N[Sin[B], $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\left(-x \cdot \frac{1}{\tan B}\right) + \frac{F}{\sin B} \cdot {\left(\left(F \cdot F + 2\right) + 2 \cdot x\right)}^{\left(-\frac{1}{2}\right)}
\begin{array}{l}
t_0 := \frac{x}{\tan B}\\
\mathbf{if}\;F \leq -108889265.59650335:\\
\;\;\;\;\frac{-1}{\sin B} - t_0\\
\mathbf{elif}\;F \leq 69448571.11480942:\\
\;\;\;\;\sqrt{\frac{1}{2 + {F}^{2}}} \cdot \frac{F}{\sin B} - \frac{x}{\sin B} \cdot \cos B\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\sin B} - t_0\\
\end{array}



Bits error versus F



Bits error versus B



Bits error versus x
Results
if F < -108889265.59650335Initial program 26.6
Simplified20.5
Taylor expanded in F around -inf 0.2
if -108889265.59650335 < F < 69448571.114809424Initial program 0.4
Simplified0.3
Taylor expanded in x around 0 0.3
Simplified0.4
Taylor expanded in x around 0 0.4
if 69448571.114809424 < F Initial program 25.6
Simplified19.6
Taylor expanded in F around inf 0.1
Final simplification0.3
herbie shell --seed 2022150
(FPCore (F B x)
:name "VandenBroeck and Keller, Equation (23)"
:precision binary64
(+ (- (* x (/ 1.0 (tan B)))) (* (/ F (sin B)) (pow (+ (+ (* F F) 2.0) (* 2.0 x)) (- (/ 1.0 2.0))))))