?

Average Error: 12.0 → 2.5
Time: 15.4s
Precision: binary64
Cost: 776

?

\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-121}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-231}:\\ \;\;\;\;x + \left(-\frac{z \cdot x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (if (<= x -3.8e-121)
   (* x (/ (- y z) y))
   (if (<= x 1.25e-231) (+ x (- (/ (* z x) y))) (/ x (/ y (- y z))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.8e-121) {
		tmp = x * ((y - z) / y);
	} else if (x <= 1.25e-231) {
		tmp = x + -((z * x) / y);
	} else {
		tmp = x / (y / (y - 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)) / y
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 (x <= (-3.8d-121)) then
        tmp = x * ((y - z) / y)
    else if (x <= 1.25d-231) then
        tmp = x + -((z * x) / y)
    else
        tmp = x / (y / (y - z))
    end if
    code = tmp
end function
public static double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
public static double code(double x, double y, double z) {
	double tmp;
	if (x <= -3.8e-121) {
		tmp = x * ((y - z) / y);
	} else if (x <= 1.25e-231) {
		tmp = x + -((z * x) / y);
	} else {
		tmp = x / (y / (y - z));
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	tmp = 0
	if x <= -3.8e-121:
		tmp = x * ((y - z) / y)
	elif x <= 1.25e-231:
		tmp = x + -((z * x) / y)
	else:
		tmp = x / (y / (y - z))
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	tmp = 0.0
	if (x <= -3.8e-121)
		tmp = Float64(x * Float64(Float64(y - z) / y));
	elseif (x <= 1.25e-231)
		tmp = Float64(x + Float64(-Float64(Float64(z * x) / y)));
	else
		tmp = Float64(x / Float64(y / Float64(y - z)));
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	tmp = 0.0;
	if (x <= -3.8e-121)
		tmp = x * ((y - z) / y);
	elseif (x <= 1.25e-231)
		tmp = x + -((z * x) / y);
	else
		tmp = x / (y / (y - z));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[x, -3.8e-121], N[(x * N[(N[(y - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.25e-231], N[(x + (-N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision])), $MachinePrecision], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
\mathbf{if}\;x \leq -3.8 \cdot 10^{-121}:\\
\;\;\;\;x \cdot \frac{y - z}{y}\\

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-231}:\\
\;\;\;\;x + \left(-\frac{z \cdot x}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.0
Target3.0
Herbie2.5
\[\begin{array}{l} \mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\ \;\;\;\;x - \frac{z \cdot x}{y}\\ \mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{else}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if x < -3.8000000000000001e-121

    1. Initial program 15.1

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

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

      [Start]15.1

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

      rational.json-simplify-2 [=>]15.1

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

      rational.json-simplify-49 [=>]1.2

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

    if -3.8000000000000001e-121 < x < 1.25000000000000006e-231

    1. Initial program 8.7

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified6.4

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

      [Start]8.7

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

      rational.json-simplify-2 [=>]8.7

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

      rational.json-simplify-49 [=>]6.4

      \[ \color{blue}{x \cdot \frac{y - z}{y}} \]
    3. Applied egg-rr22.1

      \[\leadsto \color{blue}{\frac{y - z}{\frac{y}{x}}} \]
    4. Taylor expanded in y around 0 4.8

      \[\leadsto \color{blue}{-1 \cdot \frac{z \cdot x}{y} + x} \]
    5. Simplified4.8

      \[\leadsto \color{blue}{x + \left(-\frac{z \cdot x}{y}\right)} \]
      Proof

      [Start]4.8

      \[ -1 \cdot \frac{z \cdot x}{y} + x \]

      rational.json-simplify-1 [=>]4.8

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

      rational.json-simplify-2 [=>]4.8

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

      rational.json-simplify-9 [=>]4.8

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

    if 1.25000000000000006e-231 < x

    1. Initial program 11.6

      \[\frac{x \cdot \left(y - z\right)}{y} \]
    2. Simplified2.4

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

      [Start]11.6

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

      rational.json-simplify-2 [=>]11.6

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

      rational.json-simplify-49 [=>]2.4

      \[ \color{blue}{x \cdot \frac{y - z}{y}} \]
    3. Applied egg-rr2.2

      \[\leadsto \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.8 \cdot 10^{-121}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-231}:\\ \;\;\;\;x + \left(-\frac{z \cdot x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array} \]

Alternatives

Alternative 1
Error2.1
Cost1480
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{+74}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;t_0 \leq 10^{+232}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array} \]
Alternative 2
Error19.7
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -2.4 \cdot 10^{-114}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -5.3 \cdot 10^{-137}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -9.3 \cdot 10^{-184}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.8 \cdot 10^{-52}:\\ \;\;\;\;-z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error19.5
Cost912
\[\begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{-114}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -3.95 \cdot 10^{-137}:\\ \;\;\;\;x \cdot \left(-\frac{z}{y}\right)\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.4 \cdot 10^{-53}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error3.4
Cost712
\[\begin{array}{l} t_0 := x \cdot \frac{y - z}{y}\\ \mathbf{if}\;y \leq -4.6 \cdot 10^{-186}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -6.6 \cdot 10^{-268}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error3.4
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.04 \cdot 10^{-185}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;y \leq -5.5 \cdot 10^{-267}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array} \]
Alternative 6
Error3.0
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -3.3 \cdot 10^{-158}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;y \leq -1.65 \cdot 10^{-259}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{y - z}{y}\\ \end{array} \]
Alternative 7
Error2.8
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -6.8 \cdot 10^{-158}:\\ \;\;\;\;\left(1 - \frac{z}{y}\right) \cdot x\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-260}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \end{array} \]
Alternative 8
Error19.9
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{-183}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-50}:\\ \;\;\;\;-z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error25.3
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023073 
(FPCore (x y z)
  :name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
  :precision binary64

  :herbie-target
  (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y))))

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