Linear.Projection:inversePerspective from linear-1.19.1.3, B

Percentage Accurate: 77.1% → 100.0%
Time: 3.5s
Alternatives: 3
Speedup: 1.3×

Specification

?
\[\begin{array}{l} \\ \frac{x - y}{\left(x \cdot 2\right) \cdot y} \end{array} \]
(FPCore (x y) :precision binary64 (/ (- x y) (* (* x 2.0) y)))
double code(double x, double y) {
	return (x - y) / ((x * 2.0) * y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x - y) / ((x * 2.0d0) * y)
end function
public static double code(double x, double y) {
	return (x - y) / ((x * 2.0) * y);
}
def code(x, y):
	return (x - y) / ((x * 2.0) * y)
function code(x, y)
	return Float64(Float64(x - y) / Float64(Float64(x * 2.0) * y))
end
function tmp = code(x, y)
	tmp = (x - y) / ((x * 2.0) * y);
end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
\end{array}

Sampling outcomes in binary64 precision:

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 3 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: 77.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x - y}{\left(x \cdot 2\right) \cdot y} \end{array} \]
(FPCore (x y) :precision binary64 (/ (- x y) (* (* x 2.0) y)))
double code(double x, double y) {
	return (x - y) / ((x * 2.0) * y);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (x - y) / ((x * 2.0d0) * y)
end function
public static double code(double x, double y) {
	return (x - y) / ((x * 2.0) * y);
}
def code(x, y):
	return (x - y) / ((x * 2.0) * y)
function code(x, y)
	return Float64(Float64(x - y) / Float64(Float64(x * 2.0) * y))
end
function tmp = code(x, y)
	tmp = (x - y) / ((x * 2.0) * y);
end
code[x_, y_] := N[(N[(x - y), $MachinePrecision] / N[(N[(x * 2.0), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x - y}{\left(x \cdot 2\right) \cdot y}
\end{array}

Alternative 1: 100.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \frac{0.5}{y} + \frac{-0.5}{x} \end{array} \]
(FPCore (x y) :precision binary64 (+ (/ 0.5 y) (/ -0.5 x)))
double code(double x, double y) {
	return (0.5 / y) + (-0.5 / x);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (0.5d0 / y) + ((-0.5d0) / x)
end function
public static double code(double x, double y) {
	return (0.5 / y) + (-0.5 / x);
}
def code(x, y):
	return (0.5 / y) + (-0.5 / x)
function code(x, y)
	return Float64(Float64(0.5 / y) + Float64(-0.5 / x))
end
function tmp = code(x, y)
	tmp = (0.5 / y) + (-0.5 / x);
end
code[x_, y_] := N[(N[(0.5 / y), $MachinePrecision] + N[(-0.5 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{0.5}{y} + \frac{-0.5}{x}
\end{array}
Derivation
  1. Initial program 71.5%

    \[\frac{x - y}{\left(x \cdot 2\right) \cdot y} \]
  2. Step-by-step derivation
    1. remove-double-neg71.5%

      \[\leadsto \frac{x - y}{\color{blue}{-\left(-\left(x \cdot 2\right) \cdot y\right)}} \]
    2. distribute-rgt-neg-out71.5%

      \[\leadsto \frac{x - y}{-\color{blue}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    3. distribute-frac-neg271.5%

      \[\leadsto \color{blue}{-\frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    4. neg-mul-171.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    5. div-sub71.1%

      \[\leadsto -1 \cdot \color{blue}{\left(\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} \]
    6. distribute-lft-out--71.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    7. neg-mul-171.1%

      \[\leadsto \color{blue}{\left(-\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    8. distribute-frac-neg271.1%

      \[\leadsto \color{blue}{\frac{x}{-\left(x \cdot 2\right) \cdot \left(-y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    9. distribute-rgt-neg-out71.1%

      \[\leadsto \frac{x}{-\color{blue}{\left(-\left(x \cdot 2\right) \cdot y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    10. remove-double-neg71.1%

      \[\leadsto \frac{x}{\color{blue}{\left(x \cdot 2\right) \cdot y}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    11. cancel-sign-sub-inv71.1%

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot 2\right) \cdot y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    12. associate-/r*81.1%

      \[\leadsto \color{blue}{\frac{\frac{x}{x \cdot 2}}{y}} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    13. associate-/r*81.1%

      \[\leadsto \frac{\color{blue}{\frac{\frac{x}{x}}{2}}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    14. *-inverses81.1%

      \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    15. metadata-eval81.1%

      \[\leadsto \frac{\frac{\color{blue}{--1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    16. metadata-eval81.1%

      \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    17. metadata-eval81.1%

      \[\leadsto \frac{\color{blue}{0.5}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    18. metadata-eval81.1%

      \[\leadsto \frac{0.5}{y} + \color{blue}{1} \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\frac{0.5}{y} + \frac{-0.5}{x}} \]
  4. Add Preprocessing
  5. Final simplification100.0%

    \[\leadsto \frac{0.5}{y} + \frac{-0.5}{x} \]
  6. Add Preprocessing

Alternative 2: 71.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+161} \lor \neg \left(y \leq -1.65 \cdot 10^{+55}\right) \land \left(y \leq -0.0066 \lor \neg \left(y \leq 0.049\right)\right):\\ \;\;\;\;\frac{-0.5}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{y}\\ \end{array} \end{array} \]
(FPCore (x y)
 :precision binary64
 (if (or (<= y -6.2e+161)
         (and (not (<= y -1.65e+55)) (or (<= y -0.0066) (not (<= y 0.049)))))
   (/ -0.5 x)
   (/ 0.5 y)))
double code(double x, double y) {
	double tmp;
	if ((y <= -6.2e+161) || (!(y <= -1.65e+55) && ((y <= -0.0066) || !(y <= 0.049)))) {
		tmp = -0.5 / x;
	} else {
		tmp = 0.5 / y;
	}
	return tmp;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8) :: tmp
    if ((y <= (-6.2d+161)) .or. (.not. (y <= (-1.65d+55))) .and. (y <= (-0.0066d0)) .or. (.not. (y <= 0.049d0))) then
        tmp = (-0.5d0) / x
    else
        tmp = 0.5d0 / y
    end if
    code = tmp
end function
public static double code(double x, double y) {
	double tmp;
	if ((y <= -6.2e+161) || (!(y <= -1.65e+55) && ((y <= -0.0066) || !(y <= 0.049)))) {
		tmp = -0.5 / x;
	} else {
		tmp = 0.5 / y;
	}
	return tmp;
}
def code(x, y):
	tmp = 0
	if (y <= -6.2e+161) or (not (y <= -1.65e+55) and ((y <= -0.0066) or not (y <= 0.049))):
		tmp = -0.5 / x
	else:
		tmp = 0.5 / y
	return tmp
function code(x, y)
	tmp = 0.0
	if ((y <= -6.2e+161) || (!(y <= -1.65e+55) && ((y <= -0.0066) || !(y <= 0.049))))
		tmp = Float64(-0.5 / x);
	else
		tmp = Float64(0.5 / y);
	end
	return tmp
end
function tmp_2 = code(x, y)
	tmp = 0.0;
	if ((y <= -6.2e+161) || (~((y <= -1.65e+55)) && ((y <= -0.0066) || ~((y <= 0.049)))))
		tmp = -0.5 / x;
	else
		tmp = 0.5 / y;
	end
	tmp_2 = tmp;
end
code[x_, y_] := If[Or[LessEqual[y, -6.2e+161], And[N[Not[LessEqual[y, -1.65e+55]], $MachinePrecision], Or[LessEqual[y, -0.0066], N[Not[LessEqual[y, 0.049]], $MachinePrecision]]]], N[(-0.5 / x), $MachinePrecision], N[(0.5 / y), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+161} \lor \neg \left(y \leq -1.65 \cdot 10^{+55}\right) \land \left(y \leq -0.0066 \lor \neg \left(y \leq 0.049\right)\right):\\
\;\;\;\;\frac{-0.5}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.5}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.20000000000000013e161 or -1.65e55 < y < -0.0066 or 0.049000000000000002 < y

    1. Initial program 69.5%

      \[\frac{x - y}{\left(x \cdot 2\right) \cdot y} \]
    2. Step-by-step derivation
      1. remove-double-neg69.5%

        \[\leadsto \frac{x - y}{\color{blue}{-\left(-\left(x \cdot 2\right) \cdot y\right)}} \]
      2. distribute-rgt-neg-out69.5%

        \[\leadsto \frac{x - y}{-\color{blue}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      3. distribute-frac-neg269.5%

        \[\leadsto \color{blue}{-\frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      4. neg-mul-169.5%

        \[\leadsto \color{blue}{-1 \cdot \frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      5. div-sub69.5%

        \[\leadsto -1 \cdot \color{blue}{\left(\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} \]
      6. distribute-lft-out--69.5%

        \[\leadsto \color{blue}{-1 \cdot \frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      7. neg-mul-169.5%

        \[\leadsto \color{blue}{\left(-\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      8. distribute-frac-neg269.5%

        \[\leadsto \color{blue}{\frac{x}{-\left(x \cdot 2\right) \cdot \left(-y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      9. distribute-rgt-neg-out69.5%

        \[\leadsto \frac{x}{-\color{blue}{\left(-\left(x \cdot 2\right) \cdot y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      10. remove-double-neg69.5%

        \[\leadsto \frac{x}{\color{blue}{\left(x \cdot 2\right) \cdot y}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      11. cancel-sign-sub-inv69.5%

        \[\leadsto \color{blue}{\frac{x}{\left(x \cdot 2\right) \cdot y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      12. associate-/r*79.6%

        \[\leadsto \color{blue}{\frac{\frac{x}{x \cdot 2}}{y}} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      13. associate-/r*79.6%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{x}}{2}}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      14. *-inverses79.6%

        \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      15. metadata-eval79.6%

        \[\leadsto \frac{\frac{\color{blue}{--1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      16. metadata-eval79.6%

        \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      17. metadata-eval79.6%

        \[\leadsto \frac{\color{blue}{0.5}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      18. metadata-eval79.6%

        \[\leadsto \frac{0.5}{y} + \color{blue}{1} \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{0.5}{y} + \frac{-0.5}{x}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around inf 74.8%

      \[\leadsto \color{blue}{\frac{-0.5}{x}} \]

    if -6.20000000000000013e161 < y < -1.65e55 or -0.0066 < y < 0.049000000000000002

    1. Initial program 73.2%

      \[\frac{x - y}{\left(x \cdot 2\right) \cdot y} \]
    2. Step-by-step derivation
      1. remove-double-neg73.2%

        \[\leadsto \frac{x - y}{\color{blue}{-\left(-\left(x \cdot 2\right) \cdot y\right)}} \]
      2. distribute-rgt-neg-out73.2%

        \[\leadsto \frac{x - y}{-\color{blue}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      3. distribute-frac-neg273.2%

        \[\leadsto \color{blue}{-\frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      4. neg-mul-173.2%

        \[\leadsto \color{blue}{-1 \cdot \frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      5. div-sub72.5%

        \[\leadsto -1 \cdot \color{blue}{\left(\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} \]
      6. distribute-lft-out--72.5%

        \[\leadsto \color{blue}{-1 \cdot \frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      7. neg-mul-172.5%

        \[\leadsto \color{blue}{\left(-\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      8. distribute-frac-neg272.5%

        \[\leadsto \color{blue}{\frac{x}{-\left(x \cdot 2\right) \cdot \left(-y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      9. distribute-rgt-neg-out72.5%

        \[\leadsto \frac{x}{-\color{blue}{\left(-\left(x \cdot 2\right) \cdot y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      10. remove-double-neg72.5%

        \[\leadsto \frac{x}{\color{blue}{\left(x \cdot 2\right) \cdot y}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      11. cancel-sign-sub-inv72.5%

        \[\leadsto \color{blue}{\frac{x}{\left(x \cdot 2\right) \cdot y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
      12. associate-/r*82.4%

        \[\leadsto \color{blue}{\frac{\frac{x}{x \cdot 2}}{y}} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      13. associate-/r*82.4%

        \[\leadsto \frac{\color{blue}{\frac{\frac{x}{x}}{2}}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      14. *-inverses82.4%

        \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      15. metadata-eval82.4%

        \[\leadsto \frac{\frac{\color{blue}{--1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      16. metadata-eval82.4%

        \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      17. metadata-eval82.4%

        \[\leadsto \frac{\color{blue}{0.5}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
      18. metadata-eval82.4%

        \[\leadsto \frac{0.5}{y} + \color{blue}{1} \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{\frac{0.5}{y} + \frac{-0.5}{x}} \]
    4. Add Preprocessing
    5. Taylor expanded in y around 0 78.6%

      \[\leadsto \color{blue}{\frac{0.5}{y}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+161} \lor \neg \left(y \leq -1.65 \cdot 10^{+55}\right) \land \left(y \leq -0.0066 \lor \neg \left(y \leq 0.049\right)\right):\\ \;\;\;\;\frac{-0.5}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{y}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 50.8% accurate, 3.0× speedup?

\[\begin{array}{l} \\ \frac{-0.5}{x} \end{array} \]
(FPCore (x y) :precision binary64 (/ -0.5 x))
double code(double x, double y) {
	return -0.5 / x;
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (-0.5d0) / x
end function
public static double code(double x, double y) {
	return -0.5 / x;
}
def code(x, y):
	return -0.5 / x
function code(x, y)
	return Float64(-0.5 / x)
end
function tmp = code(x, y)
	tmp = -0.5 / x;
end
code[x_, y_] := N[(-0.5 / x), $MachinePrecision]
\begin{array}{l}

\\
\frac{-0.5}{x}
\end{array}
Derivation
  1. Initial program 71.5%

    \[\frac{x - y}{\left(x \cdot 2\right) \cdot y} \]
  2. Step-by-step derivation
    1. remove-double-neg71.5%

      \[\leadsto \frac{x - y}{\color{blue}{-\left(-\left(x \cdot 2\right) \cdot y\right)}} \]
    2. distribute-rgt-neg-out71.5%

      \[\leadsto \frac{x - y}{-\color{blue}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    3. distribute-frac-neg271.5%

      \[\leadsto \color{blue}{-\frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    4. neg-mul-171.5%

      \[\leadsto \color{blue}{-1 \cdot \frac{x - y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    5. div-sub71.1%

      \[\leadsto -1 \cdot \color{blue}{\left(\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} \]
    6. distribute-lft-out--71.1%

      \[\leadsto \color{blue}{-1 \cdot \frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    7. neg-mul-171.1%

      \[\leadsto \color{blue}{\left(-\frac{x}{\left(x \cdot 2\right) \cdot \left(-y\right)}\right)} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    8. distribute-frac-neg271.1%

      \[\leadsto \color{blue}{\frac{x}{-\left(x \cdot 2\right) \cdot \left(-y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    9. distribute-rgt-neg-out71.1%

      \[\leadsto \frac{x}{-\color{blue}{\left(-\left(x \cdot 2\right) \cdot y\right)}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    10. remove-double-neg71.1%

      \[\leadsto \frac{x}{\color{blue}{\left(x \cdot 2\right) \cdot y}} - -1 \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    11. cancel-sign-sub-inv71.1%

      \[\leadsto \color{blue}{\frac{x}{\left(x \cdot 2\right) \cdot y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)}} \]
    12. associate-/r*81.1%

      \[\leadsto \color{blue}{\frac{\frac{x}{x \cdot 2}}{y}} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    13. associate-/r*81.1%

      \[\leadsto \frac{\color{blue}{\frac{\frac{x}{x}}{2}}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    14. *-inverses81.1%

      \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    15. metadata-eval81.1%

      \[\leadsto \frac{\frac{\color{blue}{--1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    16. metadata-eval81.1%

      \[\leadsto \frac{\frac{\color{blue}{1}}{2}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    17. metadata-eval81.1%

      \[\leadsto \frac{\color{blue}{0.5}}{y} + \left(--1\right) \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
    18. metadata-eval81.1%

      \[\leadsto \frac{0.5}{y} + \color{blue}{1} \cdot \frac{y}{\left(x \cdot 2\right) \cdot \left(-y\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\frac{0.5}{y} + \frac{-0.5}{x}} \]
  4. Add Preprocessing
  5. Taylor expanded in y around inf 46.7%

    \[\leadsto \color{blue}{\frac{-0.5}{x}} \]
  6. Final simplification46.7%

    \[\leadsto \frac{-0.5}{x} \]
  7. Add Preprocessing

Developer target: 100.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \frac{0.5}{y} - \frac{0.5}{x} \end{array} \]
(FPCore (x y) :precision binary64 (- (/ 0.5 y) (/ 0.5 x)))
double code(double x, double y) {
	return (0.5 / y) - (0.5 / x);
}
real(8) function code(x, y)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    code = (0.5d0 / y) - (0.5d0 / x)
end function
public static double code(double x, double y) {
	return (0.5 / y) - (0.5 / x);
}
def code(x, y):
	return (0.5 / y) - (0.5 / x)
function code(x, y)
	return Float64(Float64(0.5 / y) - Float64(0.5 / x))
end
function tmp = code(x, y)
	tmp = (0.5 / y) - (0.5 / x);
end
code[x_, y_] := N[(N[(0.5 / y), $MachinePrecision] - N[(0.5 / x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{0.5}{y} - \frac{0.5}{x}
\end{array}

Reproduce

?
herbie shell --seed 2024100 
(FPCore (x y)
  :name "Linear.Projection:inversePerspective from linear-1.19.1.3, B"
  :precision binary64

  :alt
  (- (/ 0.5 y) (/ 0.5 x))

  (/ (- x y) (* (* x 2.0) y)))