Average Error: 0.0 → 0.0
Time: 3.7s
Precision: binary64
Cost: 448
\[\frac{-\left(f + n\right)}{f - n} \]
\[\frac{f + n}{n - f} \]
(FPCore (f n) :precision binary64 (/ (- (+ f n)) (- f n)))
(FPCore (f n) :precision binary64 (/ (+ f n) (- n f)))
double code(double f, double n) {
	return -(f + n) / (f - n);
}
double code(double f, double n) {
	return (f + n) / (n - f);
}
real(8) function code(f, n)
    real(8), intent (in) :: f
    real(8), intent (in) :: n
    code = -(f + n) / (f - n)
end function
real(8) function code(f, n)
    real(8), intent (in) :: f
    real(8), intent (in) :: n
    code = (f + n) / (n - f)
end function
public static double code(double f, double n) {
	return -(f + n) / (f - n);
}
public static double code(double f, double n) {
	return (f + n) / (n - f);
}
def code(f, n):
	return -(f + n) / (f - n)
def code(f, n):
	return (f + n) / (n - f)
function code(f, n)
	return Float64(Float64(-Float64(f + n)) / Float64(f - n))
end
function code(f, n)
	return Float64(Float64(f + n) / Float64(n - f))
end
function tmp = code(f, n)
	tmp = -(f + n) / (f - n);
end
function tmp = code(f, n)
	tmp = (f + n) / (n - f);
end
code[f_, n_] := N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision]
code[f_, n_] := N[(N[(f + n), $MachinePrecision] / N[(n - f), $MachinePrecision]), $MachinePrecision]
\frac{-\left(f + n\right)}{f - n}
\frac{f + n}{n - f}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.0

    \[\frac{-\left(f + n\right)}{f - n} \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{f + n}{n - f}} \]
  3. Final simplification0.0

    \[\leadsto \frac{f + n}{n - f} \]

Alternatives

Alternative 1
Error16.6
Cost976
\[\begin{array}{l} t_0 := 2 \cdot \frac{f}{n} + 1\\ \mathbf{if}\;n \leq -5.261895610749143 \cdot 10^{-74}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 5193542763.371221:\\ \;\;\;\;-1\\ \mathbf{elif}\;n \leq 1.3275972594834952 \cdot 10^{+40}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 5.432514480889239 \cdot 10^{+82}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error16.7
Cost592
\[\begin{array}{l} \mathbf{if}\;n \leq -6.514431637250733 \cdot 10^{-29}:\\ \;\;\;\;1\\ \mathbf{elif}\;n \leq 5193542763.371221:\\ \;\;\;\;-1\\ \mathbf{elif}\;n \leq 8.426200830089981 \cdot 10^{+28}:\\ \;\;\;\;1\\ \mathbf{elif}\;n \leq 5.432514480889239 \cdot 10^{+82}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 3
Error32.0
Cost64
\[-1 \]

Error

Reproduce

herbie shell --seed 2022225 
(FPCore (f n)
  :name "subtraction fraction"
  :precision binary64
  (/ (- (+ f n)) (- f n)))