?

Average Accuracy: 84.4% → 99.8%
Time: 6.3s
Precision: binary64
Cost: 841

?

\[\frac{x + y \cdot \left(z - x\right)}{z} \]
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+19} \lor \neg \left(y \leq 72000000\right):\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
(FPCore (x y z)
 :precision binary64
 (if (or (<= y -1.75e+19) (not (<= y 72000000.0)))
   (/ y (/ z (- z x)))
   (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
	return (x + (y * (z - x))) / z;
}
double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.75e+19) || !(y <= 72000000.0)) {
		tmp = y / (z / (z - x));
	} else {
		tmp = (x + (y * (z - x))) / z;
	}
	return tmp;
}
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    code = (x + (y * (z - x))) / z
end function
real(8) function code(x, y, z)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8) :: tmp
    if ((y <= (-1.75d+19)) .or. (.not. (y <= 72000000.0d0))) then
        tmp = y / (z / (z - x))
    else
        tmp = (x + (y * (z - x))) / z
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return (x + (y * (z - x))) / z;
}
public static double code(double x, double y, double z) {
	double tmp;
	if ((y <= -1.75e+19) || !(y <= 72000000.0)) {
		tmp = y / (z / (z - x));
	} else {
		tmp = (x + (y * (z - x))) / z;
	}
	return tmp;
}
def code(x, y, z):
	return (x + (y * (z - x))) / z
def code(x, y, z):
	tmp = 0
	if (y <= -1.75e+19) or not (y <= 72000000.0):
		tmp = y / (z / (z - x))
	else:
		tmp = (x + (y * (z - x))) / z
	return tmp
function code(x, y, z)
	return Float64(Float64(x + Float64(y * Float64(z - x))) / z)
end
function code(x, y, z)
	tmp = 0.0
	if ((y <= -1.75e+19) || !(y <= 72000000.0))
		tmp = Float64(y / Float64(z / Float64(z - x)));
	else
		tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z);
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x + (y * (z - x))) / z;
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if ((y <= -1.75e+19) || ~((y <= 72000000.0)))
		tmp = y / (z / (z - x));
	else
		tmp = (x + (y * (z - x))) / z;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
code[x_, y_, z_] := If[Or[LessEqual[y, -1.75e+19], N[Not[LessEqual[y, 72000000.0]], $MachinePrecision]], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\frac{x + y \cdot \left(z - x\right)}{z}
\begin{array}{l}
\mathbf{if}\;y \leq -1.75 \cdot 10^{+19} \lor \neg \left(y \leq 72000000\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original84.4%
Target99.9%
Herbie99.8%
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}} \]

Derivation?

  1. Split input into 2 regimes
  2. if y < -1.75e19 or 7.2e7 < y

    1. Initial program 62.2%

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
    2. Taylor expanded in y around inf 62.1%

      \[\leadsto \color{blue}{\frac{y \cdot \left(z - x\right)}{z}} \]
    3. Simplified99.7%

      \[\leadsto \color{blue}{\frac{y}{\frac{z}{z - x}}} \]
      Proof

      [Start]62.1

      \[ \frac{y \cdot \left(z - x\right)}{z} \]

      associate-/l* [=>]99.7

      \[ \color{blue}{\frac{y}{\frac{z}{z - x}}} \]

    if -1.75e19 < y < 7.2e7

    1. Initial program 99.9%

      \[\frac{x + y \cdot \left(z - x\right)}{z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+19} \lor \neg \left(y \leq 72000000\right):\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy86.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{+57} \lor \neg \left(x \leq 9.5 \cdot 10^{+92}\right):\\ \;\;\;\;x \cdot \frac{1 - y}{z}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]
Alternative 2
Accuracy98.8%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 1\right):\\ \;\;\;\;\frac{y}{\frac{z}{z - x}}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]
Alternative 3
Accuracy84.6%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+123}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -4400000:\\ \;\;\;\;y \cdot \frac{-x}{z}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]
Alternative 4
Accuracy84.6%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+123}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq -4400000:\\ \;\;\;\;\frac{y}{\frac{-z}{x}}\\ \mathbf{else}:\\ \;\;\;\;y + \frac{x}{z}\\ \end{array} \]
Alternative 5
Accuracy68.4%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -3.7 \cdot 10^{-97}:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 4.1 \cdot 10^{-69}:\\ \;\;\;\;\frac{x}{z}\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 6
Accuracy86.5%
Cost320
\[y + \frac{x}{z} \]
Alternative 7
Accuracy50.5%
Cost64
\[y \]

Error

Reproduce?

herbie shell --seed 2023147 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

  :herbie-target
  (- (+ y (/ x z)) (/ y (/ z x)))

  (/ (+ x (* y (- z x))) z))