Average Error: 33.9 → 0.4
Time: 8.6s
Precision: binary64
Cost: 960
\[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
\[\frac{\frac{x}{y}}{\frac{y}{x}} + \frac{z}{t} \cdot \frac{z}{t} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
(FPCore (x y z t)
 :precision binary64
 (+ (/ (/ x y) (/ y x)) (* (/ z t) (/ z t))))
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) {
	return ((x / y) / (y / x)) + ((z / t) * (z / t));
}
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
    code = ((x / y) / (y / x)) + ((z / t) * (z / t))
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) {
	return ((x / y) / (y / x)) + ((z / t) * (z / t));
}
def code(x, y, z, t):
	return ((x * x) / (y * y)) + ((z * z) / (t * t))
def code(x, y, z, t):
	return ((x / y) / (y / x)) + ((z / t) * (z / t))
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)
	return Float64(Float64(Float64(x / y) / Float64(y / x)) + Float64(Float64(z / t) * Float64(z / t)))
end
function tmp = code(x, y, z, t)
	tmp = ((x * x) / (y * y)) + ((z * z) / (t * t));
end
function tmp = code(x, y, z, t)
	tmp = ((x / y) / (y / x)) + ((z / t) * (z / t));
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_] := N[(N[(N[(x / y), $MachinePrecision] / N[(y / x), $MachinePrecision]), $MachinePrecision] + N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\frac{\frac{x}{y}}{\frac{y}{x}} + \frac{z}{t} \cdot \frac{z}{t}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 33.9

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

    \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y} + \frac{z}{t} \cdot \frac{z}{t}} \]
    Proof
    (+.f64 (*.f64 (/.f64 x y) (/.f64 x y)) (*.f64 (/.f64 z t) (/.f64 z t))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= times-frac_binary64 (/.f64 (*.f64 x x) (*.f64 y y))) (*.f64 (/.f64 z t) (/.f64 z t))): 77 points increase in error, 15 points decrease in error
    (+.f64 (/.f64 (*.f64 x x) (*.f64 y y)) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 z z) (*.f64 t t)))): 62 points increase in error, 6 points decrease in error
  3. Applied egg-rr0.4

    \[\leadsto \color{blue}{\frac{\frac{x}{y}}{\frac{y}{x}}} + \frac{z}{t} \cdot \frac{z}{t} \]
  4. Final simplification0.4

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

Alternatives

Alternative 1
Error14.2
Cost964
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 2 \cdot 10^{-119}:\\ \;\;\;\;z \cdot \frac{\frac{z}{t}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\ \end{array} \]
Alternative 2
Error14.1
Cost964
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 2 \cdot 10^{-193}:\\ \;\;\;\;\frac{z \cdot \frac{z}{t}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{y} \cdot \frac{x}{y}\\ \end{array} \]
Alternative 3
Error14.1
Cost964
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 2 \cdot 10^{-193}:\\ \;\;\;\;\frac{z \cdot \frac{z}{t}}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{y}{x}}\\ \end{array} \]
Alternative 4
Error11.6
Cost964
\[\begin{array}{l} \mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 2 \cdot 10^{-119}:\\ \;\;\;\;\frac{\frac{z}{t}}{\frac{t}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{y}}{\frac{y}{x}}\\ \end{array} \]
Alternative 5
Error0.4
Cost960
\[\frac{z}{t} \cdot \frac{z}{t} + \frac{x}{y} \cdot \frac{x}{y} \]
Alternative 6
Error0.4
Cost960
\[\frac{x}{y} \cdot \frac{x}{y} + \frac{\frac{z}{t}}{\frac{t}{z}} \]
Alternative 7
Error37.6
Cost448
\[z \cdot \frac{z}{t \cdot t} \]
Alternative 8
Error30.2
Cost448
\[z \cdot \frac{\frac{z}{t}}{t} \]

Error

Reproduce

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