?

Average Error: 0.0 → 0.0
Time: 10.6s
Precision: binary64
Cost: 1088

?

$0 \leq v \land v \leq 20$
$\frac{-v}{{\left(v + 1\right)}^{2}} \cdot \left(3 \cdot v + 2\right)$
$\frac{v}{\left(1 + v \cdot v\right) + v \cdot 2} \cdot \left(-2 + v \cdot -3\right)$
(FPCore (v)
:precision binary64
(* (/ (- v) (pow (+ v 1.0) 2.0)) (+ (* 3.0 v) 2.0)))
(FPCore (v)
:precision binary64
(* (/ v (+ (+ 1.0 (* v v)) (* v 2.0))) (+ -2.0 (* v -3.0))))
double code(double v) {
return (-v / pow((v + 1.0), 2.0)) * ((3.0 * v) + 2.0);
}

double code(double v) {
return (v / ((1.0 + (v * v)) + (v * 2.0))) * (-2.0 + (v * -3.0));
}

real(8) function code(v)
real(8), intent (in) :: v
code = (-v / ((v + 1.0d0) ** 2.0d0)) * ((3.0d0 * v) + 2.0d0)
end function

real(8) function code(v)
real(8), intent (in) :: v
code = (v / ((1.0d0 + (v * v)) + (v * 2.0d0))) * ((-2.0d0) + (v * (-3.0d0)))
end function

public static double code(double v) {
return (-v / Math.pow((v + 1.0), 2.0)) * ((3.0 * v) + 2.0);
}

public static double code(double v) {
return (v / ((1.0 + (v * v)) + (v * 2.0))) * (-2.0 + (v * -3.0));
}

def code(v):
return (-v / math.pow((v + 1.0), 2.0)) * ((3.0 * v) + 2.0)

def code(v):
return (v / ((1.0 + (v * v)) + (v * 2.0))) * (-2.0 + (v * -3.0))

function code(v)
return Float64(Float64(Float64(-v) / (Float64(v + 1.0) ^ 2.0)) * Float64(Float64(3.0 * v) + 2.0))
end

function code(v)
return Float64(Float64(v / Float64(Float64(1.0 + Float64(v * v)) + Float64(v * 2.0))) * Float64(-2.0 + Float64(v * -3.0)))
end

function tmp = code(v)
tmp = (-v / ((v + 1.0) ^ 2.0)) * ((3.0 * v) + 2.0);
end

function tmp = code(v)
tmp = (v / ((1.0 + (v * v)) + (v * 2.0))) * (-2.0 + (v * -3.0));
end

code[v_] := N[(N[((-v) / N[Power[N[(v + 1.0), $MachinePrecision], 2.0],$MachinePrecision]), $MachinePrecision] * N[(N[(3.0 * v),$MachinePrecision] + 2.0), $MachinePrecision]),$MachinePrecision]

code[v_] := N[(N[(v / N[(N[(1.0 + N[(v * v), $MachinePrecision]),$MachinePrecision] + N[(v * 2.0), $MachinePrecision]),$MachinePrecision]), $MachinePrecision] * N[(-2.0 + N[(v * -3.0),$MachinePrecision]), $MachinePrecision]),$MachinePrecision]

\frac{-v}{{\left(v + 1\right)}^{2}} \cdot \left(3 \cdot v + 2\right)

\frac{v}{\left(1 + v \cdot v\right) + v \cdot 2} \cdot \left(-2 + v \cdot -3\right)


Try it out?

Results

 In Out
Enter valid numbers for all inputs

Derivation?

1. Initial program 0.0

$\frac{-v}{{\left(v + 1\right)}^{2}} \cdot \left(3 \cdot v + 2\right)$
2. Taylor expanded in v around 0 0.0

$\leadsto \frac{-v}{\color{blue}{1 + \left({v}^{2} + 2 \cdot v\right)}} \cdot \left(3 \cdot v + 2\right)$
3. Simplified0.0

$\leadsto \frac{-v}{\color{blue}{\left(1 + v \cdot v\right) + 2 \cdot v}} \cdot \left(3 \cdot v + 2\right)$
Proof
[Start]0.0 $\frac{-v}{1 + \left({v}^{2} + 2 \cdot v\right)} \cdot \left(3 \cdot v + 2\right)$ $\frac{-v}{\color{blue}{\left(1 + {v}^{2}\right) + 2 \cdot v}} \cdot \left(3 \cdot v + 2\right)$ $\frac{-v}{\left(1 + \color{blue}{v \cdot v}\right) + 2 \cdot v} \cdot \left(3 \cdot v + 2\right)$
4. Final simplification0.0

$\leadsto \frac{v}{\left(1 + v \cdot v\right) + v \cdot 2} \cdot \left(-2 + v \cdot -3\right)$

Alternatives

Alternative 1
Error0.0
Cost960
$\frac{v}{\left(v + 1\right) \cdot \left(v + 1\right)} \cdot \left(-2 + v \cdot -3\right)$
Alternative 2
Error0.0
Cost960
$\frac{v}{1 + v \cdot \left(v + 2\right)} \cdot \left(-2 + v \cdot -3\right)$
Alternative 3
Error0.8
Cost448
$v \cdot v + v \cdot -2$
Alternative 4
Error0.8
Cost320
$v \cdot \left(v + -2\right)$
Alternative 5
Error1.6
Cost192
$\frac{v}{-0.5}$
Alternative 6
Error60.5
Cost64
$-3$

Reproduce?

herbie shell --seed 1
(FPCore (v)
:name "(-v/(v+1)^2) * (3*v + 2)"
:precision binary64
:pre (and (<= 0.0 v) (<= v 20.0))
(* (/ (- v) (pow (+ v 1.0) 2.0)) (+ (* 3.0 v) 2.0)))