Average Error: 0.0 → 0.0
Time: 2.8s
Precision: binary64
Cost: 13248
\[\frac{-\left(f + n\right)}{f - n} \]
\[\log \left(e^{\frac{f + n}{n - f}}\right) \]
(FPCore (f n) :precision binary64 (/ (- (+ f n)) (- f n)))
(FPCore (f n) :precision binary64 (log (exp (/ (+ f n) (- n f)))))
double code(double f, double n) {
	return -(f + n) / (f - n);
}
double code(double f, double n) {
	return log(exp(((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 = log(exp(((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 Math.log(Math.exp(((f + n) / (n - f))));
}
def code(f, n):
	return -(f + n) / (f - n)
def code(f, n):
	return math.log(math.exp(((f + n) / (n - f))))
function code(f, n)
	return Float64(Float64(-Float64(f + n)) / Float64(f - n))
end
function code(f, n)
	return log(exp(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 = log(exp(((f + n) / (n - f))));
end
code[f_, n_] := N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision]
code[f_, n_] := N[Log[N[Exp[N[(N[(f + n), $MachinePrecision] / N[(n - f), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\frac{-\left(f + n\right)}{f - n}
\log \left(e^{\frac{f + n}{n - f}}\right)

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}} \]
    Proof
    (/.f64 (+.f64 f n) (-.f64 n f)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= /-rgt-identity_binary64 (/.f64 (+.f64 f n) 1)) (-.f64 n f)): 0 points increase in error, 0 points decrease in error
    (/.f64 (/.f64 (+.f64 f n) (Rewrite<= metadata-eval (/.f64 -1 -1))) (-.f64 n f)): 0 points increase in error, 0 points decrease in error
    (/.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (+.f64 f n) -1) -1)) (-.f64 n f)): 0 points increase in error, 0 points decrease in error
    (/.f64 (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 -1 (+.f64 f n))) -1) (-.f64 n f)): 0 points increase in error, 0 points decrease in error
    (/.f64 (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (+.f64 f n))) -1) (-.f64 n f)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-/r*_binary64 (/.f64 (neg.f64 (+.f64 f n)) (*.f64 -1 (-.f64 n f)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (neg.f64 (+.f64 f n)) (Rewrite<= neg-mul-1_binary64 (neg.f64 (-.f64 n f)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (neg.f64 (+.f64 f n)) (Rewrite<= sub0-neg_binary64 (-.f64 0 (-.f64 n f)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (neg.f64 (+.f64 f n)) (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 0 n) f))): 0 points increase in error, 0 points decrease in error
    (/.f64 (neg.f64 (+.f64 f n)) (+.f64 (Rewrite<= neg-sub0_binary64 (neg.f64 n)) f)): 0 points increase in error, 0 points decrease in error
    (/.f64 (neg.f64 (+.f64 f n)) (Rewrite<= +-commutative_binary64 (+.f64 f (neg.f64 n)))): 0 points increase in error, 0 points decrease in error
    (/.f64 (neg.f64 (+.f64 f n)) (Rewrite<= sub-neg_binary64 (-.f64 f n))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{\log \left(e^{\frac{f + n}{n - f}}\right)} \]
  4. Final simplification0.0

    \[\leadsto \log \left(e^{\frac{f + n}{n - f}}\right) \]

Alternatives

Alternative 1
Error16.8
Cost712
\[\begin{array}{l} t_0 := 2 \cdot \frac{f}{n} + 1\\ \mathbf{if}\;n \leq -6.3 \cdot 10^{-68}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{+72}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error0.0
Cost704
\[\frac{n}{n - f} + \frac{f}{n - f} \]
Alternative 3
Error0.0
Cost448
\[\frac{f + n}{n - f} \]
Alternative 4
Error17.2
Cost328
\[\begin{array}{l} \mathbf{if}\;n \leq -6.3 \cdot 10^{-68}:\\ \;\;\;\;1\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{+72}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
Alternative 5
Error31.9
Cost64
\[-1 \]

Error

Reproduce

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