Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1

Percentage Accurate: 67.3% → 97.3%
Time: 12.9s
Alternatives: 8
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * 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
public static double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
def code(x, y, z, t):
	return ((x * x) / (y * y)) + ((z * z) / (t * 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 tmp = code(x, y, z, t)
	tmp = ((x * x) / (y * y)) + ((z * z) / (t * 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]
\begin{array}{l}

\\
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 67.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))
double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * 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
public static double code(double x, double y, double z, double t) {
	return ((x * x) / (y * y)) + ((z * z) / (t * t));
}
def code(x, y, z, t):
	return ((x * x) / (y * y)) + ((z * z) / (t * 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 tmp = code(x, y, z, t)
	tmp = ((x * x) / (y * y)) + ((z * z) / (t * 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]
\begin{array}{l}

\\
\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}
\end{array}

Alternative 1: 97.3% accurate, 0.7× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} t_1 := \frac{\frac{z}{t}}{\frac{t}{z}}\\ \mathbf{if}\;x\_m \leq 4.2 \cdot 10^{-271}:\\ \;\;\;\;\frac{x\_m}{\frac{y}{\frac{x\_m}{y}}} + t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x\_m}{\frac{y}{x\_m}}}{y} + t\_1\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (let* ((t_1 (/ (/ z t) (/ t z))))
   (if (<= x_m 4.2e-271)
     (+ (/ x_m (/ y (/ x_m y))) t_1)
     (+ (/ (/ x_m (/ y x_m)) y) t_1))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double t_1 = (z / t) / (t / z);
	double tmp;
	if (x_m <= 4.2e-271) {
		tmp = (x_m / (y / (x_m / y))) + t_1;
	} else {
		tmp = ((x_m / (y / x_m)) / y) + t_1;
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (z / t) / (t / z)
    if (x_m <= 4.2d-271) then
        tmp = (x_m / (y / (x_m / y))) + t_1
    else
        tmp = ((x_m / (y / x_m)) / y) + t_1
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double t_1 = (z / t) / (t / z);
	double tmp;
	if (x_m <= 4.2e-271) {
		tmp = (x_m / (y / (x_m / y))) + t_1;
	} else {
		tmp = ((x_m / (y / x_m)) / y) + t_1;
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	t_1 = (z / t) / (t / z)
	tmp = 0
	if x_m <= 4.2e-271:
		tmp = (x_m / (y / (x_m / y))) + t_1
	else:
		tmp = ((x_m / (y / x_m)) / y) + t_1
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	t_1 = Float64(Float64(z / t) / Float64(t / z))
	tmp = 0.0
	if (x_m <= 4.2e-271)
		tmp = Float64(Float64(x_m / Float64(y / Float64(x_m / y))) + t_1);
	else
		tmp = Float64(Float64(Float64(x_m / Float64(y / x_m)) / y) + t_1);
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	t_1 = (z / t) / (t / z);
	tmp = 0.0;
	if (x_m <= 4.2e-271)
		tmp = (x_m / (y / (x_m / y))) + t_1;
	else
		tmp = ((x_m / (y / x_m)) / y) + t_1;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z / t), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x$95$m, 4.2e-271], N[(N[(x$95$m / N[(y / N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(N[(x$95$m / N[(y / x$95$m), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + t$95$1), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
t_1 := \frac{\frac{z}{t}}{\frac{t}{z}}\\
\mathbf{if}\;x\_m \leq 4.2 \cdot 10^{-271}:\\
\;\;\;\;\frac{x\_m}{\frac{y}{\frac{x\_m}{y}}} + t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x\_m}{\frac{y}{x\_m}}}{y} + t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.2000000000000001e-271

    1. Initial program 66.4%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]

    if 4.2000000000000001e-271 < x

    1. Initial program 80.8%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]
    5. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 73.7% accurate, 0.6× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;z \leq 1.6 \cdot 10^{-132}:\\ \;\;\;\;\frac{x\_m}{y} \cdot \frac{x\_m}{y}\\ \mathbf{elif}\;z \leq 7.5 \cdot 10^{+157}:\\ \;\;\;\;x\_m \cdot \frac{\frac{x\_m}{y}}{y} + \frac{z \cdot z}{t \cdot t}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{-\frac{t}{z} \cdot \left(0 - t\right)}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= z 1.6e-132)
   (* (/ x_m y) (/ x_m y))
   (if (<= z 7.5e+157)
     (+ (* x_m (/ (/ x_m y) y)) (/ (* z z) (* t t)))
     (/ z (- (* (/ t z) (- 0.0 t)))))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (z <= 1.6e-132) {
		tmp = (x_m / y) * (x_m / y);
	} else if (z <= 7.5e+157) {
		tmp = (x_m * ((x_m / y) / y)) + ((z * z) / (t * t));
	} else {
		tmp = z / -((t / z) * (0.0 - t));
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= 1.6d-132) then
        tmp = (x_m / y) * (x_m / y)
    else if (z <= 7.5d+157) then
        tmp = (x_m * ((x_m / y) / y)) + ((z * z) / (t * t))
    else
        tmp = z / -((t / z) * (0.0d0 - t))
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if (z <= 1.6e-132) {
		tmp = (x_m / y) * (x_m / y);
	} else if (z <= 7.5e+157) {
		tmp = (x_m * ((x_m / y) / y)) + ((z * z) / (t * t));
	} else {
		tmp = z / -((t / z) * (0.0 - t));
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if z <= 1.6e-132:
		tmp = (x_m / y) * (x_m / y)
	elif z <= 7.5e+157:
		tmp = (x_m * ((x_m / y) / y)) + ((z * z) / (t * t))
	else:
		tmp = z / -((t / z) * (0.0 - t))
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (z <= 1.6e-132)
		tmp = Float64(Float64(x_m / y) * Float64(x_m / y));
	elseif (z <= 7.5e+157)
		tmp = Float64(Float64(x_m * Float64(Float64(x_m / y) / y)) + Float64(Float64(z * z) / Float64(t * t)));
	else
		tmp = Float64(z / Float64(-Float64(Float64(t / z) * Float64(0.0 - t))));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if (z <= 1.6e-132)
		tmp = (x_m / y) * (x_m / y);
	elseif (z <= 7.5e+157)
		tmp = (x_m * ((x_m / y) / y)) + ((z * z) / (t * t));
	else
		tmp = z / -((t / z) * (0.0 - t));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 1.6e-132], N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.5e+157], N[(N[(x$95$m * N[(N[(x$95$m / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z / (-N[(N[(t / z), $MachinePrecision] * N[(0.0 - t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.6 \cdot 10^{-132}:\\
\;\;\;\;\frac{x\_m}{y} \cdot \frac{x\_m}{y}\\

\mathbf{elif}\;z \leq 7.5 \cdot 10^{+157}:\\
\;\;\;\;x\_m \cdot \frac{\frac{x\_m}{y}}{y} + \frac{z \cdot z}{t \cdot t}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{-\frac{t}{z} \cdot \left(0 - t\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < 1.6000000000000001e-132

    1. Initial program 69.6%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if 1.6000000000000001e-132 < z < 7.5e157

    1. Initial program 81.5%

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

      \[\leadsto expr\]
    3. Add Preprocessing

    if 7.5e157 < z

    1. Initial program 66.9%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 93.8% accurate, 0.7× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;z \leq 5.6 \cdot 10^{+224}:\\ \;\;\;\;x\_m \cdot \frac{\frac{x\_m}{y}}{y} + \frac{\frac{z}{t} \cdot z}{t}\\ \mathbf{else}:\\ \;\;\;\;\frac{z}{-\frac{t}{z} \cdot \left(0 - t\right)}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= z 5.6e+224)
   (+ (* x_m (/ (/ x_m y) y)) (/ (* (/ z t) z) t))
   (/ z (- (* (/ t z) (- 0.0 t))))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (z <= 5.6e+224) {
		tmp = (x_m * ((x_m / y) / y)) + (((z / t) * z) / t);
	} else {
		tmp = z / -((t / z) * (0.0 - t));
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (z <= 5.6d+224) then
        tmp = (x_m * ((x_m / y) / y)) + (((z / t) * z) / t)
    else
        tmp = z / -((t / z) * (0.0d0 - t))
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if (z <= 5.6e+224) {
		tmp = (x_m * ((x_m / y) / y)) + (((z / t) * z) / t);
	} else {
		tmp = z / -((t / z) * (0.0 - t));
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if z <= 5.6e+224:
		tmp = (x_m * ((x_m / y) / y)) + (((z / t) * z) / t)
	else:
		tmp = z / -((t / z) * (0.0 - t))
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (z <= 5.6e+224)
		tmp = Float64(Float64(x_m * Float64(Float64(x_m / y) / y)) + Float64(Float64(Float64(z / t) * z) / t));
	else
		tmp = Float64(z / Float64(-Float64(Float64(t / z) * Float64(0.0 - t))));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if (z <= 5.6e+224)
		tmp = (x_m * ((x_m / y) / y)) + (((z / t) * z) / t);
	else
		tmp = z / -((t / z) * (0.0 - t));
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[z, 5.6e+224], N[(N[(x$95$m * N[(N[(x$95$m / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(z / t), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], N[(z / (-N[(N[(t / z), $MachinePrecision] * N[(0.0 - t), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;z \leq 5.6 \cdot 10^{+224}:\\
\;\;\;\;x\_m \cdot \frac{\frac{x\_m}{y}}{y} + \frac{\frac{z}{t} \cdot z}{t}\\

\mathbf{else}:\\
\;\;\;\;\frac{z}{-\frac{t}{z} \cdot \left(0 - t\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < 5.60000000000000016e224

    1. Initial program 72.2%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Applied egg-rr0

      \[\leadsto expr\]

    if 5.60000000000000016e224 < z

    1. Initial program 71.1%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 82.2% accurate, 0.8× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 20000:\\ \;\;\;\;\frac{\frac{x\_m}{y}}{\frac{y}{x\_m}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z}{t}}{t} \cdot z\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= (/ (* z z) (* t t)) 20000.0)
   (/ (/ x_m y) (/ y x_m))
   (* (/ (/ z t) t) z)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (((z * z) / (t * t)) <= 20000.0) {
		tmp = (x_m / y) / (y / x_m);
	} else {
		tmp = ((z / t) / t) * z;
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (((z * z) / (t * t)) <= 20000.0d0) then
        tmp = (x_m / y) / (y / x_m)
    else
        tmp = ((z / t) / t) * z
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if (((z * z) / (t * t)) <= 20000.0) {
		tmp = (x_m / y) / (y / x_m);
	} else {
		tmp = ((z / t) / t) * z;
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if ((z * z) / (t * t)) <= 20000.0:
		tmp = (x_m / y) / (y / x_m)
	else:
		tmp = ((z / t) / t) * z
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (Float64(Float64(z * z) / Float64(t * t)) <= 20000.0)
		tmp = Float64(Float64(x_m / y) / Float64(y / x_m));
	else
		tmp = Float64(Float64(Float64(z / t) / t) * z);
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if (((z * z) / (t * t)) <= 20000.0)
		tmp = (x_m / y) / (y / x_m);
	else
		tmp = ((z / t) / t) * z;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 20000.0], N[(N[(x$95$m / y), $MachinePrecision] / N[(y / x$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z / t), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 20000:\\
\;\;\;\;\frac{\frac{x\_m}{y}}{\frac{y}{x\_m}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{z}{t}}{t} \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 2e4

    1. Initial program 74.5%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if 2e4 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 70.3%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 82.1% accurate, 0.8× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 20000:\\ \;\;\;\;\frac{x\_m}{y} \cdot \frac{x\_m}{y}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{z}{t}}{t} \cdot z\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= (/ (* z z) (* t t)) 20000.0)
   (* (/ x_m y) (/ x_m y))
   (* (/ (/ z t) t) z)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if (((z * z) / (t * t)) <= 20000.0) {
		tmp = (x_m / y) * (x_m / y);
	} else {
		tmp = ((z / t) / t) * z;
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if (((z * z) / (t * t)) <= 20000.0d0) then
        tmp = (x_m / y) * (x_m / y)
    else
        tmp = ((z / t) / t) * z
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if (((z * z) / (t * t)) <= 20000.0) {
		tmp = (x_m / y) * (x_m / y);
	} else {
		tmp = ((z / t) / t) * z;
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if ((z * z) / (t * t)) <= 20000.0:
		tmp = (x_m / y) * (x_m / y)
	else:
		tmp = ((z / t) / t) * z
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (Float64(Float64(z * z) / Float64(t * t)) <= 20000.0)
		tmp = Float64(Float64(x_m / y) * Float64(x_m / y));
	else
		tmp = Float64(Float64(Float64(z / t) / t) * z);
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if (((z * z) / (t * t)) <= 20000.0)
		tmp = (x_m / y) * (x_m / y);
	else
		tmp = ((z / t) / t) * z;
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 20000.0], N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z / t), $MachinePrecision] / t), $MachinePrecision] * z), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 20000:\\
\;\;\;\;\frac{x\_m}{y} \cdot \frac{x\_m}{y}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{z}{t}}{t} \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 z z) (*.f64 t t)) < 2e4

    1. Initial program 74.5%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if 2e4 < (/.f64 (*.f64 z z) (*.f64 t t))

    1. Initial program 70.3%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
    7. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 6: 96.8% accurate, 1.0× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ x\_m \cdot \frac{\frac{x\_m}{y}}{y} + \frac{\frac{z}{t}}{\frac{t}{z}} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (+ (* x_m (/ (/ x_m y) y)) (/ (/ z t) (/ t z))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	return (x_m * ((x_m / y) / y)) + ((z / t) / (t / z));
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x_m * ((x_m / y) / y)) + ((z / t) / (t / z))
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	return (x_m * ((x_m / y) / y)) + ((z / t) / (t / z));
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	return (x_m * ((x_m / y) / y)) + ((z / t) / (t / z))
x_m = abs(x)
function code(x_m, y, z, t)
	return Float64(Float64(x_m * Float64(Float64(x_m / y) / y)) + Float64(Float64(z / t) / Float64(t / z)))
end
x_m = abs(x);
function tmp = code(x_m, y, z, t)
	tmp = (x_m * ((x_m / y) / y)) + ((z / t) / (t / z));
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := N[(N[(x$95$m * N[(N[(x$95$m / y), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(N[(z / t), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

\\
x\_m \cdot \frac{\frac{x\_m}{y}}{y} + \frac{\frac{z}{t}}{\frac{t}{z}}
\end{array}
Derivation
  1. Initial program 72.1%

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Applied egg-rr0

    \[\leadsto expr\]
  5. Add Preprocessing

Alternative 7: 72.6% accurate, 1.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \begin{array}{l} \mathbf{if}\;t \cdot t \leq 2.5 \cdot 10^{+134}:\\ \;\;\;\;\frac{z}{t \cdot t} \cdot z\\ \mathbf{else}:\\ \;\;\;\;\frac{x\_m}{y} \cdot \frac{x\_m}{y}\\ \end{array} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t)
 :precision binary64
 (if (<= (* t t) 2.5e+134) (* (/ z (* t t)) z) (* (/ x_m y) (/ x_m y))))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	double tmp;
	if ((t * t) <= 2.5e+134) {
		tmp = (z / (t * t)) * z;
	} else {
		tmp = (x_m / y) * (x_m / y);
	}
	return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: tmp
    if ((t * t) <= 2.5d+134) then
        tmp = (z / (t * t)) * z
    else
        tmp = (x_m / y) * (x_m / y)
    end if
    code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	double tmp;
	if ((t * t) <= 2.5e+134) {
		tmp = (z / (t * t)) * z;
	} else {
		tmp = (x_m / y) * (x_m / y);
	}
	return tmp;
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	tmp = 0
	if (t * t) <= 2.5e+134:
		tmp = (z / (t * t)) * z
	else:
		tmp = (x_m / y) * (x_m / y)
	return tmp
x_m = abs(x)
function code(x_m, y, z, t)
	tmp = 0.0
	if (Float64(t * t) <= 2.5e+134)
		tmp = Float64(Float64(z / Float64(t * t)) * z);
	else
		tmp = Float64(Float64(x_m / y) * Float64(x_m / y));
	end
	return tmp
end
x_m = abs(x);
function tmp_2 = code(x_m, y, z, t)
	tmp = 0.0;
	if ((t * t) <= 2.5e+134)
		tmp = (z / (t * t)) * z;
	else
		tmp = (x_m / y) * (x_m / y);
	end
	tmp_2 = tmp;
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := If[LessEqual[N[(t * t), $MachinePrecision], 2.5e+134], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision], N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|

\\
\begin{array}{l}
\mathbf{if}\;t \cdot t \leq 2.5 \cdot 10^{+134}:\\
\;\;\;\;\frac{z}{t \cdot t} \cdot z\\

\mathbf{else}:\\
\;\;\;\;\frac{x\_m}{y} \cdot \frac{x\_m}{y}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 t t) < 2.4999999999999999e134

    1. Initial program 79.3%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around 0 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]

    if 2.4999999999999999e134 < (*.f64 t t)

    1. Initial program 62.1%

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

      \[\leadsto expr\]
    3. Add Preprocessing
    4. Taylor expanded in x around inf 0

      \[\leadsto expr\]
    5. Simplified0

      \[\leadsto expr\]
    6. Applied egg-rr0

      \[\leadsto expr\]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 8: 59.7% accurate, 2.1× speedup?

\[\begin{array}{l} x_m = \left|x\right| \\ \frac{x\_m}{y} \cdot \frac{x\_m}{y} \end{array} \]
x_m = (fabs.f64 x)
(FPCore (x_m y z t) :precision binary64 (* (/ x_m y) (/ x_m y)))
x_m = fabs(x);
double code(double x_m, double y, double z, double t) {
	return (x_m / y) * (x_m / y);
}
x_m = abs(x)
real(8) function code(x_m, y, z, t)
    real(8), intent (in) :: x_m
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = (x_m / y) * (x_m / y)
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z, double t) {
	return (x_m / y) * (x_m / y);
}
x_m = math.fabs(x)
def code(x_m, y, z, t):
	return (x_m / y) * (x_m / y)
x_m = abs(x)
function code(x_m, y, z, t)
	return Float64(Float64(x_m / y) * Float64(x_m / y))
end
x_m = abs(x);
function tmp = code(x_m, y, z, t)
	tmp = (x_m / y) * (x_m / y);
end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_, t_] := N[(N[(x$95$m / y), $MachinePrecision] * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|

\\
\frac{x\_m}{y} \cdot \frac{x\_m}{y}
\end{array}
Derivation
  1. Initial program 72.1%

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

    \[\leadsto expr\]
  3. Add Preprocessing
  4. Taylor expanded in x around inf 0

    \[\leadsto expr\]
  5. Simplified0

    \[\leadsto expr\]
  6. Applied egg-rr0

    \[\leadsto expr\]
  7. Add Preprocessing

Developer Target 1: 99.7% accurate, 0.1× speedup?

\[\begin{array}{l} \\ {\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2} \end{array} \]
(FPCore (x y z t) :precision binary64 (+ (pow (/ x y) 2.0) (pow (/ z t) 2.0)))
double code(double x, double y, double z, double t) {
	return pow((x / y), 2.0) + pow((z / t), 2.0);
}
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) ** 2.0d0) + ((z / t) ** 2.0d0)
end function
public static double code(double x, double y, double z, double t) {
	return Math.pow((x / y), 2.0) + Math.pow((z / t), 2.0);
}
def code(x, y, z, t):
	return math.pow((x / y), 2.0) + math.pow((z / t), 2.0)
function code(x, y, z, t)
	return Float64((Float64(x / y) ^ 2.0) + (Float64(z / t) ^ 2.0))
end
function tmp = code(x, y, z, t)
	tmp = ((x / y) ^ 2.0) + ((z / t) ^ 2.0);
end
code[x_, y_, z_, t_] := N[(N[Power[N[(x / y), $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(z / t), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(\frac{x}{y}\right)}^{2} + {\left(\frac{z}{t}\right)}^{2}
\end{array}

Reproduce

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

  :alt
  (! :herbie-platform default (+ (pow (/ x y) 2) (pow (/ z t) 2)))

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