?

Average Accuracy: 80.1% → 98.6%
Time: 4.7s
Precision: binary64
Cost: 2513

?

\[\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 -2 \cdot 10^{+295}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-101} \lor \neg \left(t_0 \leq 2 \cdot 10^{+133}\right) \land t_0 \leq 2 \cdot 10^{+292}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \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 -2e+295)
     (- x (* z (/ x y)))
     (if (or (<= t_0 -2e-101) (and (not (<= t_0 2e+133)) (<= t_0 2e+292)))
       t_0
       (- x (/ x (/ y z)))))))
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 <= -2e+295) {
		tmp = x - (z * (x / y));
	} else if ((t_0 <= -2e-101) || (!(t_0 <= 2e+133) && (t_0 <= 2e+292))) {
		tmp = t_0;
	} else {
		tmp = x - (x / (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) :: t_0
    real(8) :: tmp
    t_0 = (x * (y - z)) / y
    if (t_0 <= (-2d+295)) then
        tmp = x - (z * (x / y))
    else if ((t_0 <= (-2d-101)) .or. (.not. (t_0 <= 2d+133)) .and. (t_0 <= 2d+292)) then
        tmp = t_0
    else
        tmp = x - (x / (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 t_0 = (x * (y - z)) / y;
	double tmp;
	if (t_0 <= -2e+295) {
		tmp = x - (z * (x / y));
	} else if ((t_0 <= -2e-101) || (!(t_0 <= 2e+133) && (t_0 <= 2e+292))) {
		tmp = t_0;
	} else {
		tmp = x - (x / (y / z));
	}
	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 <= -2e+295:
		tmp = x - (z * (x / y))
	elif (t_0 <= -2e-101) or (not (t_0 <= 2e+133) and (t_0 <= 2e+292)):
		tmp = t_0
	else:
		tmp = x - (x / (y / z))
	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 <= -2e+295)
		tmp = Float64(x - Float64(z * Float64(x / y)));
	elseif ((t_0 <= -2e-101) || (!(t_0 <= 2e+133) && (t_0 <= 2e+292)))
		tmp = t_0;
	else
		tmp = Float64(x - Float64(x / 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)
	t_0 = (x * (y - z)) / y;
	tmp = 0.0;
	if (t_0 <= -2e+295)
		tmp = x - (z * (x / y));
	elseif ((t_0 <= -2e-101) || (~((t_0 <= 2e+133)) && (t_0 <= 2e+292)))
		tmp = t_0;
	else
		tmp = x - (x / (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_] := Block[{t$95$0 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[t$95$0, -2e+295], N[(x - N[(z * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[t$95$0, -2e-101], And[N[Not[LessEqual[t$95$0, 2e+133]], $MachinePrecision], LessEqual[t$95$0, 2e+292]]], t$95$0, N[(x - N[(x / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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 -2 \cdot 10^{+295}:\\
\;\;\;\;x - z \cdot \frac{x}{y}\\

\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-101} \lor \neg \left(t_0 \leq 2 \cdot 10^{+133}\right) \land t_0 \leq 2 \cdot 10^{+292}:\\
\;\;\;\;t_0\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original80.1%
Target95.0%
Herbie98.6%
\[\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 (/.f64 (*.f64 x (-.f64 y z)) y) < -2e295

    1. Initial program 9.7%

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

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

      [Start]9.7

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

      associate-*l/ [<=]94.8

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

      distribute-rgt-out-- [<=]94.8

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

      associate-*r/ [=>]11.9

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

      associate-*l/ [<=]94.9

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

      *-inverses [=>]94.9

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

      *-lft-identity [=>]94.9

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

    if -2e295 < (/.f64 (*.f64 x (-.f64 y z)) y) < -2.0000000000000001e-101 or 2e133 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2e292

    1. Initial program 99.5%

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

    if -2.0000000000000001e-101 < (/.f64 (*.f64 x (-.f64 y z)) y) < 2e133 or 2e292 < (/.f64 (*.f64 x (-.f64 y z)) y)

    1. Initial program 77.0%

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

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

      [Start]77.0

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

      associate-*l/ [<=]75.1

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

      distribute-rgt-out-- [<=]75.1

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

      associate-*r/ [=>]77.4

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

      associate-*l/ [<=]94.9

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

      *-inverses [=>]94.9

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

      *-lft-identity [=>]94.9

      \[ \color{blue}{x} - z \cdot \frac{x}{y} \]
    3. Taylor expanded in z around 0 90.3%

      \[\leadsto x - \color{blue}{\frac{z \cdot x}{y}} \]
    4. Simplified98.6%

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

      [Start]90.3

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

      *-commutative [=>]90.3

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

      associate-/l* [=>]98.6

      \[ x - \color{blue}{\frac{x}{\frac{y}{z}}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification98.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot \left(y - z\right)}{y} \leq -2 \cdot 10^{+295}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{elif}\;\frac{x \cdot \left(y - z\right)}{y} \leq -2 \cdot 10^{-101} \lor \neg \left(\frac{x \cdot \left(y - z\right)}{y} \leq 2 \cdot 10^{+133}\right) \land \frac{x \cdot \left(y - z\right)}{y} \leq 2 \cdot 10^{+292}:\\ \;\;\;\;\frac{x \cdot \left(y - z\right)}{y}\\ \mathbf{else}:\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy92.5%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -5 \cdot 10^{-219} \lor \neg \left(z \leq 2.5 \cdot 10^{-147}\right):\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy97.0%
Cost713
\[\begin{array}{l} \mathbf{if}\;x \leq -5.8 \cdot 10^{-123} \lor \neg \left(x \leq 1.95 \cdot 10^{-61}\right):\\ \;\;\;\;x - \frac{x}{\frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \frac{x}{y}\\ \end{array} \]
Alternative 3
Accuracy69.5%
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{-52} \lor \neg \left(z \leq 3.8 \cdot 10^{+104}\right):\\ \;\;\;\;z \cdot \frac{-x}{y}\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Accuracy60.6%
Cost64
\[x \]

Error

Reproduce?

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