
(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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
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:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
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}
(FPCore (x y z t) :precision binary64 (+ (* (/ x y) (/ x y)) (/ (* (/ z t) z) t)))
double code(double x, double y, double z, double t) {
return ((x / y) * (x / y)) + (((z / t) * z) / t);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x / y) * (x / y)) + (((z / t) * z) / t)
end function
public static double code(double x, double y, double z, double t) {
return ((x / y) * (x / y)) + (((z / t) * z) / t);
}
def code(x, y, z, t): return ((x / y) * (x / y)) + (((z / t) * z) / t)
function code(x, y, z, t) return Float64(Float64(Float64(x / y) * Float64(x / y)) + Float64(Float64(Float64(z / t) * z) / t)) end
function tmp = code(x, y, z, t) tmp = ((x / y) * (x / y)) + (((z / t) * z) / t); end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(z / t), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y} \cdot \frac{x}{y} + \frac{\frac{z}{t} \cdot z}{t}
\end{array}
Initial program 67.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
associate-*r/N/A
lower-/.f64N/A
lower-*.f64N/A
lower-/.f6481.7
Applied rewrites81.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6498.3
Applied rewrites98.3%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* z z) (* t t)) 4e+174) (fma (/ (/ x y) y) x (* (fabs z) (/ (fabs z) (* t t)))) (fma (/ x (* y y)) x (* (/ z t) (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 4e+174) {
tmp = fma(((x / y) / y), x, (fabs(z) * (fabs(z) / (t * t))));
} else {
tmp = fma((x / (y * y)), x, ((z / t) * (z / t)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 4e+174) tmp = fma(Float64(Float64(x / y) / y), x, Float64(abs(z) * Float64(abs(z) / Float64(t * t)))); else tmp = fma(Float64(x / Float64(y * y)), x, Float64(Float64(z / t) * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 4e+174], N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x + N[(N[Abs[z], $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 4 \cdot 10^{+174}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{x}{y}}{y}, x, \left|z\right| \cdot \frac{\left|z\right|}{t \cdot t}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y \cdot y}, x, \frac{z}{t} \cdot \frac{z}{t}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 4.00000000000000028e174Initial program 77.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6496.9
Applied rewrites96.9%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
sqr-abs-revN/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
pow2N/A
lift-*.f6495.1
Applied rewrites95.1%
if 4.00000000000000028e174 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 55.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6499.0
Applied rewrites99.0%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6498.2
Applied rewrites98.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f6497.3
Applied rewrites97.3%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6498.2
Applied rewrites98.2%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* z z) (* t t)) 4e+174) (+ (/ (* (/ x y) x) y) (* z (/ z (* t t)))) (fma (/ x (* y y)) x (* (/ z t) (/ z t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 4e+174) {
tmp = (((x / y) * x) / y) + (z * (z / (t * t)));
} else {
tmp = fma((x / (y * y)), x, ((z / t) * (z / t)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 4e+174) tmp = Float64(Float64(Float64(Float64(x / y) * x) / y) + Float64(z * Float64(z / Float64(t * t)))); else tmp = fma(Float64(x / Float64(y * y)), x, Float64(Float64(z / t) * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 4e+174], N[(N[(N[(N[(x / y), $MachinePrecision] * x), $MachinePrecision] / y), $MachinePrecision] + N[(z * N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 4 \cdot 10^{+174}:\\
\;\;\;\;\frac{\frac{x}{y} \cdot x}{y} + z \cdot \frac{z}{t \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y \cdot y}, x, \frac{z}{t} \cdot \frac{z}{t}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 4.00000000000000028e174Initial program 77.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
sqr-neg-revN/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-neg.f64N/A
lower-/.f64N/A
lower-neg.f64N/A
pow2N/A
lift-*.f6480.9
Applied rewrites80.9%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lower-*.f64N/A
lift-/.f6495.2
Applied rewrites95.2%
if 4.00000000000000028e174 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 55.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6499.0
Applied rewrites99.0%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6498.2
Applied rewrites98.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f6497.3
Applied rewrites97.3%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6498.2
Applied rewrites98.2%
Final simplification96.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* z z) (* t t))))
(if (<= t_1 4e+174)
(+ (* (/ x y) (/ x y)) t_1)
(fma (/ x (* y y)) x (* (/ z t) (/ z t))))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= 4e+174) {
tmp = ((x / y) * (x / y)) + t_1;
} else {
tmp = fma((x / (y * y)), x, ((z / t) * (z / t)));
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= 4e+174) tmp = Float64(Float64(Float64(x / y) * Float64(x / y)) + t_1); else tmp = fma(Float64(x / Float64(y * y)), x, Float64(Float64(z / t) * Float64(z / t))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 4e+174], N[(N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq 4 \cdot 10^{+174}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{y} + t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y \cdot y}, x, \frac{z}{t} \cdot \frac{z}{t}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 4.00000000000000028e174Initial program 77.5%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f6494.4
Applied rewrites94.4%
if 4.00000000000000028e174 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 55.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6499.0
Applied rewrites99.0%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6498.2
Applied rewrites98.2%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f6497.3
Applied rewrites97.3%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6498.2
Applied rewrites98.2%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* x x) (* y y)) INFINITY) (fma (/ x (* y y)) x (* (/ z t) (/ z t))) (fma (/ (/ x y) y) x (/ (* z z) (* t t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) / (y * y)) <= ((double) INFINITY)) {
tmp = fma((x / (y * y)), x, ((z / t) * (z / t)));
} else {
tmp = fma(((x / y) / y), x, ((z * z) / (t * t)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * x) / Float64(y * y)) <= Inf) tmp = fma(Float64(x / Float64(y * y)), x, Float64(Float64(z / t) * Float64(z / t))); else tmp = fma(Float64(Float64(x / y) / y), x, Float64(Float64(z * z) / Float64(t * t))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x + N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y \cdot y}, x, \frac{z}{t} \cdot \frac{z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\frac{x}{y}}{y}, x, \frac{z \cdot z}{t \cdot t}\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0Initial program 74.2%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6498.7
Applied rewrites98.7%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6497.5
Applied rewrites97.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f6495.3
Applied rewrites95.3%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6496.5
Applied rewrites96.5%
if +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 0.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6489.8
Applied rewrites89.8%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f6481.1
Applied rewrites81.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (/ (* z z) (* t t)))) (if (<= t_1 INFINITY) (fma (/ x (* y y)) x t_1) (/ (* x x) (* y y)))))
double code(double x, double y, double z, double t) {
double t_1 = (z * z) / (t * t);
double tmp;
if (t_1 <= ((double) INFINITY)) {
tmp = fma((x / (y * y)), x, t_1);
} else {
tmp = (x * x) / (y * y);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(z * z) / Float64(t * t)) tmp = 0.0 if (t_1 <= Inf) tmp = fma(Float64(x / Float64(y * y)), x, t_1); else tmp = Float64(Float64(x * x) / Float64(y * y)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x + t$95$1), $MachinePrecision], N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{z \cdot z}{t \cdot t}\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y \cdot y}, x, t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot x}{y \cdot y}\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < +inf.0Initial program 76.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6498.0
Applied rewrites98.0%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.5
Applied rewrites90.5%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
times-fracN/A
pow2N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6484.7
Applied rewrites84.7%
if +inf.0 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 0.0%
Taylor expanded in y around 0
lower-/.f64N/A
associate-/l*N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6447.5
Applied rewrites47.5%
Taylor expanded in x around inf
pow2N/A
lift-*.f6436.0
Applied rewrites36.0%
(FPCore (x y z t) :precision binary64 (fma (/ (/ x y) y) x (/ (* (/ z t) z) t)))
double code(double x, double y, double z, double t) {
return fma(((x / y) / y), x, (((z / t) * z) / t));
}
function code(x, y, z, t) return fma(Float64(Float64(x / y) / y), x, Float64(Float64(Float64(z / t) * z) / t)) end
code[x_, y_, z_, t_] := N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x + N[(N[(N[(z / t), $MachinePrecision] * z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{\frac{x}{y}}{y}, x, \frac{\frac{z}{t} \cdot z}{t}\right)
\end{array}
Initial program 67.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
(FPCore (x y z t) :precision binary64 (fma (/ x (* y y)) x (* (/ z t) (/ z t))))
double code(double x, double y, double z, double t) {
return fma((x / (y * y)), x, ((z / t) * (z / t)));
}
function code(x, y, z, t) return fma(Float64(x / Float64(y * y)), x, Float64(Float64(z / t) * Float64(z / t))) end
code[x_, y_, z_, t_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{y \cdot y}, x, \frac{z}{t} \cdot \frac{z}{t}\right)
\end{array}
Initial program 67.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.9
Applied rewrites90.9%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-/.f6492.3
Applied rewrites92.3%
(FPCore (x y z t) :precision binary64 (fma (/ x (* y y)) x (* (fabs z) (/ (fabs z) (* t t)))))
double code(double x, double y, double z, double t) {
return fma((x / (y * y)), x, (fabs(z) * (fabs(z) / (t * t))));
}
function code(x, y, z, t) return fma(Float64(x / Float64(y * y)), x, Float64(abs(z) * Float64(abs(z) / Float64(t * t)))) end
code[x_, y_, z_, t_] := N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x + N[(N[Abs[z], $MachinePrecision] * N[(N[Abs[z], $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{x}{y \cdot y}, x, \left|z\right| \cdot \frac{\left|z\right|}{t \cdot t}\right)
\end{array}
Initial program 67.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
pow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f6497.9
Applied rewrites97.9%
lift-pow.f64N/A
pow2N/A
lift-/.f64N/A
associate-*l/N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
associate-*l/N/A
lift-/.f64N/A
lower-*.f6496.4
Applied rewrites96.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
pow2N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.9
Applied rewrites90.9%
lift-/.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/l*N/A
times-fracN/A
sqr-abs-revN/A
pow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-fabs.f64N/A
lower-/.f64N/A
lower-fabs.f64N/A
pow2N/A
lift-*.f6481.6
Applied rewrites81.6%
(FPCore (x y z t) :precision binary64 (/ (* x x) (* y y)))
double code(double x, double y, double z, double t) {
return (x * x) / (y * y);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
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)
end function
public static double code(double x, double y, double z, double t) {
return (x * x) / (y * y);
}
def code(x, y, z, t): return (x * x) / (y * y)
function code(x, y, z, t) return Float64(Float64(x * x) / Float64(y * y)) end
function tmp = code(x, y, z, t) tmp = (x * x) / (y * y); end
code[x_, y_, z_, t_] := N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot x}{y \cdot y}
\end{array}
Initial program 67.5%
Taylor expanded in y around 0
lower-/.f64N/A
associate-/l*N/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
pow2N/A
times-fracN/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6455.6
Applied rewrites55.6%
Taylor expanded in x around inf
pow2N/A
lift-*.f6454.0
Applied rewrites54.0%
(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);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, y, z, t)
use fmin_fmax_functions
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}
herbie shell --seed 2025051
(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))))