# ?

Average Error: 18.0 → 0.0
Time: 5.0s
Precision: binary64
Cost: 448

# ?

$\left(-1.79 \cdot 10^{+308} \leq y \land y \leq 1.79 \cdot 10^{+308}\right) \land \left(-1.79 \cdot 10^{+308} \leq x \land x \leq 1.79 \cdot 10^{+308}\right)$
$y - \frac{y \cdot y - x}{2 \cdot y}$
$0.5 \cdot \left(y + \frac{x}{y}\right)$
(FPCore (y x) :precision binary64 (- y (/ (- (* y y) x) (* 2.0 y))))
(FPCore (y x) :precision binary64 (* 0.5 (+ y (/ x y))))
double code(double y, double x) {
return y - (((y * y) - x) / (2.0 * y));
}

double code(double y, double x) {
return 0.5 * (y + (x / y));
}

real(8) function code(y, x)
real(8), intent (in) :: y
real(8), intent (in) :: x
code = y - (((y * y) - x) / (2.0d0 * y))
end function

real(8) function code(y, x)
real(8), intent (in) :: y
real(8), intent (in) :: x
code = 0.5d0 * (y + (x / y))
end function

public static double code(double y, double x) {
return y - (((y * y) - x) / (2.0 * y));
}

public static double code(double y, double x) {
return 0.5 * (y + (x / y));
}

def code(y, x):
return y - (((y * y) - x) / (2.0 * y))

def code(y, x):
return 0.5 * (y + (x / y))

function code(y, x)
return Float64(y - Float64(Float64(Float64(y * y) - x) / Float64(2.0 * y)))
end

function code(y, x)
return Float64(0.5 * Float64(y + Float64(x / y)))
end

function tmp = code(y, x)
tmp = y - (((y * y) - x) / (2.0 * y));
end

function tmp = code(y, x)
tmp = 0.5 * (y + (x / y));
end

code[y_, x_] := N[(y - N[(N[(N[(y * y), $MachinePrecision] - x),$MachinePrecision] / N[(2.0 * y), $MachinePrecision]),$MachinePrecision]), $MachinePrecision]  code[y_, x_] := N[(0.5 * N[(y + N[(x / y),$MachinePrecision]), $MachinePrecision]),$MachinePrecision]

y - \frac{y \cdot y - x}{2 \cdot y}

0.5 \cdot \left(y + \frac{x}{y}\right)


# Try it out?

Your Program's Arguments

Results

 In Out
Enter valid numbers for all inputs

# Derivation?

1. Initial program 18.0

$y - \frac{y \cdot y - x}{2 \cdot y}$
2. Simplified0.0

$\leadsto \color{blue}{0.5 \cdot \left(\frac{x}{y} + y\right)}$
Proof
[Start]18.0 $y - \frac{y \cdot y - x}{2 \cdot y}$ $\color{blue}{y + \left(-\frac{y \cdot y - x}{2 \cdot y}\right)}$ $\color{blue}{\left(-\frac{y \cdot y - x}{2 \cdot y}\right) + y}$ $\color{blue}{\left(0 - \frac{y \cdot y - x}{2 \cdot y}\right)} + y$ $\color{blue}{0 - \left(\frac{y \cdot y - x}{2 \cdot y} - y\right)}$ $\color{blue}{-\left(\frac{y \cdot y - x}{2 \cdot y} - y\right)}$ $-\left(\color{blue}{\left(\frac{y \cdot y}{2 \cdot y} - \frac{x}{2 \cdot y}\right)} - y\right)$ $-\left(\color{blue}{\left(\frac{y \cdot y}{2 \cdot y} + \left(-\frac{x}{2 \cdot y}\right)\right)} - y\right)$ $-\left(\color{blue}{\left(\left(-\frac{x}{2 \cdot y}\right) + \frac{y \cdot y}{2 \cdot y}\right)} - y\right)$ $-\left(\left(\left(-\frac{x}{2 \cdot y}\right) + \color{blue}{\frac{y}{2} \cdot \frac{y}{y}}\right) - y\right)$ $-\left(\left(\left(-\frac{x}{2 \cdot y}\right) + \frac{y}{2} \cdot \color{blue}{1}\right) - y\right)$ $-\left(\left(\left(-\frac{x}{2 \cdot y}\right) + \color{blue}{\frac{y}{2}}\right) - y\right)$ $-\color{blue}{\left(\left(-\frac{x}{2 \cdot y}\right) + \left(\frac{y}{2} - y\right)\right)}$ $-\color{blue}{\left(\left(\frac{y}{2} - y\right) + \left(-\frac{x}{2 \cdot y}\right)\right)}$
3. Final simplification0.0

$\leadsto 0.5 \cdot \left(y + \frac{x}{y}\right)$

# Alternatives

Alternative 1
Error9.1
Cost584
$\begin{array}{l} \mathbf{if}\;y \leq -1400:\\ \;\;\;\;0.5 \cdot y\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-14}:\\ \;\;\;\;0.5 \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot y\\ \end{array}$
Alternative 2
Error27.2
Cost192
$0.5 \cdot y$

# Reproduce?

herbie shell --seed 1
(FPCore (y x)
:name "y - (y*y - x) / (2 y)"
:precision binary64
:pre (and (and (<= -1.79e+308 y) (<= y 1.79e+308)) (and (<= -1.79e+308 x) (<= x 1.79e+308)))
(- y (/ (- (* y y) x) (* 2.0 y))))