# ?

Average Error: 0.0 → 0.0
Time: 14.7s
Precision: binary64
Cost: 13632

# ?

$\left(\left(\left(\left(0 \leq va \land va \leq 10000000\right) \land \left(0 \leq vb \land vb \leq 10000000\right)\right) \land \left(0 \leq p \land p \leq 1\right)\right) \land \left(1 \leq na \land na \leq 10000000\right)\right) \land \left(1 \leq nb \land nb \leq 10000000\right)$
$\frac{\left|va - vb\right| \cdot \left(1 - p\right)}{p} - \left|na - nb\right|$
$\frac{\left|va - vb\right| \cdot \left(1 - p\right)}{p} - \left|na - nb\right|$
(FPCore (va vb p na nb)
:precision binary64
(- (/ (* (fabs (- va vb)) (- 1.0 p)) p) (fabs (- na nb))))
(FPCore (va vb p na nb)
:precision binary64
(- (/ (* (fabs (- va vb)) (- 1.0 p)) p) (fabs (- na nb))))
double code(double va, double vb, double p, double na, double nb) {
return ((fabs((va - vb)) * (1.0 - p)) / p) - fabs((na - nb));
}

double code(double va, double vb, double p, double na, double nb) {
return ((fabs((va - vb)) * (1.0 - p)) / p) - fabs((na - nb));
}

real(8) function code(va, vb, p, na, nb)
real(8), intent (in) :: va
real(8), intent (in) :: vb
real(8), intent (in) :: p
real(8), intent (in) :: na
real(8), intent (in) :: nb
code = ((abs((va - vb)) * (1.0d0 - p)) / p) - abs((na - nb))
end function

real(8) function code(va, vb, p, na, nb)
real(8), intent (in) :: va
real(8), intent (in) :: vb
real(8), intent (in) :: p
real(8), intent (in) :: na
real(8), intent (in) :: nb
code = ((abs((va - vb)) * (1.0d0 - p)) / p) - abs((na - nb))
end function

public static double code(double va, double vb, double p, double na, double nb) {
return ((Math.abs((va - vb)) * (1.0 - p)) / p) - Math.abs((na - nb));
}

public static double code(double va, double vb, double p, double na, double nb) {
return ((Math.abs((va - vb)) * (1.0 - p)) / p) - Math.abs((na - nb));
}

def code(va, vb, p, na, nb):
return ((math.fabs((va - vb)) * (1.0 - p)) / p) - math.fabs((na - nb))

def code(va, vb, p, na, nb):
return ((math.fabs((va - vb)) * (1.0 - p)) / p) - math.fabs((na - nb))

function code(va, vb, p, na, nb)
return Float64(Float64(Float64(abs(Float64(va - vb)) * Float64(1.0 - p)) / p) - abs(Float64(na - nb)))
end

function code(va, vb, p, na, nb)
return Float64(Float64(Float64(abs(Float64(va - vb)) * Float64(1.0 - p)) / p) - abs(Float64(na - nb)))
end

function tmp = code(va, vb, p, na, nb)
tmp = ((abs((va - vb)) * (1.0 - p)) / p) - abs((na - nb));
end

function tmp = code(va, vb, p, na, nb)
tmp = ((abs((va - vb)) * (1.0 - p)) / p) - abs((na - nb));
end

code[va_, vb_, p_, na_, nb_] := N[(N[(N[(N[Abs[N[(va - vb), $MachinePrecision]],$MachinePrecision] * N[(1.0 - p), $MachinePrecision]),$MachinePrecision] / p), $MachinePrecision] - N[Abs[N[(na - nb),$MachinePrecision]], $MachinePrecision]),$MachinePrecision]

code[va_, vb_, p_, na_, nb_] := N[(N[(N[(N[Abs[N[(va - vb), $MachinePrecision]],$MachinePrecision] * N[(1.0 - p), $MachinePrecision]),$MachinePrecision] / p), $MachinePrecision] - N[Abs[N[(na - nb),$MachinePrecision]], $MachinePrecision]),$MachinePrecision]

\frac{\left|va - vb\right| \cdot \left(1 - p\right)}{p} - \left|na - nb\right|

\frac{\left|va - vb\right| \cdot \left(1 - p\right)}{p} - \left|na - nb\right|


# Try it out?

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 0.0

$\frac{\left|va - vb\right| \cdot \left(1 - p\right)}{p} - \left|na - nb\right|$
2. Final simplification0.0

$\leadsto \frac{\left|va - vb\right| \cdot \left(1 - p\right)}{p} - \left|na - nb\right|$

# Alternatives

Alternative 1
Error0.2
Cost13632
$\left|va - vb\right| \cdot \frac{1 - p}{p} - \left|na - nb\right|$
Alternative 2
Error21.3
Cost6976
$\frac{vb - va}{p} - \left|na - nb\right|$
Alternative 3
Error35.6
Cost708
$\begin{array}{l} \mathbf{if}\;p \leq 2.25 \cdot 10^{-122}:\\ \;\;\;\;nb + \left(\frac{vb - va}{p} - na\right)\\ \mathbf{else}:\\ \;\;\;\;na + \left(\left(vb - va\right) - nb\right)\\ \end{array}$
Alternative 4
Error43.8
Cost580
$\begin{array}{l} \mathbf{if}\;p \leq 9.2 \cdot 10^{-132}:\\ \;\;\;\;va \cdot \left(\frac{1}{p} + -1\right)\\ \mathbf{else}:\\ \;\;\;\;-na\\ \end{array}$
Alternative 5
Error51.5
Cost448
$na + \left(\left(vb - va\right) - nb\right)$
Alternative 6
Error58.7
Cost128
$-na$
Alternative 7
Error61.1
Cost64
$nb$

# Reproduce?

herbie shell --seed 1
(FPCore (va vb p na nb)
:name "abs(va-vb)*(1-p)/p-abs(na-nb)"
:precision binary64
:pre (and (and (and (and (and (<= 0.0 va) (<= va 10000000.0)) (and (<= 0.0 vb) (<= vb 10000000.0))) (and (<= 0.0 p) (<= p 1.0))) (and (<= 1.0 na) (<= na 10000000.0))) (and (<= 1.0 nb) (<= nb 10000000.0)))
(- (/ (* (fabs (- va vb)) (- 1.0 p)) p) (fabs (- na nb))))