Average Error: 33.3 → 1.5
Time: 16.2s
Precision: binary64
Cost: 7564
\[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
\[\begin{array}{l} t_1 := \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t \cdot \frac{t}{z}}\\ t_2 := \frac{z \cdot \frac{z}{t}}{t} + \frac{\frac{x}{y}}{\frac{y}{x}}\\ \mathbf{if}\;t \leq -6.198516607574852 \cdot 10^{+250}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -2 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{-161}:\\ \;\;\;\;{\left(\frac{z}{t}\right)}^{2} + x \cdot \frac{\frac{x}{y}}{y}\\ \mathbf{elif}\;t \leq 2.704629184144483 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (+ (* (/ x y) (/ x y)) (/ z (* t (/ t z)))))
        (t_2 (+ (/ (* z (/ z t)) t) (/ (/ x y) (/ y x)))))
   (if (<= t -6.198516607574852e+250)
     t_2
     (if (<= t -2e-212)
       t_1
       (if (<= t 1e-161)
         (+ (pow (/ z t) 2.0) (* x (/ (/ x y) y)))
         (if (<= t 2.704629184144483e+172) t_1 t_2))))))
double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
double code(double x, double y, double z, double t) {
	double t_1 = ((x / y) * (x / y)) + (z / (t * (t / z)));
	double t_2 = ((z * (z / t)) / t) + ((x / y) / (y / x));
	double tmp;
	if (t <= -6.198516607574852e+250) {
		tmp = t_2;
	} else if (t <= -2e-212) {
		tmp = t_1;
	} else if (t <= 1e-161) {
		tmp = pow((z / t), 2.0) + (x * ((x / y) / y));
	} else if (t <= 2.704629184144483e+172) {
		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 * x) / (y * y)) + ((z * 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) * (x / y)) + (z / (t * (t / z)))
    t_2 = ((z * (z / t)) / t) + ((x / y) / (y / x))
    if (t <= (-6.198516607574852d+250)) then
        tmp = t_2
    else if (t <= (-2d-212)) then
        tmp = t_1
    else if (t <= 1d-161) then
        tmp = ((z / t) ** 2.0d0) + (x * ((x / y) / y))
    else if (t <= 2.704629184144483d+172) 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 * x) / (y * y)) + ((z * z) / (t * t));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = ((x / y) * (x / y)) + (z / (t * (t / z)));
	double t_2 = ((z * (z / t)) / t) + ((x / y) / (y / x));
	double tmp;
	if (t <= -6.198516607574852e+250) {
		tmp = t_2;
	} else if (t <= -2e-212) {
		tmp = t_1;
	} else if (t <= 1e-161) {
		tmp = Math.pow((z / t), 2.0) + (x * ((x / y) / y));
	} else if (t <= 2.704629184144483e+172) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t):
	return ((x * x) / (y * y)) + ((z * z) / (t * t))
def code(x, y, z, t):
	t_1 = ((x / y) * (x / y)) + (z / (t * (t / z)))
	t_2 = ((z * (z / t)) / t) + ((x / y) / (y / x))
	tmp = 0
	if t <= -6.198516607574852e+250:
		tmp = t_2
	elif t <= -2e-212:
		tmp = t_1
	elif t <= 1e-161:
		tmp = math.pow((z / t), 2.0) + (x * ((x / y) / y))
	elif t <= 2.704629184144483e+172:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t)
	return Float64(Float64(Float64(x * x) / Float64(y * y)) + Float64(Float64(z * z) / Float64(t * t)))
end
function code(x, y, z, t)
	t_1 = Float64(Float64(Float64(x / y) * Float64(x / y)) + Float64(z / Float64(t * Float64(t / z))))
	t_2 = Float64(Float64(Float64(z * Float64(z / t)) / t) + Float64(Float64(x / y) / Float64(y / x)))
	tmp = 0.0
	if (t <= -6.198516607574852e+250)
		tmp = t_2;
	elseif (t <= -2e-212)
		tmp = t_1;
	elseif (t <= 1e-161)
		tmp = Float64((Float64(z / t) ^ 2.0) + Float64(x * Float64(Float64(x / y) / y)));
	elseif (t <= 2.704629184144483e+172)
		tmp = t_1;
	else
		tmp = t_2;
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = ((x * x) / (y * y)) + ((z * z) / (t * t));
end
function tmp_2 = code(x, y, z, t)
	t_1 = ((x / y) * (x / y)) + (z / (t * (t / z)));
	t_2 = ((z * (z / t)) / t) + ((x / y) / (y / x));
	tmp = 0.0;
	if (t <= -6.198516607574852e+250)
		tmp = t_2;
	elseif (t <= -2e-212)
		tmp = t_1;
	elseif (t <= 1e-161)
		tmp = ((z / t) ^ 2.0) + (x * ((x / y) / y));
	elseif (t <= 2.704629184144483e+172)
		tmp = t_1;
	else
		tmp = t_2;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_] := N[(N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + N[(z / N[(t * N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z * N[(z / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -6.198516607574852e+250], t$95$2, If[LessEqual[t, -2e-212], t$95$1, If[LessEqual[t, 1e-161], N[(N[Power[N[(z / t), $MachinePrecision], 2.0], $MachinePrecision] + N[(x * N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.704629184144483e+172], t$95$1, t$95$2]]]]]]
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\begin{array}{l}
t_1 := \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t \cdot \frac{t}{z}}\\
t_2 := \frac{z \cdot \frac{z}{t}}{t} + \frac{\frac{x}{y}}{\frac{y}{x}}\\
\mathbf{if}\;t \leq -6.198516607574852 \cdot 10^{+250}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;t \leq -2 \cdot 10^{-212}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t \leq 10^{-161}:\\
\;\;\;\;{\left(\frac{z}{t}\right)}^{2} + x \cdot \frac{\frac{x}{y}}{y}\\

\mathbf{elif}\;t \leq 2.704629184144483 \cdot 10^{+172}:\\
\;\;\;\;t_1\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original33.3
Target0.4
Herbie1.5
\[{\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2} \]

Derivation

  1. Split input into 3 regimes
  2. if t < -6.1985166075748523e250 or 2.704629184144483e172 < t

    1. Initial program 34.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{x}{y \cdot y}, \frac{z}{\frac{t \cdot t}{z}}\right)} \]
      Proof
      (fma.f64 x (/.f64 x (*.f64 y y)) (/.f64 z (/.f64 (*.f64 t t) z))): 0 points increase in error, 0 points decrease in error
      (fma.f64 x (/.f64 x (*.f64 y y)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z z) (*.f64 t t)))): 55 points increase in error, 12 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (/.f64 x (*.f64 y y))) (/.f64 (*.f64 z z) (*.f64 t t)))): 1 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x x) (*.f64 y y))) (/.f64 (*.f64 z z) (*.f64 t t))): 39 points increase in error, 5 points decrease in error
    3. Applied egg-rr5.3

      \[\leadsto \color{blue}{{\left(\frac{z}{t}\right)}^{2} + x \cdot \frac{\frac{x}{y}}{y}} \]
    4. Applied egg-rr7.4

      \[\leadsto \color{blue}{\frac{\frac{z}{t} \cdot z}{t}} + x \cdot \frac{\frac{x}{y}}{y} \]
    5. Applied egg-rr2.5

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

    if -6.1985166075748523e250 < t < -1.99999999999999991e-212 or 1.00000000000000003e-161 < t < 2.704629184144483e172

    1. Initial program 28.6

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

      \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    3. Simplified19.2

      \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z}{t \cdot \frac{t}{z}}} \]
      Proof
      (/.f64 z (*.f64 t (/.f64 t z))): 0 points increase in error, 0 points decrease in error
      (/.f64 z (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 t t) z))): 56 points increase in error, 8 points decrease in error
      (/.f64 z (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 t 2)) z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z z) (pow.f64 t 2))): 64 points increase in error, 21 points decrease in error
      (/.f64 (Rewrite<= unpow2_binary64 (pow.f64 z 2)) (pow.f64 t 2)): 1 points increase in error, 0 points decrease in error
    4. Applied egg-rr1.0

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

    if -1.99999999999999991e-212 < t < 1.00000000000000003e-161

    1. Initial program 63.9

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Simplified63.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{x}{y \cdot y}, \frac{z}{\frac{t \cdot t}{z}}\right)} \]
      Proof
      (fma.f64 x (/.f64 x (*.f64 y y)) (/.f64 z (/.f64 (*.f64 t t) z))): 0 points increase in error, 0 points decrease in error
      (fma.f64 x (/.f64 x (*.f64 y y)) (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 z z) (*.f64 t t)))): 55 points increase in error, 12 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x (/.f64 x (*.f64 y y))) (/.f64 (*.f64 z z) (*.f64 t t)))): 1 points increase in error, 0 points decrease in error
      (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 x x) (*.f64 y y))) (/.f64 (*.f64 z z) (*.f64 t t))): 39 points increase in error, 5 points decrease in error
    3. Applied egg-rr2.7

      \[\leadsto \color{blue}{{\left(\frac{z}{t}\right)}^{2} + x \cdot \frac{\frac{x}{y}}{y}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -6.198516607574852 \cdot 10^{+250}:\\ \;\;\;\;\frac{z \cdot \frac{z}{t}}{t} + \frac{\frac{x}{y}}{\frac{y}{x}}\\ \mathbf{elif}\;t \leq -2 \cdot 10^{-212}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t \cdot \frac{t}{z}}\\ \mathbf{elif}\;t \leq 10^{-161}:\\ \;\;\;\;{\left(\frac{z}{t}\right)}^{2} + x \cdot \frac{\frac{x}{y}}{y}\\ \mathbf{elif}\;t \leq 2.704629184144483 \cdot 10^{+172}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t \cdot \frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \frac{z}{t}}{t} + \frac{\frac{x}{y}}{\frac{y}{x}}\\ \end{array} \]

Alternatives

Alternative 1
Error24.9
Cost2008
\[\begin{array}{l} t_1 := \frac{\frac{z \cdot z}{t}}{t}\\ t_2 := \frac{\frac{x}{y}}{\frac{y}{x}}\\ \mathbf{if}\;z \cdot z \leq 2.9301005185928046 \cdot 10^{-230}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \cdot z \leq 1.6557389782555157 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot z \leq 3.122381867287253 \cdot 10^{-133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \cdot z \leq 92000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot z \leq 4.5 \cdot 10^{+128}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \cdot z \leq 1.2 \cdot 10^{+300}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error1.7
Cost1488
\[\begin{array}{l} t_1 := \frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t \cdot \frac{t}{z}}\\ t_2 := \frac{z \cdot \frac{z}{t}}{t} + \frac{\frac{x}{y}}{\frac{y}{x}}\\ \mathbf{if}\;t \leq -6.198516607574852 \cdot 10^{+250}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1 \cdot 10^{-154}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{-170}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.704629184144483 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error3.6
Cost1092
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \cdot 10^{+250}:\\ \;\;\;\;\frac{\frac{z}{t}}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{z \cdot \frac{z}{t}}{t} + \frac{\frac{x}{y}}{\frac{y}{x}}\\ \end{array} \]
Alternative 4
Error10.8
Cost964
\[\begin{array}{l} \mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 2 \cdot 10^{-181}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{y}{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z}{t}}{\frac{t}{z}}\\ \end{array} \]
Alternative 5
Error26.7
Cost448
\[\frac{\frac{x}{y}}{\frac{y}{x}} \]

Error

Reproduce

herbie shell --seed 2022316 
(FPCore (x y z t)
  :name "Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1"
  :precision binary64

  :herbie-target
  (+ (pow (/ x y) 2.0) (pow (/ z t) 2.0))

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