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

Percentage Accurate: 65.9% → 99.7%
Time: 12.1s
Alternatives: 15
Speedup: 0.8×

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 15 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: 65.9% 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: 99.7% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t} \cdot \frac{z}{t}\right) \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (fma (/ x y) (/ x y) (* (/ z t) (/ z t))))
double code(double x, double y, double z, double t) {
	return fma((x / y), (x / y), ((z / t) * (z / t)));
}
function code(x, y, z, t)
	return fma(Float64(x / y), Float64(x / y), Float64(Float64(z / t) * Float64(z / t)))
end
code[x_, y_, z_, t_] := N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t} \cdot \frac{z}{t}\right)
\end{array}
Derivation
  1. Initial program 61.4%

    \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
    2. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
    5. times-fracN/A

      \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t} \]
    6. lower-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right)} \]
    7. lower-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right) \]
    8. lower-/.f6476.7

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \color{blue}{\frac{x}{y}}, \frac{z \cdot z}{t \cdot t}\right) \]
  4. Applied rewrites76.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right)} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z \cdot z}{t \cdot t}}\right) \]
    2. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{\color{blue}{z \cdot z}}{t \cdot t}\right) \]
    3. lift-*.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{\color{blue}{t \cdot t}}\right) \]
    4. times-fracN/A

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{t} \cdot \frac{z}{t}}\right) \]
    5. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{t}} \cdot \frac{z}{t}\right) \]
    6. lift-/.f64N/A

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t} \cdot \color{blue}{\frac{z}{t}}\right) \]
    7. lower-*.f6499.6

      \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{t} \cdot \frac{z}{t}}\right) \]
  6. Applied rewrites99.6%

    \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \color{blue}{\frac{z}{t} \cdot \frac{z}{t}}\right) \]
  7. Add Preprocessing

Alternative 2: 91.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \frac{x \cdot x}{y \cdot y}\\ \mathbf{if}\;t\_1 \leq 10^{-290}:\\ \;\;\;\;\frac{\frac{z}{t}}{\frac{t}{z}}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+295}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t \cdot t}, z, x \cdot \frac{x}{y \cdot y}\right)\\ \mathbf{elif}\;t\_1 \leq \infty:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot \frac{1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right)\\ \end{array} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (/ (* x x) (* y y))))
   (if (<= t_1 1e-290)
     (/ (/ z t) (/ t z))
     (if (<= t_1 5e+295)
       (fma (/ z (* t t)) z (* x (/ x (* y y))))
       (if (<= t_1 INFINITY)
         (* (/ x y) (* x (/ 1.0 y)))
         (fma (/ x y) (/ x y) (/ (* z z) (* t t))))))))
double code(double x, double y, double z, double t) {
	double t_1 = (x * x) / (y * y);
	double tmp;
	if (t_1 <= 1e-290) {
		tmp = (z / t) / (t / z);
	} else if (t_1 <= 5e+295) {
		tmp = fma((z / (t * t)), z, (x * (x / (y * y))));
	} else if (t_1 <= ((double) INFINITY)) {
		tmp = (x / y) * (x * (1.0 / y));
	} else {
		tmp = fma((x / y), (x / y), ((z * z) / (t * t)));
	}
	return tmp;
}
function code(x, y, z, t)
	t_1 = Float64(Float64(x * x) / Float64(y * y))
	tmp = 0.0
	if (t_1 <= 1e-290)
		tmp = Float64(Float64(z / t) / Float64(t / z));
	elseif (t_1 <= 5e+295)
		tmp = fma(Float64(z / Float64(t * t)), z, Float64(x * Float64(x / Float64(y * y))));
	elseif (t_1 <= Inf)
		tmp = Float64(Float64(x / y) * Float64(x * Float64(1.0 / y)));
	else
		tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z * z) / Float64(t * t)));
	end
	return tmp
end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-290], N[(N[(z / t), $MachinePrecision] / N[(t / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+295], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z + N[(x * N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, Infinity], N[(N[(x / y), $MachinePrecision] * N[(x * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t \cdot t}, z, x \cdot \frac{x}{y \cdot y}\right)\\

\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot \frac{1}{y}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 (*.f64 x x) (*.f64 y y)) < 1.0000000000000001e-290

    1. Initial program 71.0%

      \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z \cdot z}{t \cdot t}} \]
      4. frac-addN/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot \left(t \cdot t\right) + \left(y \cdot y\right) \cdot \left(z \cdot z\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)}} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\left(x \cdot x\right) \cdot \left(t \cdot t\right) + \left(y \cdot y\right) \cdot \left(z \cdot z\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)}} \]
      6. lift-*.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x \cdot x\right)} \cdot \left(t \cdot t\right) + \left(y \cdot y\right) \cdot \left(z \cdot z\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      7. associate-*l*N/A

        \[\leadsto \frac{\color{blue}{x \cdot \left(x \cdot \left(t \cdot t\right)\right)} + \left(y \cdot y\right) \cdot \left(z \cdot z\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      8. lower-fma.f64N/A

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(y \cdot y\right) \cdot \left(z \cdot z\right)\right)}}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, \color{blue}{x \cdot \left(t \cdot t\right)}, \left(y \cdot y\right) \cdot \left(z \cdot z\right)\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      10. *-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \color{blue}{\left(z \cdot z\right) \cdot \left(y \cdot y\right)}\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      11. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(z \cdot z\right) \cdot \color{blue}{\left(y \cdot y\right)}\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      12. associate-*r*N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \color{blue}{\left(\left(z \cdot z\right) \cdot y\right) \cdot y}\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \color{blue}{\left(\left(z \cdot z\right) \cdot y\right) \cdot y}\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      14. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \color{blue}{\left(\left(z \cdot z\right) \cdot y\right)} \cdot y\right)}{\left(y \cdot y\right) \cdot \left(t \cdot t\right)} \]
      15. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{\color{blue}{\left(y \cdot y\right)} \cdot \left(t \cdot t\right)} \]
      16. lift-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{\left(y \cdot y\right) \cdot \color{blue}{\left(t \cdot t\right)}} \]
      17. unswap-sqrN/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{\color{blue}{\left(y \cdot t\right) \cdot \left(y \cdot t\right)}} \]
      18. associate-*l*N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{\color{blue}{y \cdot \left(t \cdot \left(y \cdot t\right)\right)}} \]
      19. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{\color{blue}{y \cdot \left(t \cdot \left(y \cdot t\right)\right)}} \]
      20. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{y \cdot \color{blue}{\left(t \cdot \left(y \cdot t\right)\right)}} \]
      21. lower-*.f6441.9

        \[\leadsto \frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{y \cdot \left(t \cdot \color{blue}{\left(y \cdot t\right)}\right)} \]
    4. Applied rewrites41.9%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, x \cdot \left(t \cdot t\right), \left(\left(z \cdot z\right) \cdot y\right) \cdot y\right)}{y \cdot \left(t \cdot \left(y \cdot t\right)\right)}} \]
    5. Taylor expanded in x around 0

      \[\leadsto \color{blue}{\frac{{z}^{2}}{{t}^{2}}} \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \frac{\color{blue}{z \cdot z}}{{t}^{2}} \]
      2. associate-/l*N/A

        \[\leadsto \color{blue}{z \cdot \frac{z}{{t}^{2}}} \]
      3. lower-*.f64N/A

        \[\leadsto \color{blue}{z \cdot \frac{z}{{t}^{2}}} \]
      4. lower-/.f64N/A

        \[\leadsto z \cdot \color{blue}{\frac{z}{{t}^{2}}} \]
      5. unpow2N/A

        \[\leadsto z \cdot \frac{z}{\color{blue}{t \cdot t}} \]
      6. lower-*.f6476.0

        \[\leadsto z \cdot \frac{z}{\color{blue}{t \cdot t}} \]
    7. Applied rewrites76.0%

      \[\leadsto \color{blue}{z \cdot \frac{z}{t \cdot t}} \]
    8. Step-by-step derivation
      1. Applied rewrites93.3%

        \[\leadsto \frac{\frac{z}{t}}{\color{blue}{\frac{t}{z}}} \]

      if 1.0000000000000001e-290 < (/.f64 (*.f64 x x) (*.f64 y y)) < 4.99999999999999991e295

      1. Initial program 78.9%

        \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      2. Add Preprocessing
      3. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z \cdot z}{t \cdot t}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{\color{blue}{z \cdot z}}{t \cdot t} \]
        3. lift-*.f64N/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{\color{blue}{t \cdot t}} \]
        4. times-fracN/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} \]
        5. clear-numN/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{z}{t} \cdot \color{blue}{\frac{1}{\frac{t}{z}}} \]
        6. un-div-invN/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{\frac{z}{t}}{\frac{t}{z}}} \]
        7. lower-/.f64N/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{\frac{z}{t}}{\frac{t}{z}}} \]
        8. lower-/.f64N/A

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{\color{blue}{\frac{z}{t}}}{\frac{t}{z}} \]
        9. lower-/.f6498.9

          \[\leadsto \frac{x \cdot x}{y \cdot y} + \frac{\frac{z}{t}}{\color{blue}{\frac{t}{z}}} \]
      4. Applied rewrites98.9%

        \[\leadsto \frac{x \cdot x}{y \cdot y} + \color{blue}{\frac{\frac{z}{t}}{\frac{t}{z}}} \]
      5. Step-by-step derivation
        1. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{\frac{z}{t}}{\frac{t}{z}} \]
        2. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{\frac{z}{t}}{\frac{t}{z}} \]
        3. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{x}{y \cdot y} \cdot x} + \frac{\frac{z}{t}}{\frac{t}{z}} \]
        4. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \cdot x + \frac{\frac{z}{t}}{\frac{t}{z}} \]
        5. lower-*.f6499.2

          \[\leadsto \color{blue}{\frac{x}{y \cdot y} \cdot x} + \frac{\frac{z}{t}}{\frac{t}{z}} \]
      6. Applied rewrites99.2%

        \[\leadsto \color{blue}{\frac{x}{y \cdot y} \cdot x} + \frac{\frac{z}{t}}{\frac{t}{z}} \]
      7. Step-by-step derivation
        1. lift-+.f64N/A

          \[\leadsto \color{blue}{\frac{x}{y \cdot y} \cdot x + \frac{\frac{z}{t}}{\frac{t}{z}}} \]
        2. lift-/.f64N/A

          \[\leadsto \frac{x}{y \cdot y} \cdot x + \color{blue}{\frac{\frac{z}{t}}{\frac{t}{z}}} \]
        3. div-invN/A

          \[\leadsto \frac{x}{y \cdot y} \cdot x + \color{blue}{\frac{z}{t} \cdot \frac{1}{\frac{t}{z}}} \]
        4. lift-/.f64N/A

          \[\leadsto \frac{x}{y \cdot y} \cdot x + \frac{z}{t} \cdot \frac{1}{\color{blue}{\frac{t}{z}}} \]
        5. clear-numN/A

          \[\leadsto \frac{x}{y \cdot y} \cdot x + \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
        6. lift-/.f64N/A

          \[\leadsto \frac{x}{y \cdot y} \cdot x + \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} \]
        7. lift-*.f64N/A

          \[\leadsto \frac{x}{y \cdot y} \cdot x + \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} \]
        8. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{x}{y \cdot y} \cdot x} + \frac{z}{t} \cdot \frac{z}{t} \]
        9. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x}{y \cdot y}} \cdot x + \frac{z}{t} \cdot \frac{z}{t} \]
        10. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z}{t} \cdot \frac{z}{t} \]
        11. lift-*.f64N/A

          \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z}{t} \cdot \frac{z}{t} \]
        12. lift-/.f64N/A

          \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z}{t} \cdot \frac{z}{t} \]
        13. +-commutativeN/A

          \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t} + \frac{x \cdot x}{y \cdot y}} \]
        14. lift-*.f64N/A

          \[\leadsto \color{blue}{\frac{z}{t} \cdot \frac{z}{t}} + \frac{x \cdot x}{y \cdot y} \]
        15. lift-/.f64N/A

          \[\leadsto \frac{z}{t} \cdot \color{blue}{\frac{z}{t}} + \frac{x \cdot x}{y \cdot y} \]
        16. associate-*r/N/A

          \[\leadsto \color{blue}{\frac{\frac{z}{t} \cdot z}{t}} + \frac{x \cdot x}{y \cdot y} \]
        17. associate-*l/N/A

          \[\leadsto \color{blue}{\frac{\frac{z}{t}}{t} \cdot z} + \frac{x \cdot x}{y \cdot y} \]
        18. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{z}{t}}{t}, z, \frac{x \cdot x}{y \cdot y}\right)} \]
        19. lift-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{\color{blue}{\frac{z}{t}}}{t}, z, \frac{x \cdot x}{y \cdot y}\right) \]
        20. associate-/r*N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t \cdot t}}, z, \frac{x \cdot x}{y \cdot y}\right) \]
        21. lower-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{z}{t \cdot t}}, z, \frac{x \cdot x}{y \cdot y}\right) \]
        22. lower-*.f6486.3

          \[\leadsto \mathsf{fma}\left(\frac{z}{\color{blue}{t \cdot t}}, z, \frac{x \cdot x}{y \cdot y}\right) \]
        23. lift-/.f64N/A

          \[\leadsto \mathsf{fma}\left(\frac{z}{t \cdot t}, z, \color{blue}{\frac{x \cdot x}{y \cdot y}}\right) \]
      8. Applied rewrites86.6%

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

      if 4.99999999999999991e295 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0

      1. Initial program 77.5%

        \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
      2. Add Preprocessing
      3. Taylor expanded in x around inf

        \[\leadsto \color{blue}{\frac{{x}^{2}}{{y}^{2}}} \]
      4. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \frac{\color{blue}{x \cdot x}}{{y}^{2}} \]
        2. associate-/l*N/A

          \[\leadsto \color{blue}{x \cdot \frac{x}{{y}^{2}}} \]
        3. lower-*.f64N/A

          \[\leadsto \color{blue}{x \cdot \frac{x}{{y}^{2}}} \]
        4. lower-/.f64N/A

          \[\leadsto x \cdot \color{blue}{\frac{x}{{y}^{2}}} \]
        5. unpow2N/A

          \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot y}} \]
        6. lower-*.f6491.1

          \[\leadsto x \cdot \frac{x}{\color{blue}{y \cdot y}} \]
      5. Applied rewrites91.1%

        \[\leadsto \color{blue}{x \cdot \frac{x}{y \cdot y}} \]
      6. Step-by-step derivation
        1. Applied rewrites94.5%

          \[\leadsto \frac{x}{y} \cdot \color{blue}{\frac{x}{y}} \]
        2. Step-by-step derivation
          1. Applied rewrites94.5%

            \[\leadsto \frac{x}{y} \cdot \left(\frac{1}{y} \cdot \color{blue}{x}\right) \]

          if +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y))

          1. Initial program 0.0%

            \[\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
          2. Add Preprocessing
          3. Step-by-step derivation
            1. lift-+.f64N/A

              \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y} + \frac{z \cdot z}{t \cdot t}} \]
            2. lift-/.f64N/A

              \[\leadsto \color{blue}{\frac{x \cdot x}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
            3. lift-*.f64N/A

              \[\leadsto \frac{\color{blue}{x \cdot x}}{y \cdot y} + \frac{z \cdot z}{t \cdot t} \]
            4. lift-*.f64N/A

              \[\leadsto \frac{x \cdot x}{\color{blue}{y \cdot y}} + \frac{z \cdot z}{t \cdot t} \]
            5. times-fracN/A

              \[\leadsto \color{blue}{\frac{x}{y} \cdot \frac{x}{y}} + \frac{z \cdot z}{t \cdot t} \]
            6. lower-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right)} \]
            7. lower-/.f64N/A

              \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{x}{y}}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right) \]
            8. lower-/.f6481.5

              \[\leadsto \mathsf{fma}\left(\frac{x}{y}, \color{blue}{\frac{x}{y}}, \frac{z \cdot z}{t \cdot t}\right) \]
          4. Applied rewrites81.5%

            \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right)} \]
        3. Recombined 4 regimes into one program.
        4. Final simplification91.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 10^{-290}:\\ \;\;\;\;\frac{\frac{z}{t}}{\frac{t}{z}}\\ \mathbf{elif}\;\frac{x \cdot x}{y \cdot y} \leq 5 \cdot 10^{+295}:\\ \;\;\;\;\mathsf{fma}\left(\frac{z}{t \cdot t}, z, x \cdot \frac{x}{y \cdot y}\right)\\ \mathbf{elif}\;\frac{x \cdot x}{y \cdot y} \leq \infty:\\ \;\;\;\;\frac{x}{y} \cdot \left(x \cdot \frac{1}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z \cdot z}{t \cdot t}\right)\\ \end{array} \]
        5. Add Preprocessing

        Developer Target 1: 99.7% accurate, 0.2× 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 2024229 
        (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))))