?

Average Error: 19.96% → 2.53%
Time: 6.1s
Precision: binary64
Cost: 2512

?

\[\frac{x \cdot \left(y - z\right)}{y} \]
\[\begin{array}{l} t_0 := \frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{+289}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{elif}\;t_0 \leq -4 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 4 \cdot 10^{+70}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+282}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (/ (* x (- y z)) y)))
   (if (<= t_0 -5e+289)
     (* x (- 1.0 (/ z y)))
     (if (<= t_0 -4e-81)
       t_0
       (if (<= t_0 4e+70) (/ x (/ y (- y z))) (if (<= t_0 5e+282) t_0 x))))))
double code(double x, double y, double z) {
	return (x * (y - z)) / y;
}
double code(double x, double y, double z) {
	double t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -5e+289) {
		tmp = x * (1.0 - (z / y));
	} else if (t_0 <= -4e-81) {
		tmp = t_0;
	} else if (t_0 <= 4e+70) {
		tmp = x / (y / (y - z));
	} else if (t_0 <= 5e+282) {
		tmp = t_0;
	} else {
		tmp = x;
	}
	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) :: t_0
    real(8) :: tmp
    t_0 = (x * (y - z)) / y
    if (t_0 <= (-5d+289)) then
        tmp = x * (1.0d0 - (z / y))
    else if (t_0 <= (-4d-81)) then
        tmp = t_0
    else if (t_0 <= 4d+70) then
        tmp = x / (y / (y - z))
    else if (t_0 <= 5d+282) then
        tmp = t_0
    else
        tmp = x
    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 t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -5e+289) {
		tmp = x * (1.0 - (z / y));
	} else if (t_0 <= -4e-81) {
		tmp = t_0;
	} else if (t_0 <= 4e+70) {
		tmp = x / (y / (y - z));
	} else if (t_0 <= 5e+282) {
		tmp = t_0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x, y, z):
	return (x * (y - z)) / y
def code(x, y, z):
	t_0 = (x * (y - z)) / y
	tmp = 0
	if t_0 <= -5e+289:
		tmp = x * (1.0 - (z / y))
	elif t_0 <= -4e-81:
		tmp = t_0
	elif t_0 <= 4e+70:
		tmp = x / (y / (y - z))
	elif t_0 <= 5e+282:
		tmp = t_0
	else:
		tmp = x
	return tmp
function code(x, y, z)
	return Float64(Float64(x * Float64(y - z)) / y)
end
function code(x, y, z)
	t_0 = Float64(Float64(x * Float64(y - z)) / y)
	tmp = 0.0
	if (t_0 <= -5e+289)
		tmp = Float64(x * Float64(1.0 - Float64(z / y)));
	elseif (t_0 <= -4e-81)
		tmp = t_0;
	elseif (t_0 <= 4e+70)
		tmp = Float64(x / Float64(y / Float64(y - z)));
	elseif (t_0 <= 5e+282)
		tmp = t_0;
	else
		tmp = x;
	end
	return tmp
end
function tmp = code(x, y, z)
	tmp = (x * (y - z)) / y;
end
function tmp_2 = code(x, y, z)
	t_0 = (x * (y - z)) / y;
	tmp = 0.0;
	if (t_0 <= -5e+289)
		tmp = x * (1.0 - (z / y));
	elseif (t_0 <= -4e-81)
		tmp = t_0;
	elseif (t_0 <= 4e+70)
		tmp = x / (y / (y - z));
	elseif (t_0 <= 5e+282)
		tmp = t_0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -5e+289], N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -4e-81], t$95$0, If[LessEqual[t$95$0, 4e+70], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+282], t$95$0, x]]]]]
\frac{x \cdot \left(y - z\right)}{y}
\begin{array}{l}
t_0 := \frac{x \cdot \left(y - z\right)}{y}\\
\mathbf{if}\;t_0 \leq -5 \cdot 10^{+289}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\

\mathbf{elif}\;t_0 \leq -4 \cdot 10^{-81}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+70}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+282}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;x\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.96%
Target5.08%
Herbie2.53%
\[\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 4 regimes
  2. if (/.f64 (*.f64 x (-.f64 y z)) y) < -5.00000000000000031e289

    1. Initial program 89.52

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

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

      [Start]89.52

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

      *-commutative [=>]89.52

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

      associate-*r/ [<=]5.49

      \[ \color{blue}{\left(y - z\right) \cdot \frac{x}{y}} \]
    3. Taylor expanded in x around 0 89.52

      \[\leadsto \color{blue}{\frac{\left(y - z\right) \cdot x}{y}} \]
    4. Simplified2.18

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

      [Start]89.52

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

      associate-*l/ [<=]2.18

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

      *-commutative [=>]2.18

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

      div-sub [=>]2.18

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

      *-inverses [=>]2.18

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

    if -5.00000000000000031e289 < (/.f64 (*.f64 x (-.f64 y z)) y) < -3.9999999999999998e-81 or 4.00000000000000029e70 < (/.f64 (*.f64 x (-.f64 y z)) y) < 4.99999999999999978e282

    1. Initial program 0.37

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

    if -3.9999999999999998e-81 < (/.f64 (*.f64 x (-.f64 y z)) y) < 4.00000000000000029e70

    1. Initial program 10.47

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

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

      [Start]10.47

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

      associate-/l* [=>]0.4

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

    if 4.99999999999999978e282 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 87.11

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

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

      [Start]87.11

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

      associate-/l* [=>]3.19

      \[ \color{blue}{\frac{x}{\frac{y}{y - z}}} \]
    3. Taylor expanded in y around inf 24.04

      \[\leadsto \color{blue}{x} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification2.53

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -5 \cdot 10^{+289}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -4 \cdot 10^{-81}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 4 \cdot 10^{+70}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq 5 \cdot 10^{+282}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternatives

Alternative 1
Error5.55%
Cost845
\[\begin{array}{l} \mathbf{if}\;z \leq -2.8 \cdot 10^{+66} \lor \neg \left(z \leq 3.4 \cdot 10^{+193}\right) \land z \leq 7 \cdot 10^{+255}:\\ \;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \end{array} \]
Alternative 2
Error5.27%
Cost844
\[\begin{array}{l} t_0 := \left(y - z\right) \cdot \frac{x}{y}\\ \mathbf{if}\;z \leq -3.3 \cdot 10^{+86}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.15 \cdot 10^{+194}:\\ \;\;\;\;\frac{x}{\frac{y}{y - z}}\\ \mathbf{elif}\;z \leq 4.5 \cdot 10^{+255}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \end{array} \]
Alternative 3
Error29.68%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -4.9 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-57}:\\ \;\;\;\;\frac{x}{y} \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error29.41%
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -3.55 \cdot 10^{-10}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{-57}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error5.42%
Cost580
\[\begin{array}{l} \mathbf{if}\;z \leq -6.3 \cdot 10^{+211}:\\ \;\;\;\;\frac{-z}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\ \end{array} \]
Alternative 6
Error39.1%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023090 
(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))