?

Average Error: 14.4 → 1.4
Time: 5.8s
Precision: binary64
Cost: 2896

?

\[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ t_3 := \frac{y \cdot x}{z}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;t_2 \leq -5 \cdot 10^{-301}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 0:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+263}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (* x (/ y z)))
        (t_2 (* x (/ (* (/ y z) t) t)))
        (t_3 (/ (* y x) z)))
   (if (<= t_2 (- INFINITY))
     (/ y (/ z x))
     (if (<= t_2 -5e-301)
       t_1
       (if (<= t_2 0.0) t_3 (if (<= t_2 2e+263) t_1 t_3))))))
double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
double code(double x, double y, double z, double t) {
	double t_1 = x * (y / z);
	double t_2 = x * (((y / z) * t) / t);
	double t_3 = (y * x) / z;
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = y / (z / x);
	} else if (t_2 <= -5e-301) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 2e+263) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return x * (((y / z) * t) / t);
}
public static double code(double x, double y, double z, double t) {
	double t_1 = x * (y / z);
	double t_2 = x * (((y / z) * t) / t);
	double t_3 = (y * x) / z;
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = y / (z / x);
	} else if (t_2 <= -5e-301) {
		tmp = t_1;
	} else if (t_2 <= 0.0) {
		tmp = t_3;
	} else if (t_2 <= 2e+263) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(x, y, z, t):
	return x * (((y / z) * t) / t)
def code(x, y, z, t):
	t_1 = x * (y / z)
	t_2 = x * (((y / z) * t) / t)
	t_3 = (y * x) / z
	tmp = 0
	if t_2 <= -math.inf:
		tmp = y / (z / x)
	elif t_2 <= -5e-301:
		tmp = t_1
	elif t_2 <= 0.0:
		tmp = t_3
	elif t_2 <= 2e+263:
		tmp = t_1
	else:
		tmp = t_3
	return tmp
function code(x, y, z, t)
	return Float64(x * Float64(Float64(Float64(y / z) * t) / t))
end
function code(x, y, z, t)
	t_1 = Float64(x * Float64(y / z))
	t_2 = Float64(x * Float64(Float64(Float64(y / z) * t) / t))
	t_3 = Float64(Float64(y * x) / z)
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(y / Float64(z / x));
	elseif (t_2 <= -5e-301)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 2e+263)
		tmp = t_1;
	else
		tmp = t_3;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x * (((y / z) * t) / t);
end
function tmp_2 = code(x, y, z, t)
	t_1 = x * (y / z);
	t_2 = x * (((y / z) * t) / t);
	t_3 = (y * x) / z;
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = y / (z / x);
	elseif (t_2 <= -5e-301)
		tmp = t_1;
	elseif (t_2 <= 0.0)
		tmp = t_3;
	elseif (t_2 <= 2e+263)
		tmp = t_1;
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -5e-301], t$95$1, If[LessEqual[t$95$2, 0.0], t$95$3, If[LessEqual[t$95$2, 2e+263], t$95$1, t$95$3]]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := x \cdot \frac{y}{z}\\
t_2 := x \cdot \frac{\frac{y}{z} \cdot t}{t}\\
t_3 := \frac{y \cdot x}{z}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\mathbf{elif}\;t_2 \leq -5 \cdot 10^{-301}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 0:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+263}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.4
Target1.5
Herbie1.4
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} < -1.20672205123045 \cdot 10^{+245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < -5.907522236933906 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 5.658954423153415 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} < 2.0087180502407133 \cdot 10^{+217}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]

Derivation?

  1. Split input into 3 regimes
  2. if (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < -inf.0

    1. Initial program 64.0

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified28.7

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

      [Start]64.0

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

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

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

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

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

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

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

      rational.json-simplify-54 [=>]47.3

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

      rational.json-simplify-61 [=>]34.0

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

      rational.json-simplify-61 [=>]28.7

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

      rational.json-simplify-61 [=>]28.7

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

      rational.json-simplify-60 [=>]28.7

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

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

    if -inf.0 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < -5.00000000000000013e-301 or 0.0 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < 2.00000000000000003e263

    1. Initial program 0.8

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified0.4

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

      [Start]0.8

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

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

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

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

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

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

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

      rational.json-simplify-54 [=>]17.7

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

      rational.json-simplify-61 [=>]22.4

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

      rational.json-simplify-61 [=>]15.0

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

      rational.json-simplify-61 [=>]0.4

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

      rational.json-simplify-60 [=>]0.4

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

    if -5.00000000000000013e-301 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < 0.0 or 2.00000000000000003e263 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t))

    1. Initial program 26.3

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified15.3

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

      [Start]26.3

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

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

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

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

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

      rational.json-simplify-49 [<=]26.3

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

      rational.json-simplify-2 [<=]26.3

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

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

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

      rational.json-simplify-47 [=>]15.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq -\infty:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq -5 \cdot 10^{-301}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq 0:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq 2 \cdot 10^{+263}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array} \]

Alternatives

Alternative 1
Error1.9
Cost1100
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := y \cdot \frac{x}{z}\\ \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{-284}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{-224}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{+206}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error1.8
Cost1100
\[\begin{array}{l} t_1 := y \cdot \frac{x}{z}\\ \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{-284}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{-283}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{+236}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error2.1
Cost1100
\[\begin{array}{l} t_1 := \frac{y}{\frac{z}{x}}\\ \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{-203}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{y}{z} \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{+282}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error6.4
Cost320
\[x \cdot \frac{y}{z} \]

Error

Reproduce?

herbie shell --seed 2023074 
(FPCore (x y z t)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
  :precision binary64

  :herbie-target
  (if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))

  (* x (/ (* (/ y z) t) t)))