
(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 8 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 (if (<= (/ (* z z) (* t t)) 1e+157) (fma (/ x y) (/ x y) (* (/ z (* t t)) z)) (fma (/ z t) (/ z t) (* (/ (/ x y) y) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 1e+157) {
tmp = fma((x / y), (x / y), ((z / (t * t)) * z));
} else {
tmp = fma((z / t), (z / t), (((x / y) / y) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 1e+157) tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z / Float64(t * t)) * z)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(Float64(x / y) / y) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 1e+157], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision] + N[(N[(N[(x / y), $MachinePrecision] / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 10^{+157}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{\frac{x}{y}}{y} \cdot x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 9.99999999999999983e156Initial program 67.1%
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-*.f6490.0
Applied rewrites90.0%
if 9.99999999999999983e156 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 67.1%
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-*.f6489.5
Applied rewrites89.5%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
lower-/.f6496.7
Applied rewrites96.7%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* z z) (* t t)) 2e+252) (fma (/ x y) (/ x y) (* (/ z (* t t)) z)) (fma (/ z t) (/ z t) (* (/ x (* y y)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (((z * z) / (t * t)) <= 2e+252) {
tmp = fma((x / y), (x / y), ((z / (t * t)) * z));
} else {
tmp = fma((z / t), (z / t), ((x / (y * y)) * x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(z * z) / Float64(t * t)) <= 2e+252) tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z / Float64(t * t)) * z)); else tmp = fma(Float64(z / t), Float64(z / t), Float64(Float64(x / Float64(y * y)) * x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(z * z), $MachinePrecision] / N[(t * t), $MachinePrecision]), $MachinePrecision], 2e+252], N[(N[(x / y), $MachinePrecision] * N[(x / y), $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 * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{z \cdot z}{t \cdot t} \leq 2 \cdot 10^{+252}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t}, \frac{z}{t}, \frac{x}{y \cdot y} \cdot x\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 z z) (*.f64 t t)) < 2.0000000000000002e252Initial program 67.1%
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-*.f6490.0
Applied rewrites90.0%
if 2.0000000000000002e252 < (/.f64 (*.f64 z z) (*.f64 t t)) Initial program 67.1%
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-*.f6489.5
Applied rewrites89.5%
(FPCore (x y z t) :precision binary64 (if (<= (/ (* x x) (* y y)) 1e-217) (* (/ z t) (/ z t)) (fma (/ x y) (/ x y) (* (/ z (* t t)) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * x) / (y * y)) <= 1e-217) {
tmp = (z / t) * (z / t);
} else {
tmp = fma((x / y), (x / y), ((z / (t * t)) * z));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * x) / Float64(y * y)) <= 1e-217) tmp = Float64(Float64(z / t) * Float64(z / t)); else tmp = fma(Float64(x / y), Float64(x / y), Float64(Float64(z / Float64(t * t)) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision], 1e-217], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / y), $MachinePrecision] + N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot x}{y \cdot y} \leq 10^{-217}:\\
\;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{y}, \frac{x}{y}, \frac{z}{t \cdot t} \cdot z\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 1.00000000000000008e-217Initial program 67.1%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
if 1.00000000000000008e-217 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 67.1%
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-*.f6490.0
Applied rewrites90.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* x x) (* y y))) (t_2 (* (/ z t) (/ z t))))
(if (<= t_1 1e-217)
t_2
(if (<= t_1 INFINITY) (fma (/ z (* t t)) z (* (/ x (* y y)) x)) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double t_2 = (z / t) * (z / t);
double tmp;
if (t_1 <= 1e-217) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = fma((z / (t * t)), z, ((x / (y * y)) * x));
} else {
tmp = t_2;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(x * x) / Float64(y * y)) t_2 = Float64(Float64(z / t) * Float64(z / t)) tmp = 0.0 if (t_1 <= 1e-217) tmp = t_2; elseif (t_1 <= Inf) tmp = fma(Float64(z / Float64(t * t)), z, Float64(Float64(x / Float64(y * y)) * x)); else tmp = t_2; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e-217], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z + N[(N[(x / N[(y * y), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
t_2 := \frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{if}\;t\_1 \leq 10^{-217}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{t \cdot t}, z, \frac{x}{y \cdot y} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 1.00000000000000008e-217 or +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 67.1%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
if 1.00000000000000008e-217 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0Initial program 67.1%
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%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* x x) (* y y))) (t_2 (* (/ z t) (/ z t))))
(if (<= t_1 2e+186)
t_2
(if (<= t_1 INFINITY) (/ (* (* (/ t y) x) x) (* t y)) t_2))))
double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double t_2 = (z / t) * (z / t);
double tmp;
if (t_1 <= 2e+186) {
tmp = t_2;
} else if (t_1 <= ((double) INFINITY)) {
tmp = (((t / y) * x) * x) / (t * y);
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x * x) / (y * y);
double t_2 = (z / t) * (z / t);
double tmp;
if (t_1 <= 2e+186) {
tmp = t_2;
} else if (t_1 <= Double.POSITIVE_INFINITY) {
tmp = (((t / y) * x) * x) / (t * y);
} else {
tmp = t_2;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * x) / (y * y) t_2 = (z / t) * (z / t) tmp = 0 if t_1 <= 2e+186: tmp = t_2 elif t_1 <= math.inf: tmp = (((t / y) * x) * x) / (t * y) else: tmp = t_2 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * x) / Float64(y * y)) t_2 = Float64(Float64(z / t) * Float64(z / t)) tmp = 0.0 if (t_1 <= 2e+186) tmp = t_2; elseif (t_1 <= Inf) tmp = Float64(Float64(Float64(Float64(t / y) * x) * x) / Float64(t * y)); else tmp = t_2; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * x) / (y * y); t_2 = (z / t) * (z / t); tmp = 0.0; if (t_1 <= 2e+186) tmp = t_2; elseif (t_1 <= Inf) tmp = (((t / y) * x) * x) / (t * y); else tmp = t_2; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * x), $MachinePrecision] / N[(y * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e+186], t$95$2, If[LessEqual[t$95$1, Infinity], N[(N[(N[(N[(t / y), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision] / N[(t * y), $MachinePrecision]), $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x \cdot x}{y \cdot y}\\
t_2 := \frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{+186}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq \infty:\\
\;\;\;\;\frac{\left(\frac{t}{y} \cdot x\right) \cdot x}{t \cdot y}\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if (/.f64 (*.f64 x x) (*.f64 y y)) < 1.99999999999999996e186 or +inf.0 < (/.f64 (*.f64 x x) (*.f64 y y)) Initial program 67.1%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
if 1.99999999999999996e186 < (/.f64 (*.f64 x x) (*.f64 y y)) < +inf.0Initial program 67.1%
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
pow2N/A
pow2N/A
pow2N/A
pow2N/A
associate-/r*N/A
pow2N/A
associate-/r*N/A
frac-addN/A
lower-/.f64N/A
Applied rewrites81.8%
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
associate-/l*N/A
associate-*l/N/A
pow2N/A
associate-*r*N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
pow2N/A
*-commutativeN/A
associate-/l*N/A
lower-fma.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-/.f64N/A
Applied rewrites74.1%
Taylor expanded in x around inf
associate-*l/N/A
pow2N/A
associate-*l*N/A
lower-*.f64N/A
lift-/.f64N/A
lift-*.f6447.9
Applied rewrites47.9%
(FPCore (x y z t) :precision binary64 (if (<= x 2.4e+262) (* (/ z t) (/ z t)) (/ (/ (* z z) (- t)) (- t))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= 2.4e+262) {
tmp = (z / t) * (z / t);
} else {
tmp = ((z * z) / -t) / -t;
}
return tmp;
}
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
real(8) :: tmp
if (x <= 2.4d+262) then
tmp = (z / t) * (z / t)
else
tmp = ((z * z) / -t) / -t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= 2.4e+262) {
tmp = (z / t) * (z / t);
} else {
tmp = ((z * z) / -t) / -t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= 2.4e+262: tmp = (z / t) * (z / t) else: tmp = ((z * z) / -t) / -t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= 2.4e+262) tmp = Float64(Float64(z / t) * Float64(z / t)); else tmp = Float64(Float64(Float64(z * z) / Float64(-t)) / Float64(-t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= 2.4e+262) tmp = (z / t) * (z / t); else tmp = ((z * z) / -t) / -t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, 2.4e+262], N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * z), $MachinePrecision] / (-t)), $MachinePrecision] / (-t)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.4 \cdot 10^{+262}:\\
\;\;\;\;\frac{z}{t} \cdot \frac{z}{t}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{z \cdot z}{-t}}{-t}\\
\end{array}
\end{array}
if x < 2.39999999999999983e262Initial program 67.1%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
if 2.39999999999999983e262 < x Initial program 67.1%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
associate-*l/N/A
pow2N/A
lift-/.f64N/A
lift-*.f64N/A
lift-*.f6449.2
Applied rewrites49.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
pow2N/A
pow2N/A
pow2N/A
sqr-neg-revN/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lower-neg.f64N/A
lower-neg.f6453.0
Applied rewrites53.0%
(FPCore (x y z t) :precision binary64 (* (/ z t) (/ z t)))
double code(double x, double y, double z, double t) {
return (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 = (z / t) * (z / t)
end function
public static double code(double x, double y, double z, double t) {
return (z / t) * (z / t);
}
def code(x, y, z, t): return (z / t) * (z / t)
function code(x, y, z, t) return Float64(Float64(z / t) * Float64(z / t)) end
function tmp = code(x, y, z, t) tmp = (z / t) * (z / t); end
code[x_, y_, z_, t_] := N[(N[(z / t), $MachinePrecision] * N[(z / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{t} \cdot \frac{z}{t}
\end{array}
Initial program 67.1%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6453.2
Applied rewrites53.2%
lift-*.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lift-/.f64N/A
associate-*l/N/A
associate-*r/N/A
lift-/.f64N/A
lower-*.f6459.1
Applied rewrites59.1%
(FPCore (x y z t) :precision binary64 (* (/ z (* t t)) z))
double code(double x, double y, double z, double t) {
return (z / (t * t)) * z;
}
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 = (z / (t * t)) * z
end function
public static double code(double x, double y, double z, double t) {
return (z / (t * t)) * z;
}
def code(x, y, z, t): return (z / (t * t)) * z
function code(x, y, z, t) return Float64(Float64(z / Float64(t * t)) * z) end
function tmp = code(x, y, z, t) tmp = (z / (t * t)) * z; end
code[x_, y_, z_, t_] := N[(N[(z / N[(t * t), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}
\\
\frac{z}{t \cdot t} \cdot z
\end{array}
Initial program 67.1%
Taylor expanded in x around 0
pow2N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6453.2
Applied rewrites53.2%
herbie shell --seed 2025139
(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))))