Average Error: 0.0 → 0.0
Time: 2.8s
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
Error17.0
Cost976
\[\begin{array}{l} t_0 := -2 \cdot \frac{n}{f} + -1\\ \mathbf{if}\;n \leq -2.6476397496637592 \cdot 10^{+63}:\\ \;\;\;\;1\\ \mathbf{elif}\;n \leq -1.0465172999074706 \cdot 10^{-13}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -7.709548087072705 \cdot 10^{-51}:\\ \;\;\;\;1\\ \mathbf{elif}\;n \leq 388951867627.8923:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 2
Error16.7
Cost976
\[\begin{array}{l} t_0 := 2 \cdot \frac{f}{n} + 1\\ t_1 := -2 \cdot \frac{n}{f} + -1\\ \mathbf{if}\;n \leq -2.6476397496637592 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -1.0465172999074706 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;n \leq -7.709548087072705 \cdot 10^{-51}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 388951867627.8923:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.3
Cost592
\[\begin{array}{l} \mathbf{if}\;n \leq -1.1288238676881295 \cdot 10^{+53}:\\ \;\;\;\;1\\ \mathbf{elif}\;n \leq -1.0465172999074706 \cdot 10^{-13}:\\ \;\;\;\;-1\\ \mathbf{elif}\;n \leq -7.709548087072705 \cdot 10^{-51}:\\ \;\;\;\;1\\ \mathbf{elif}\;n \leq 388951867627.8923:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 4
Error32.2
Cost64
\[1 \]

Error

Reproduce

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