subtraction fraction

Percentage Accurate: 100.0% → 100.0%
Time: 3.1s
Alternatives: 6
Speedup: 1.1×

Specification

?
\[\frac{-\left(f + n\right)}{f - n} \]
(FPCore (f n)
  :precision binary64
  (/ (- (+ f n)) (- f n)))
double code(double f, double n) {
	return -(f + n) / (f - n);
}
real(8) function code(f, n)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: n
    code = -(f + n) / (f - n)
end function
public static double code(double f, double n) {
	return -(f + n) / (f - n);
}
def code(f, n):
	return -(f + n) / (f - n)
function code(f, n)
	return Float64(Float64(-Float64(f + n)) / Float64(f - n))
end
function tmp = code(f, n)
	tmp = -(f + n) / (f - n);
end
code[f_, n_] := N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision]
\frac{-\left(f + n\right)}{f - n}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 6 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 100.0% accurate, 1.0× speedup?

\[\frac{-\left(f + n\right)}{f - n} \]
(FPCore (f n)
  :precision binary64
  (/ (- (+ f n)) (- f n)))
double code(double f, double n) {
	return -(f + n) / (f - n);
}
real(8) function code(f, n)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: n
    code = -(f + n) / (f - n)
end function
public static double code(double f, double n) {
	return -(f + n) / (f - n);
}
def code(f, n):
	return -(f + n) / (f - n)
function code(f, n)
	return Float64(Float64(-Float64(f + n)) / Float64(f - n))
end
function tmp = code(f, n)
	tmp = -(f + n) / (f - n);
end
code[f_, n_] := N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision]
\frac{-\left(f + n\right)}{f - n}

Alternative 1: 100.0% accurate, 1.1× speedup?

\[\frac{n + f}{n - f} \]
(FPCore (f n)
  :precision binary64
  (/ (+ n f) (- n f)))
double code(double f, double n) {
	return (n + f) / (n - f);
}
real(8) function code(f, n)
use fmin_fmax_functions
    real(8), intent (in) :: f
    real(8), intent (in) :: n
    code = (n + f) / (n - f)
end function
public static double code(double f, double n) {
	return (n + f) / (n - f);
}
def code(f, n):
	return (n + f) / (n - f)
function code(f, n)
	return Float64(Float64(n + f) / Float64(n - f))
end
function tmp = code(f, n)
	tmp = (n + f) / (n - f);
end
code[f_, n_] := N[(N[(n + f), $MachinePrecision] / N[(n - f), $MachinePrecision]), $MachinePrecision]
\frac{n + f}{n - f}
Derivation
  1. Initial program 100.0%

    \[\frac{-\left(f + n\right)}{f - n} \]
  2. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{-\left(f + n\right)}{f - n}} \]
    2. lift-neg.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(\left(f + n\right)\right)}}{f - n} \]
    3. distribute-frac-negN/A

      \[\leadsto \color{blue}{\mathsf{neg}\left(\frac{f + n}{f - n}\right)} \]
    4. distribute-neg-frac2N/A

      \[\leadsto \color{blue}{\frac{f + n}{\mathsf{neg}\left(\left(f - n\right)\right)}} \]
    5. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{f + n}{\mathsf{neg}\left(\left(f - n\right)\right)}} \]
    6. lift-+.f64N/A

      \[\leadsto \frac{\color{blue}{f + n}}{\mathsf{neg}\left(\left(f - n\right)\right)} \]
    7. +-commutativeN/A

      \[\leadsto \frac{\color{blue}{n + f}}{\mathsf{neg}\left(\left(f - n\right)\right)} \]
    8. lower-+.f64N/A

      \[\leadsto \frac{\color{blue}{n + f}}{\mathsf{neg}\left(\left(f - n\right)\right)} \]
    9. lift--.f64N/A

      \[\leadsto \frac{n + f}{\mathsf{neg}\left(\color{blue}{\left(f - n\right)}\right)} \]
    10. sub-negate-revN/A

      \[\leadsto \frac{n + f}{\color{blue}{n - f}} \]
    11. lower--.f64100.0%

      \[\leadsto \frac{n + f}{\color{blue}{n - f}} \]
  3. Applied rewrites100.0%

    \[\leadsto \color{blue}{\frac{n + f}{n - f}} \]
  4. Add Preprocessing

Alternative 2: 98.9% accurate, 0.5× speedup?

\[\begin{array}{l} \mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -0.5:\\ \;\;\;\;\mathsf{fma}\left(\frac{n}{f}, -2, -1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{f}{n}, 2, 1\right)\\ \end{array} \]
(FPCore (f n)
  :precision binary64
  (if (<= (/ (- (+ f n)) (- f n)) -0.5)
  (fma (/ n f) -2.0 -1.0)
  (fma (/ f n) 2.0 1.0)))
double code(double f, double n) {
	double tmp;
	if ((-(f + n) / (f - n)) <= -0.5) {
		tmp = fma((n / f), -2.0, -1.0);
	} else {
		tmp = fma((f / n), 2.0, 1.0);
	}
	return tmp;
}
function code(f, n)
	tmp = 0.0
	if (Float64(Float64(-Float64(f + n)) / Float64(f - n)) <= -0.5)
		tmp = fma(Float64(n / f), -2.0, -1.0);
	else
		tmp = fma(Float64(f / n), 2.0, 1.0);
	end
	return tmp
end
code[f_, n_] := If[LessEqual[N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision], -0.5], N[(N[(n / f), $MachinePrecision] * -2.0 + -1.0), $MachinePrecision], N[(N[(f / n), $MachinePrecision] * 2.0 + 1.0), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -0.5:\\
\;\;\;\;\mathsf{fma}\left(\frac{n}{f}, -2, -1\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{f}{n}, 2, 1\right)\\


\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n)) < -0.5

    1. Initial program 100.0%

      \[\frac{-\left(f + n\right)}{f - n} \]
    2. Taylor expanded in n around 0

      \[\leadsto \color{blue}{-2 \cdot \frac{n}{f} - 1} \]
    3. Step-by-step derivation
      1. lower--.f64N/A

        \[\leadsto -2 \cdot \frac{n}{f} - \color{blue}{1} \]
      2. lower-*.f64N/A

        \[\leadsto -2 \cdot \frac{n}{f} - 1 \]
      3. lower-/.f6450.9%

        \[\leadsto -2 \cdot \frac{n}{f} - 1 \]
    4. Applied rewrites50.9%

      \[\leadsto \color{blue}{-2 \cdot \frac{n}{f} - 1} \]
    5. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto -2 \cdot \frac{n}{f} - \color{blue}{1} \]
      2. sub-flipN/A

        \[\leadsto -2 \cdot \frac{n}{f} + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)} \]
      3. lift-*.f64N/A

        \[\leadsto -2 \cdot \frac{n}{f} + \left(\mathsf{neg}\left(\color{blue}{1}\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \frac{n}{f} \cdot -2 + \left(\mathsf{neg}\left(\color{blue}{1}\right)\right) \]
      5. metadata-evalN/A

        \[\leadsto \frac{n}{f} \cdot -2 + -1 \]
      6. lower-fma.f6450.9%

        \[\leadsto \mathsf{fma}\left(\frac{n}{f}, \color{blue}{-2}, -1\right) \]
    6. Applied rewrites50.9%

      \[\leadsto \mathsf{fma}\left(\frac{n}{f}, \color{blue}{-2}, -1\right) \]

    if -0.5 < (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n))

    1. Initial program 100.0%

      \[\frac{-\left(f + n\right)}{f - n} \]
    2. Taylor expanded in f around inf

      \[\leadsto \color{blue}{-1} \]
    3. Step-by-step derivation
      1. Applied rewrites49.6%

        \[\leadsto \color{blue}{-1} \]
      2. Taylor expanded in f around 0

        \[\leadsto \color{blue}{1 + 2 \cdot \frac{f}{n}} \]
      3. Step-by-step derivation
        1. lower-+.f64N/A

          \[\leadsto 1 + \color{blue}{2 \cdot \frac{f}{n}} \]
        2. lower-*.f64N/A

          \[\leadsto 1 + 2 \cdot \color{blue}{\frac{f}{n}} \]
        3. lower-/.f6451.1%

          \[\leadsto 1 + 2 \cdot \frac{f}{\color{blue}{n}} \]
      4. Applied rewrites51.1%

        \[\leadsto \color{blue}{1 + 2 \cdot \frac{f}{n}} \]
      5. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto 1 + \color{blue}{2 \cdot \frac{f}{n}} \]
        2. +-commutativeN/A

          \[\leadsto 2 \cdot \frac{f}{n} + \color{blue}{1} \]
        3. lift-*.f64N/A

          \[\leadsto 2 \cdot \frac{f}{n} + 1 \]
        4. *-commutativeN/A

          \[\leadsto \frac{f}{n} \cdot 2 + 1 \]
        5. lower-fma.f6451.1%

          \[\leadsto \mathsf{fma}\left(\frac{f}{n}, \color{blue}{2}, 1\right) \]
      6. Applied rewrites51.1%

        \[\leadsto \mathsf{fma}\left(\frac{f}{n}, \color{blue}{2}, 1\right) \]
    4. Recombined 2 regimes into one program.
    5. Add Preprocessing

    Alternative 3: 98.4% accurate, 0.5× speedup?

    \[\begin{array}{l} \mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -0.5:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{f}{n}, 2, 1\right)\\ \end{array} \]
    (FPCore (f n)
      :precision binary64
      (if (<= (/ (- (+ f n)) (- f n)) -0.5) -1.0 (fma (/ f n) 2.0 1.0)))
    double code(double f, double n) {
    	double tmp;
    	if ((-(f + n) / (f - n)) <= -0.5) {
    		tmp = -1.0;
    	} else {
    		tmp = fma((f / n), 2.0, 1.0);
    	}
    	return tmp;
    }
    
    function code(f, n)
    	tmp = 0.0
    	if (Float64(Float64(-Float64(f + n)) / Float64(f - n)) <= -0.5)
    		tmp = -1.0;
    	else
    		tmp = fma(Float64(f / n), 2.0, 1.0);
    	end
    	return tmp
    end
    
    code[f_, n_] := If[LessEqual[N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision], -0.5], -1.0, N[(N[(f / n), $MachinePrecision] * 2.0 + 1.0), $MachinePrecision]]
    
    \begin{array}{l}
    \mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -0.5:\\
    \;\;\;\;-1\\
    
    \mathbf{else}:\\
    \;\;\;\;\mathsf{fma}\left(\frac{f}{n}, 2, 1\right)\\
    
    
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n)) < -0.5

      1. Initial program 100.0%

        \[\frac{-\left(f + n\right)}{f - n} \]
      2. Taylor expanded in f around inf

        \[\leadsto \color{blue}{-1} \]
      3. Step-by-step derivation
        1. Applied rewrites49.6%

          \[\leadsto \color{blue}{-1} \]

        if -0.5 < (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n))

        1. Initial program 100.0%

          \[\frac{-\left(f + n\right)}{f - n} \]
        2. Taylor expanded in f around inf

          \[\leadsto \color{blue}{-1} \]
        3. Step-by-step derivation
          1. Applied rewrites49.6%

            \[\leadsto \color{blue}{-1} \]
          2. Taylor expanded in f around 0

            \[\leadsto \color{blue}{1 + 2 \cdot \frac{f}{n}} \]
          3. Step-by-step derivation
            1. lower-+.f64N/A

              \[\leadsto 1 + \color{blue}{2 \cdot \frac{f}{n}} \]
            2. lower-*.f64N/A

              \[\leadsto 1 + 2 \cdot \color{blue}{\frac{f}{n}} \]
            3. lower-/.f6451.1%

              \[\leadsto 1 + 2 \cdot \frac{f}{\color{blue}{n}} \]
          4. Applied rewrites51.1%

            \[\leadsto \color{blue}{1 + 2 \cdot \frac{f}{n}} \]
          5. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto 1 + \color{blue}{2 \cdot \frac{f}{n}} \]
            2. +-commutativeN/A

              \[\leadsto 2 \cdot \frac{f}{n} + \color{blue}{1} \]
            3. lift-*.f64N/A

              \[\leadsto 2 \cdot \frac{f}{n} + 1 \]
            4. *-commutativeN/A

              \[\leadsto \frac{f}{n} \cdot 2 + 1 \]
            5. lower-fma.f6451.1%

              \[\leadsto \mathsf{fma}\left(\frac{f}{n}, \color{blue}{2}, 1\right) \]
          6. Applied rewrites51.1%

            \[\leadsto \mathsf{fma}\left(\frac{f}{n}, \color{blue}{2}, 1\right) \]
        4. Recombined 2 regimes into one program.
        5. Add Preprocessing

        Alternative 4: 97.8% accurate, 0.5× speedup?

        \[\begin{array}{l} \mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -0.5:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;\frac{n}{n - f}\\ \end{array} \]
        (FPCore (f n)
          :precision binary64
          (if (<= (/ (- (+ f n)) (- f n)) -0.5) -1.0 (/ n (- n f))))
        double code(double f, double n) {
        	double tmp;
        	if ((-(f + n) / (f - n)) <= -0.5) {
        		tmp = -1.0;
        	} else {
        		tmp = n / (n - f);
        	}
        	return tmp;
        }
        
        real(8) function code(f, n)
        use fmin_fmax_functions
            real(8), intent (in) :: f
            real(8), intent (in) :: n
            real(8) :: tmp
            if ((-(f + n) / (f - n)) <= (-0.5d0)) then
                tmp = -1.0d0
            else
                tmp = n / (n - f)
            end if
            code = tmp
        end function
        
        public static double code(double f, double n) {
        	double tmp;
        	if ((-(f + n) / (f - n)) <= -0.5) {
        		tmp = -1.0;
        	} else {
        		tmp = n / (n - f);
        	}
        	return tmp;
        }
        
        def code(f, n):
        	tmp = 0
        	if (-(f + n) / (f - n)) <= -0.5:
        		tmp = -1.0
        	else:
        		tmp = n / (n - f)
        	return tmp
        
        function code(f, n)
        	tmp = 0.0
        	if (Float64(Float64(-Float64(f + n)) / Float64(f - n)) <= -0.5)
        		tmp = -1.0;
        	else
        		tmp = Float64(n / Float64(n - f));
        	end
        	return tmp
        end
        
        function tmp_2 = code(f, n)
        	tmp = 0.0;
        	if ((-(f + n) / (f - n)) <= -0.5)
        		tmp = -1.0;
        	else
        		tmp = n / (n - f);
        	end
        	tmp_2 = tmp;
        end
        
        code[f_, n_] := If[LessEqual[N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision], -0.5], -1.0, N[(n / N[(n - f), $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        \mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -0.5:\\
        \;\;\;\;-1\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{n}{n - f}\\
        
        
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n)) < -0.5

          1. Initial program 100.0%

            \[\frac{-\left(f + n\right)}{f - n} \]
          2. Taylor expanded in f around inf

            \[\leadsto \color{blue}{-1} \]
          3. Step-by-step derivation
            1. Applied rewrites49.6%

              \[\leadsto \color{blue}{-1} \]

            if -0.5 < (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n))

            1. Initial program 100.0%

              \[\frac{-\left(f + n\right)}{f - n} \]
            2. Taylor expanded in f around 0

              \[\leadsto \frac{-\color{blue}{n}}{f - n} \]
            3. Step-by-step derivation
              1. Applied rewrites50.9%

                \[\leadsto \frac{-\color{blue}{n}}{f - n} \]
              2. Step-by-step derivation
                1. lift-/.f64N/A

                  \[\leadsto \color{blue}{\frac{-n}{f - n}} \]
                2. lift-neg.f64N/A

                  \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(n\right)}}{f - n} \]
                3. lift--.f64N/A

                  \[\leadsto \frac{\mathsf{neg}\left(n\right)}{\color{blue}{f - n}} \]
                4. sub-negate-revN/A

                  \[\leadsto \frac{\mathsf{neg}\left(n\right)}{\color{blue}{\mathsf{neg}\left(\left(n - f\right)\right)}} \]
                5. lift--.f64N/A

                  \[\leadsto \frac{\mathsf{neg}\left(n\right)}{\mathsf{neg}\left(\color{blue}{\left(n - f\right)}\right)} \]
                6. frac-2neg-revN/A

                  \[\leadsto \color{blue}{\frac{n}{n - f}} \]
                7. lower-/.f6450.9%

                  \[\leadsto \color{blue}{\frac{n}{n - f}} \]
              3. Applied rewrites50.9%

                \[\leadsto \color{blue}{\frac{n}{n - f}} \]
            4. Recombined 2 regimes into one program.
            5. Add Preprocessing

            Alternative 5: 97.8% accurate, 0.7× speedup?

            \[\begin{array}{l} \mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -1.7 \cdot 10^{-228}:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;1\\ \end{array} \]
            (FPCore (f n)
              :precision binary64
              (if (<= (/ (- (+ f n)) (- f n)) -1.7e-228) -1.0 1.0))
            double code(double f, double n) {
            	double tmp;
            	if ((-(f + n) / (f - n)) <= -1.7e-228) {
            		tmp = -1.0;
            	} else {
            		tmp = 1.0;
            	}
            	return tmp;
            }
            
            real(8) function code(f, n)
            use fmin_fmax_functions
                real(8), intent (in) :: f
                real(8), intent (in) :: n
                real(8) :: tmp
                if ((-(f + n) / (f - n)) <= (-1.7d-228)) then
                    tmp = -1.0d0
                else
                    tmp = 1.0d0
                end if
                code = tmp
            end function
            
            public static double code(double f, double n) {
            	double tmp;
            	if ((-(f + n) / (f - n)) <= -1.7e-228) {
            		tmp = -1.0;
            	} else {
            		tmp = 1.0;
            	}
            	return tmp;
            }
            
            def code(f, n):
            	tmp = 0
            	if (-(f + n) / (f - n)) <= -1.7e-228:
            		tmp = -1.0
            	else:
            		tmp = 1.0
            	return tmp
            
            function code(f, n)
            	tmp = 0.0
            	if (Float64(Float64(-Float64(f + n)) / Float64(f - n)) <= -1.7e-228)
            		tmp = -1.0;
            	else
            		tmp = 1.0;
            	end
            	return tmp
            end
            
            function tmp_2 = code(f, n)
            	tmp = 0.0;
            	if ((-(f + n) / (f - n)) <= -1.7e-228)
            		tmp = -1.0;
            	else
            		tmp = 1.0;
            	end
            	tmp_2 = tmp;
            end
            
            code[f_, n_] := If[LessEqual[N[((-N[(f + n), $MachinePrecision]) / N[(f - n), $MachinePrecision]), $MachinePrecision], -1.7e-228], -1.0, 1.0]
            
            \begin{array}{l}
            \mathbf{if}\;\frac{-\left(f + n\right)}{f - n} \leq -1.7 \cdot 10^{-228}:\\
            \;\;\;\;-1\\
            
            \mathbf{else}:\\
            \;\;\;\;1\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n)) < -1.7e-228

              1. Initial program 100.0%

                \[\frac{-\left(f + n\right)}{f - n} \]
              2. Taylor expanded in f around inf

                \[\leadsto \color{blue}{-1} \]
              3. Step-by-step derivation
                1. Applied rewrites49.6%

                  \[\leadsto \color{blue}{-1} \]

                if -1.7e-228 < (/.f64 (neg.f64 (+.f64 f n)) (-.f64 f n))

                1. Initial program 100.0%

                  \[\frac{-\left(f + n\right)}{f - n} \]
                2. Taylor expanded in f around 0

                  \[\leadsto \color{blue}{1} \]
                3. Step-by-step derivation
                  1. Applied rewrites49.8%

                    \[\leadsto \color{blue}{1} \]
                4. Recombined 2 regimes into one program.
                5. Add Preprocessing

                Alternative 6: 49.6% accurate, 11.0× speedup?

                \[-1 \]
                (FPCore (f n)
                  :precision binary64
                  -1.0)
                double code(double f, double n) {
                	return -1.0;
                }
                
                real(8) function code(f, n)
                use fmin_fmax_functions
                    real(8), intent (in) :: f
                    real(8), intent (in) :: n
                    code = -1.0d0
                end function
                
                public static double code(double f, double n) {
                	return -1.0;
                }
                
                def code(f, n):
                	return -1.0
                
                function code(f, n)
                	return -1.0
                end
                
                function tmp = code(f, n)
                	tmp = -1.0;
                end
                
                code[f_, n_] := -1.0
                
                -1
                
                Derivation
                1. Initial program 100.0%

                  \[\frac{-\left(f + n\right)}{f - n} \]
                2. Taylor expanded in f around inf

                  \[\leadsto \color{blue}{-1} \]
                3. Step-by-step derivation
                  1. Applied rewrites49.6%

                    \[\leadsto \color{blue}{-1} \]
                  2. Add Preprocessing

                  Reproduce

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