# ?

Average Error: 0.0 → 0.1
Time: 12.6s
Precision: binary64
Cost: 13376

# ?

$\left(\left(\left(-1 \leq a \land a \leq 1\right) \land \left(-1 \leq b \land b \leq 1\right)\right) \land \left(-1 \leq c \land c \leq 1\right)\right) \land \left(-1 \leq d \land d \leq 1\right)$
$\begin{array}{c}[b, c, d] = \mathsf{sort}([b, c, d])\\ \end{array}$
$2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{\left(\left(b + c\right) + d\right) + 1}\right)$
$2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{1 + \left(d + b\right)}\right)$
(FPCore (a b c d)
:precision binary64
(* 2.0 (atan (/ (fabs a) (+ (+ (+ b c) d) 1.0)))))
(FPCore (a b c d)
:precision binary64
(* 2.0 (atan (/ (fabs a) (+ 1.0 (+ d b))))))
double code(double a, double b, double c, double d) {
return 2.0 * atan((fabs(a) / (((b + c) + d) + 1.0)));
}

double code(double a, double b, double c, double d) {
return 2.0 * atan((fabs(a) / (1.0 + (d + b))));
}

real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = 2.0d0 * atan((abs(a) / (((b + c) + d) + 1.0d0)))
end function

real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = 2.0d0 * atan((abs(a) / (1.0d0 + (d + b))))
end function

public static double code(double a, double b, double c, double d) {
return 2.0 * Math.atan((Math.abs(a) / (((b + c) + d) + 1.0)));
}

public static double code(double a, double b, double c, double d) {
return 2.0 * Math.atan((Math.abs(a) / (1.0 + (d + b))));
}

def code(a, b, c, d):
return 2.0 * math.atan((math.fabs(a) / (((b + c) + d) + 1.0)))

def code(a, b, c, d):
return 2.0 * math.atan((math.fabs(a) / (1.0 + (d + b))))

function code(a, b, c, d)
return Float64(2.0 * atan(Float64(abs(a) / Float64(Float64(Float64(b + c) + d) + 1.0))))
end

function code(a, b, c, d)
return Float64(2.0 * atan(Float64(abs(a) / Float64(1.0 + Float64(d + b)))))
end

function tmp = code(a, b, c, d)
tmp = 2.0 * atan((abs(a) / (((b + c) + d) + 1.0)));
end

function tmp = code(a, b, c, d)
tmp = 2.0 * atan((abs(a) / (1.0 + (d + b))));
end

code[a_, b_, c_, d_] := N[(2.0 * N[ArcTan[N[(N[Abs[a], $MachinePrecision] / N[(N[(N[(b + c),$MachinePrecision] + d), $MachinePrecision] + 1.0),$MachinePrecision]), $MachinePrecision]],$MachinePrecision]), $MachinePrecision]  code[a_, b_, c_, d_] := N[(2.0 * N[ArcTan[N[(N[Abs[a],$MachinePrecision] / N[(1.0 + N[(d + b), $MachinePrecision]),$MachinePrecision]), $MachinePrecision]],$MachinePrecision]), \$MachinePrecision]

2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{\left(\left(b + c\right) + d\right) + 1}\right)

2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{1 + \left(d + b\right)}\right)


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 0.0

$2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{\left(\left(b + c\right) + d\right) + 1}\right)$
2. Taylor expanded in c around 0 0.1

$\leadsto 2 \cdot \tan^{-1} \color{blue}{\left(\frac{\left|a\right|}{1 + \left(d + b\right)}\right)}$
3. Final simplification0.1

$\leadsto 2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{1 + \left(d + b\right)}\right)$

# Alternatives

Alternative 1
Error0.3
Cost13380
$\begin{array}{l} \mathbf{if}\;d \leq 10^{-28}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{1 + b}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{1 + d}\right)\\ \end{array}$
Alternative 2
Error2.1
Cost13248
$2 \cdot \tan^{-1} \left(\frac{\left|a\right|}{1 + b}\right)$
Alternative 3
Error30.1
Cost7236
$\begin{array}{l} \mathbf{if}\;a \leq -5.2 \cdot 10^{-215}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(\frac{a}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(a \cdot \frac{-1}{-1 - \left(d + b\right)}\right)\\ \end{array}$
Alternative 4
Error30.1
Cost7236
$\begin{array}{l} \mathbf{if}\;a \leq -5.2 \cdot 10^{-215}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(\frac{a}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(\frac{a}{1 + \left(\left(d + b\right) + c\right)}\right)\\ \end{array}$
Alternative 5
Error31.1
Cost6980
$\begin{array}{l} \mathbf{if}\;a \leq -5.2 \cdot 10^{-215}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(\frac{a}{b}\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \tan^{-1} \left(\frac{a}{1 + b}\right)\\ \end{array}$
Alternative 6
Error60.9
Cost6720
$2 \cdot \tan^{-1} \left(\frac{a}{b}\right)$

# Reproduce?

herbie shell --seed 1
(FPCore (a b c d)
:name "2.0 * atan(abs(a)/(b+c+d+1))"
:precision binary64
:pre (and (and (and (and (<= -1.0 a) (<= a 1.0)) (and (<= -1.0 b) (<= b 1.0))) (and (<= -1.0 c) (<= c 1.0))) (and (<= -1.0 d) (<= d 1.0)))
(* 2.0 (atan (/ (fabs a) (+ (+ (+ b c) d) 1.0)))))