
(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}
Herbie found 7 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}
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1e-191) (fma (/ z t) (/ z t) (/ (* (/ x y_m) x) y_m)) (fma (/ z t) (/ z t) (* (/ (/ x y_m) y_m) x))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1e-191) {
tmp = fma((z / t), (z / t), (((x / y_m) * x) / y_m));
} else {
tmp = fma((z / t), (z / t), (((x / y_m) / y_m) * x));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1e-191) tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(Float64(x / y_m) * x) / y_m)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(Float64(x / y_m) / y_m) * x)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1e-191], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(N[(x / y$95$m), $MachinePrecision] * x), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(N[(x / y$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 10^{-191}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\frac{x}{y\_m} \cdot x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\frac{x}{y\_m}}{y\_m} \cdot x\right)\\
\end{array}
\end{array}
if y < 1e-191Initial program 67.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.0
Applied rewrites90.0%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
associate-/r*N/A
associate-*l/N/A
lift-/.f64N/A
lift-*.f64N/A
lift-/.f6496.8
Applied rewrites96.8%
if 1e-191 < y Initial program 67.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.0
Applied rewrites90.0%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6496.8
Applied rewrites96.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (fma (/ z t) (/ z t) (* (/ (/ x y_m) y_m) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return fma((z / t), (z / t), (((x / y_m) / y_m) * x));
}
y_m = abs(y) function code(x, y_m, z, t) return fma(Float64(z / t), Float64(z / t), Float64(Float64(Float64(x / y_m) / y_m) * x)) end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(N[(x / y$95$m), $MachinePrecision] / y$95$m), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\frac{x}{y\_m}}{y\_m} \cdot x\right)
\end{array}
Initial program 67.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.0
Applied rewrites90.0%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6496.8
Applied rewrites96.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= (/ (* z z) (* t t)) 5e+299) (fma (/ x y_m) (/ x y_m) (* (/ z (* t t)) z)) (fma (/ z t) (/ z t) (* (/ x (* y_m y_m)) x))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 5e+299) {
tmp = fma((x / y_m), (x / y_m), ((z / (t * t)) * z));
} else {
tmp = fma((z / t), (z / t), ((x / (y_m * y_m)) * x));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 5e+299) tmp = fma(Float64(x / y_m), Float64(x / y_m), Float64(Float64(z / Float64(t * t)) * z)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(x / Float64(y_m * y_m)) * x)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 5e+299], N[(N[(x / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(x / N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 5 \cdot 10^{+299}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y\_m}, \frac{x}{y\_m}, \frac{z}{t \cdot t} \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y\_m \cdot y\_m} \cdot x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 5.0000000000000003e299Initial program 67.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6489.5
Applied rewrites89.5%
if 5.0000000000000003e299 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 67.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
pow2N/A
pow2N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6490.0
Applied rewrites90.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= (/ (* x x) (* y_m y_m)) 0.0) (* (/ z t) (/ z t)) (fma (/ x y_m) (/ x y_m) (* (/ z (* t t)) z))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (((x * x) / (y_m * y_m)) <= 0.0) {
tmp = (z / t) * (z / t);
} else {
tmp = fma((x / y_m), (x / y_m), ((z / (t * t)) * z));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (Float64(Float64(x * x) / Float64(y_m * y_m)) <= 0.0) tmp = Float64(Float64(z / t) * Float64(z / t)); else tmp = fma(Float64(x / y_m), Float64(x / y_m), Float64(Float64(z / Float64(t * t)) * z)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[(x / y$95$m), $MachinePrecision] * N[(x / y$95$m), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y\_m \cdot y\_m} \leq 0:\\
\;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y\_m}, \frac{x}{y\_m}, \frac{z}{t \cdot t} \cdot z\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 0.0Initial program 67.3%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6452.7
Applied rewrites52.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
if 0.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 67.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
times-fracN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6489.5
Applied rewrites89.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= (* y_m y_m) 1.25e+286) (fma (/ z (* t t)) z (* (/ x (* y_m y_m)) x)) (* (/ z t) (/ z t))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((y_m * y_m) <= 1.25e+286) {
tmp = fma((z / (t * t)), z, ((x / (y_m * y_m)) * x));
} else {
tmp = (z / t) * (z / t);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (Float64(y_m * y_m) <= 1.25e+286) tmp = fma(Float64(z / Float64(t * t)), z, Float64(Float64(x / Float64(y_m * y_m)) * x)); else tmp = Float64(Float64(z / t) * Float64(z / t)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[N[(y$95$m * y$95$m), $MachinePrecision], 1.25e+286], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z + N[(N[(x / N[(y$95$m * y$95$m), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \cdot y\_m \leq 1.25 \cdot 10^{+286}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{x}{y\_m \cdot y\_m} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\
\end{array}
\end{array}
if (*.f64 y y) < 1.2500000000000001e286Initial program 67.3%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
+-commutativeN/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
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6481.0
Applied rewrites81.0%
if 1.2500000000000001e286 < (*.f64 y y) Initial program 67.3%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6452.7
Applied rewrites52.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (* (/ z t) (/ z t)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return (z / t) * (z / t);
}
y_m = private
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_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (z / t) * (z / t)
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
return (z / t) * (z / t);
}
y_m = math.fabs(y) def code(x, y_m, z, t): return (z / t) * (z / t)
y_m = abs(y) function code(x, y_m, z, t) return Float64(Float64(z / t) * Float64(z / t)) end
y_m = abs(y); function tmp = code(x, y_m, z, t) tmp = (z / t) * (z / t); end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\frac{z}{t} \cdot \frac{z}{t}
\end{array}
Initial program 67.3%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6452.7
Applied rewrites52.7%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
frac-timesN/A
lift-/.f64N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (* (/ z (* t t)) z))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return (z / (t * t)) * z;
}
y_m = private
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_m, z, t)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (z / (t * t)) * z
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
return (z / (t * t)) * z;
}
y_m = math.fabs(y) def code(x, y_m, z, t): return (z / (t * t)) * z
y_m = abs(y) function code(x, y_m, z, t) return Float64(Float64(z / Float64(t * t)) * z) end
y_m = abs(y); function tmp = code(x, y_m, z, t) tmp = (z / (t * t)) * z; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\frac{z}{t \cdot t} \cdot z
\end{array}
Initial program 67.3%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6452.7
Applied rewrites52.7%
herbie shell --seed 2025142
(FPCore (x y z t)
:name "Graphics.Rasterific.Svg.PathConverter:arcToSegments from rasterific-svg-0.2.3.1"
:precision binary64
(+ (/ (* x x) (* y y)) (/ (* z z) (* t t))))