?

Average Error: 15.0 → 4.3
Time: 6.3s
Precision: binary64
Cost: 2252

?

\[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
\[\begin{array}{l} t_1 := x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ t_2 := \frac{y \cdot x}{z}\\ \mathbf{if}\;t_1 \leq -3 \cdot 10^{+287}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq -1 \cdot 10^{-196}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;t_1 \leq 10^{-56}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \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) t))) (t_2 (/ (* y x) z)))
   (if (<= t_1 -3e+287)
     t_2
     (if (<= t_1 -1e-196)
       (/ x (/ z y))
       (if (<= t_1 1e-56) t_2 (/ y (/ z x)))))))
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) * t) / t);
	double t_2 = (y * x) / z;
	double tmp;
	if (t_1 <= -3e+287) {
		tmp = t_2;
	} else if (t_1 <= -1e-196) {
		tmp = x / (z / y);
	} else if (t_1 <= 1e-56) {
		tmp = t_2;
	} else {
		tmp = y / (z / x);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x * (((y / z) * t) / t)
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_1 = x * (((y / z) * t) / t)
    t_2 = (y * x) / z
    if (t_1 <= (-3d+287)) then
        tmp = t_2
    else if (t_1 <= (-1d-196)) then
        tmp = x / (z / y)
    else if (t_1 <= 1d-56) then
        tmp = t_2
    else
        tmp = y / (z / x)
    end if
    code = tmp
end function
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) * t) / t);
	double t_2 = (y * x) / z;
	double tmp;
	if (t_1 <= -3e+287) {
		tmp = t_2;
	} else if (t_1 <= -1e-196) {
		tmp = x / (z / y);
	} else if (t_1 <= 1e-56) {
		tmp = t_2;
	} else {
		tmp = y / (z / x);
	}
	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) / t)
	t_2 = (y * x) / z
	tmp = 0
	if t_1 <= -3e+287:
		tmp = t_2
	elif t_1 <= -1e-196:
		tmp = x / (z / y)
	elif t_1 <= 1e-56:
		tmp = t_2
	else:
		tmp = y / (z / x)
	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(Float64(Float64(y / z) * t) / t))
	t_2 = Float64(Float64(y * x) / z)
	tmp = 0.0
	if (t_1 <= -3e+287)
		tmp = t_2;
	elseif (t_1 <= -1e-196)
		tmp = Float64(x / Float64(z / y));
	elseif (t_1 <= 1e-56)
		tmp = t_2;
	else
		tmp = Float64(y / Float64(z / x));
	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) / t);
	t_2 = (y * x) / z;
	tmp = 0.0;
	if (t_1 <= -3e+287)
		tmp = t_2;
	elseif (t_1 <= -1e-196)
		tmp = x / (z / y);
	elseif (t_1 <= 1e-56)
		tmp = t_2;
	else
		tmp = y / (z / x);
	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[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[t$95$1, -3e+287], t$95$2, If[LessEqual[t$95$1, -1e-196], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-56], t$95$2, N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := x \cdot \frac{\frac{y}{z} \cdot t}{t}\\
t_2 := \frac{y \cdot x}{z}\\
\mathbf{if}\;t_1 \leq -3 \cdot 10^{+287}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t_1 \leq -1 \cdot 10^{-196}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\

\mathbf{elif}\;t_1 \leq 10^{-56}:\\
\;\;\;\;t_2\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.0
Target1.5
Herbie4.3
\[\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)) < -2.9999999999999999e287 or -1e-196 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < 1e-56

    1. Initial program 19.9

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Simplified8.1

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

      [Start]19.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.9999999999999999e287 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t)) < -1e-196

    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.6

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

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

      \[ 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}} \]
    3. Applied egg-rr0.6

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

    if 1e-56 < (*.f64 x (/.f64 (*.f64 (/.f64 y z) t) t))

    1. Initial program 17.9

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

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

      [Start]17.9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq -3 \cdot 10^{+287}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq -1 \cdot 10^{-196}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;x \cdot \frac{\frac{y}{z} \cdot t}{t} \leq 10^{-56}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error2.4
Cost1100
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := y \cdot \frac{x}{z}\\ \mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{-281}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{-244}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{+120}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error2.2
Cost1100
\[\begin{array}{l} t_1 := y \cdot \frac{x}{z}\\ \mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{-281}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 2 \cdot 10^{-244}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{+120}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error2.3
Cost1100
\[\begin{array}{l} t_1 := \frac{y}{\frac{z}{x}}\\ \mathbf{if}\;\frac{y}{z} \leq -1 \cdot 10^{-255}:\\ \;\;\;\;\frac{x}{\frac{z}{y}}\\ \mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 10^{+120}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error6.2
Cost320
\[x \cdot \frac{y}{z} \]

Error

Reproduce?

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