Average Error: 14.6 → 0.5
Time: 17.5s
Precision: binary64
Cost: 1360
\[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
\[\begin{array}{l} t_1 := x \cdot \frac{y}{z}\\ t_2 := \frac{x}{z} \cdot y\\ \mathbf{if}\;\frac{y}{z} \leq -4 \cdot 10^{+237}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{-268}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{+290}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \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 z) y)))
   (if (<= (/ y z) -4e+237)
     t_2
     (if (<= (/ y z) -2e-145)
       t_1
       (if (<= (/ y z) 5e-268) t_2 (if (<= (/ y z) 5e+290) t_1 t_2))))))
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 / z) * y;
	double tmp;
	if ((y / z) <= -4e+237) {
		tmp = t_2;
	} else if ((y / z) <= -2e-145) {
		tmp = t_1;
	} else if ((y / z) <= 5e-268) {
		tmp = t_2;
	} else if ((y / z) <= 5e+290) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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_2 = (x / z) * y
    if ((y / z) <= (-4d+237)) then
        tmp = t_2
    else if ((y / z) <= (-2d-145)) then
        tmp = t_1
    else if ((y / z) <= 5d-268) then
        tmp = t_2
    else if ((y / z) <= 5d+290) then
        tmp = t_1
    else
        tmp = t_2
    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);
	double t_2 = (x / z) * y;
	double tmp;
	if ((y / z) <= -4e+237) {
		tmp = t_2;
	} else if ((y / z) <= -2e-145) {
		tmp = t_1;
	} else if ((y / z) <= 5e-268) {
		tmp = t_2;
	} else if ((y / z) <= 5e+290) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	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 / z) * y
	tmp = 0
	if (y / z) <= -4e+237:
		tmp = t_2
	elif (y / z) <= -2e-145:
		tmp = t_1
	elif (y / z) <= 5e-268:
		tmp = t_2
	elif (y / z) <= 5e+290:
		tmp = t_1
	else:
		tmp = t_2
	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(Float64(x / z) * y)
	tmp = 0.0
	if (Float64(y / z) <= -4e+237)
		tmp = t_2;
	elseif (Float64(y / z) <= -2e-145)
		tmp = t_1;
	elseif (Float64(y / z) <= 5e-268)
		tmp = t_2;
	elseif (Float64(y / z) <= 5e+290)
		tmp = t_1;
	else
		tmp = t_2;
	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 / z) * y;
	tmp = 0.0;
	if ((y / z) <= -4e+237)
		tmp = t_2;
	elseif ((y / z) <= -2e-145)
		tmp = t_1;
	elseif ((y / z) <= 5e-268)
		tmp = t_2;
	elseif ((y / z) <= 5e+290)
		tmp = t_1;
	else
		tmp = t_2;
	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[(N[(x / z), $MachinePrecision] * y), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -4e+237], t$95$2, If[LessEqual[N[(y / z), $MachinePrecision], -2e-145], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], 5e-268], t$95$2, If[LessEqual[N[(y / z), $MachinePrecision], 5e+290], t$95$1, t$95$2]]]]]]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
t_1 := x \cdot \frac{y}{z}\\
t_2 := \frac{x}{z} \cdot y\\
\mathbf{if}\;\frac{y}{z} \leq -4 \cdot 10^{+237}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{y}{z} \leq -2 \cdot 10^{-145}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{-268}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{+290}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original14.6
Target1.5
Herbie0.5
\[\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 2 regimes
  2. if (/.f64 y z) < -3.99999999999999976e237 or -1.99999999999999983e-145 < (/.f64 y z) < 4.9999999999999999e-268 or 4.9999999999999998e290 < (/.f64 y z)

    1. Initial program 25.0

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in x around 0 0.7

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}} \]
    3. Applied egg-rr0.9

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

    if -3.99999999999999976e237 < (/.f64 y z) < -1.99999999999999983e-145 or 4.9999999999999999e-268 < (/.f64 y z) < 4.9999999999999998e290

    1. Initial program 9.0

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t} \]
    2. Taylor expanded in y around 0 0.2

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

Alternatives

Alternative 1
Error2.7
Cost2252
\[\begin{array}{l} t_1 := \frac{y \cdot x}{z}\\ t_2 := x \cdot \frac{y}{z}\\ t_3 := x \cdot \frac{\frac{y}{z} \cdot t}{t}\\ \mathbf{if}\;t_3 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_3 \leq -2 \cdot 10^{-312}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_3 \leq 2 \cdot 10^{-237}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error6.5
Cost320
\[x \cdot \frac{y}{z} \]

Error

Reproduce

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