
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\end{array}
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))
double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)
end function
public static double code(double x, double y) {
return ((1.0 - x) * (3.0 - x)) / (y * 3.0);
}
def code(x, y): return ((1.0 - x) * (3.0 - x)) / (y * 3.0)
function code(x, y) return Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) end
function tmp = code(x, y) tmp = ((1.0 - x) * (3.0 - x)) / (y * 3.0); end
code[x_, y_] := N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3}
\end{array}
(FPCore (x y) :precision binary64 (* (/ (* (- 3.0 x) 0.3333333333333333) y) (- 1.0 x)))
double code(double x, double y) {
return (((3.0 - x) * 0.3333333333333333) / y) * (1.0 - x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (((3.0d0 - x) * 0.3333333333333333d0) / y) * (1.0d0 - x)
end function
public static double code(double x, double y) {
return (((3.0 - x) * 0.3333333333333333) / y) * (1.0 - x);
}
def code(x, y): return (((3.0 - x) * 0.3333333333333333) / y) * (1.0 - x)
function code(x, y) return Float64(Float64(Float64(Float64(3.0 - x) * 0.3333333333333333) / y) * Float64(1.0 - x)) end
function tmp = code(x, y) tmp = (((3.0 - x) * 0.3333333333333333) / y) * (1.0 - x); end
code[x_, y_] := N[(N[(N[(N[(3.0 - x), $MachinePrecision] * 0.3333333333333333), $MachinePrecision] / y), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(3 - x\right) \cdot 0.3333333333333333}{y} \cdot \left(1 - x\right)
\end{array}
Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
(FPCore (x y) :precision binary64 (* (- 3.0 x) (/ (- 1.0 x) (* y 3.0))))
double code(double x, double y) {
return (3.0 - x) * ((1.0 - x) / (y * 3.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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (3.0d0 - x) * ((1.0d0 - x) / (y * 3.0d0))
end function
public static double code(double x, double y) {
return (3.0 - x) * ((1.0 - x) / (y * 3.0));
}
def code(x, y): return (3.0 - x) * ((1.0 - x) / (y * 3.0))
function code(x, y) return Float64(Float64(3.0 - x) * Float64(Float64(1.0 - x) / Float64(y * 3.0))) end
function tmp = code(x, y) tmp = (3.0 - x) * ((1.0 - x) / (y * 3.0)); end
code[x_, y_] := N[(N[(3.0 - x), $MachinePrecision] * N[(N[(1.0 - x), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(3 - x\right) \cdot \frac{1 - x}{y \cdot 3}
\end{array}
Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f6499.5
Applied rewrites99.5%
(FPCore (x y) :precision binary64 (/ (fma 0.3333333333333333 x -0.3333333333333333) (/ y (- x 3.0))))
double code(double x, double y) {
return fma(0.3333333333333333, x, -0.3333333333333333) / (y / (x - 3.0));
}
function code(x, y) return Float64(fma(0.3333333333333333, x, -0.3333333333333333) / Float64(y / Float64(x - 3.0))) end
code[x_, y_] := N[(N[(0.3333333333333333 * x + -0.3333333333333333), $MachinePrecision] / N[(y / N[(x - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(0.3333333333333333, x, -0.3333333333333333\right)}{\frac{y}{x - 3}}
\end{array}
Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-*.f64N/A
metadata-evalN/A
mult-flip-revN/A
times-fracN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower--.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lift--.f64N/A
sub-negate-revN/A
sub-negate-revN/A
sub-negate-revN/A
distribute-frac-neg2N/A
frac-2neg-revN/A
lower-/.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
sub-negate-revN/A
lower--.f6499.5
Applied rewrites99.5%
(FPCore (x y) :precision binary64 (* (fma -0.3333333333333333 x 0.3333333333333333) (/ (- 3.0 x) y)))
double code(double x, double y) {
return fma(-0.3333333333333333, x, 0.3333333333333333) * ((3.0 - x) / y);
}
function code(x, y) return Float64(fma(-0.3333333333333333, x, 0.3333333333333333) * Float64(Float64(3.0 - x) / y)) end
code[x_, y_] := N[(N[(-0.3333333333333333 * x + 0.3333333333333333), $MachinePrecision] * N[(N[(3.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-0.3333333333333333, x, 0.3333333333333333\right) \cdot \frac{3 - x}{y}
\end{array}
Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-*.f64N/A
metadata-evalN/A
mult-flip-revN/A
times-fracN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower--.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.5
lift--.f64N/A
sub-flipN/A
+-commutativeN/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f6499.5
Applied rewrites99.5%
(FPCore (x y) :precision binary64 (if (<= (* (- 1.0 x) (- 3.0 x)) 5.0) (/ (fma -1.3333333333333333 x 1.0) y) (/ (* 0.3333333333333333 x) (/ y (- x 3.0)))))
double code(double x, double y) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y;
} else {
tmp = (0.3333333333333333 * x) / (y / (x - 3.0));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y); else tmp = Float64(Float64(0.3333333333333333 * x) / Float64(y / Float64(x - 3.0))); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(0.3333333333333333 * x), $MachinePrecision] / N[(y / N[(x - 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333 \cdot x}{\frac{y}{x - 3}}\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 93.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6457.4
Applied rewrites57.4%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift-*.f64N/A
metadata-evalN/A
mult-flip-revN/A
times-fracN/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower--.f64N/A
mult-flipN/A
metadata-evalN/A
lower-*.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
lift-/.f64N/A
div-flipN/A
mult-flip-revN/A
lift--.f64N/A
sub-negate-revN/A
sub-negate-revN/A
sub-negate-revN/A
distribute-frac-neg2N/A
frac-2neg-revN/A
lower-/.f64N/A
sub-flipN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
sub-negate-revN/A
lower--.f6499.5
Applied rewrites99.5%
Taylor expanded in x around inf
lower-*.f6450.7
Applied rewrites50.7%
(FPCore (x y) :precision binary64 (if (<= (* (- 1.0 x) (- 3.0 x)) 5.0) (/ (fma -1.3333333333333333 x 1.0) y) (* (/ (/ x -3.0) y) (- 1.0 x))))
double code(double x, double y) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y;
} else {
tmp = ((x / -3.0) / y) * (1.0 - x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y); else tmp = Float64(Float64(Float64(x / -3.0) / y) * Float64(1.0 - x)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(x / -3.0), $MachinePrecision] / y), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{-3}}{y} \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 93.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6457.4
Applied rewrites57.4%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6450.6
Applied rewrites50.6%
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
distribute-lft-neg-outN/A
metadata-evalN/A
mult-flip-revN/A
metadata-evalN/A
metadata-evalN/A
frac-2neg-revN/A
lower-/.f64N/A
metadata-eval50.6
Applied rewrites50.6%
(FPCore (x y) :precision binary64 (if (<= (* (- 1.0 x) (- 3.0 x)) 5.0) (/ (fma -1.3333333333333333 x 1.0) y) (* (/ (* -0.3333333333333333 x) y) (- 1.0 x))))
double code(double x, double y) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y;
} else {
tmp = ((-0.3333333333333333 * x) / y) * (1.0 - x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y); else tmp = Float64(Float64(Float64(-0.3333333333333333 * x) / y) * Float64(1.0 - x)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(N[(-0.3333333333333333 * x), $MachinePrecision] / y), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.3333333333333333 \cdot x}{y} \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 93.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6457.4
Applied rewrites57.4%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6450.6
Applied rewrites50.6%
(FPCore (x y) :precision binary64 (if (<= (* (- 1.0 x) (- 3.0 x)) 5.0) (/ (fma -1.3333333333333333 x 1.0) y) (* (* -0.3333333333333333 (/ x y)) (- 1.0 x))))
double code(double x, double y) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y;
} else {
tmp = (-0.3333333333333333 * (x / y)) * (1.0 - x);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y); else tmp = Float64(Float64(-0.3333333333333333 * Float64(x / y)) * Float64(1.0 - x)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(-0.3333333333333333 * N[(x / y), $MachinePrecision]), $MachinePrecision] * N[(1.0 - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(-0.3333333333333333 \cdot \frac{x}{y}\right) \cdot \left(1 - x\right)\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 93.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6457.4
Applied rewrites57.4%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6450.6
Applied rewrites50.6%
(FPCore (x y) :precision binary64 (if (<= (* (- 1.0 x) (- 3.0 x)) 5.0) (/ (fma -1.3333333333333333 x 1.0) y) (* (* -0.3333333333333333 x) (/ (- 1.0 x) y))))
double code(double x, double y) {
double tmp;
if (((1.0 - x) * (3.0 - x)) <= 5.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y;
} else {
tmp = (-0.3333333333333333 * x) * ((1.0 - x) / y);
}
return tmp;
}
function code(x, y) tmp = 0.0 if (Float64(Float64(1.0 - x) * Float64(3.0 - x)) <= 5.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y); else tmp = Float64(Float64(-0.3333333333333333 * x) * Float64(Float64(1.0 - x) / y)); end return tmp end
code[x_, y_] := If[LessEqual[N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision], 5.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[(N[(-0.3333333333333333 * x), $MachinePrecision] * N[(N[(1.0 - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - x\right) \cdot \left(3 - x\right) \leq 5:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\left(-0.3333333333333333 \cdot x\right) \cdot \frac{1 - x}{y}\\
\end{array}
\end{array}
if (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) < 5Initial program 93.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6457.4
Applied rewrites57.4%
if 5 < (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) Initial program 93.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift--.f64N/A
div-subN/A
metadata-evalN/A
lower-/.f64N/A
metadata-evalN/A
div-subN/A
lift--.f64N/A
mult-flipN/A
lower-*.f64N/A
metadata-eval99.8
Applied rewrites99.8%
Taylor expanded in x around inf
lower-*.f6450.6
Applied rewrites50.6%
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
associate-/l*N/A
lift--.f64N/A
lower-*.f64N/A
lift--.f64N/A
lower-/.f6450.6
Applied rewrites50.6%
(FPCore (x y) :precision binary64 (if (<= x 3.0) (/ (fma -1.3333333333333333 x 1.0) y) (sqrt (/ 1.0 (* y y)))))
double code(double x, double y) {
double tmp;
if (x <= 3.0) {
tmp = fma(-1.3333333333333333, x, 1.0) / y;
} else {
tmp = sqrt((1.0 / (y * y)));
}
return tmp;
}
function code(x, y) tmp = 0.0 if (x <= 3.0) tmp = Float64(fma(-1.3333333333333333, x, 1.0) / y); else tmp = sqrt(Float64(1.0 / Float64(y * y))); end return tmp end
code[x_, y_] := If[LessEqual[x, 3.0], N[(N[(-1.3333333333333333 * x + 1.0), $MachinePrecision] / y), $MachinePrecision], N[Sqrt[N[(1.0 / N[(y * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1.3333333333333333, x, 1\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{y \cdot y}}\\
\end{array}
\end{array}
if x < 3Initial program 93.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
lift-fma.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-/.f64N/A
div-add-revN/A
lower-/.f64N/A
lower-fma.f6457.4
Applied rewrites57.4%
if 3 < x Initial program 93.8%
Taylor expanded in x around 0
lower-/.f6451.7
Applied rewrites51.7%
lift-/.f64N/A
inv-powN/A
pow-to-expN/A
fabs-expN/A
pow-to-expN/A
inv-powN/A
lift-/.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f6419.8
Applied rewrites19.8%
(FPCore (x y) :precision binary64 (if (<= (/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)) 1e+307) (/ 1.0 y) (sqrt (/ 1.0 (* y y)))))
double code(double x, double y) {
double tmp;
if ((((1.0 - x) * (3.0 - x)) / (y * 3.0)) <= 1e+307) {
tmp = 1.0 / y;
} else {
tmp = sqrt((1.0 / (y * y)));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((((1.0d0 - x) * (3.0d0 - x)) / (y * 3.0d0)) <= 1d+307) then
tmp = 1.0d0 / y
else
tmp = sqrt((1.0d0 / (y * y)))
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((((1.0 - x) * (3.0 - x)) / (y * 3.0)) <= 1e+307) {
tmp = 1.0 / y;
} else {
tmp = Math.sqrt((1.0 / (y * y)));
}
return tmp;
}
def code(x, y): tmp = 0 if (((1.0 - x) * (3.0 - x)) / (y * 3.0)) <= 1e+307: tmp = 1.0 / y else: tmp = math.sqrt((1.0 / (y * y))) return tmp
function code(x, y) tmp = 0.0 if (Float64(Float64(Float64(1.0 - x) * Float64(3.0 - x)) / Float64(y * 3.0)) <= 1e+307) tmp = Float64(1.0 / y); else tmp = sqrt(Float64(1.0 / Float64(y * y))); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((((1.0 - x) * (3.0 - x)) / (y * 3.0)) <= 1e+307) tmp = 1.0 / y; else tmp = sqrt((1.0 / (y * y))); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[N[(N[(N[(1.0 - x), $MachinePrecision] * N[(3.0 - x), $MachinePrecision]), $MachinePrecision] / N[(y * 3.0), $MachinePrecision]), $MachinePrecision], 1e+307], N[(1.0 / y), $MachinePrecision], N[Sqrt[N[(1.0 / N[(y * y), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{\left(1 - x\right) \cdot \left(3 - x\right)}{y \cdot 3} \leq 10^{+307}:\\
\;\;\;\;\frac{1}{y}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{1}{y \cdot y}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) (*.f64 y #s(literal 3 binary64))) < 9.99999999999999986e306Initial program 93.8%
Taylor expanded in x around 0
lower-/.f6451.7
Applied rewrites51.7%
if 9.99999999999999986e306 < (/.f64 (*.f64 (-.f64 #s(literal 1 binary64) x) (-.f64 #s(literal 3 binary64) x)) (*.f64 y #s(literal 3 binary64))) Initial program 93.8%
Taylor expanded in x around 0
lower-/.f6451.7
Applied rewrites51.7%
lift-/.f64N/A
inv-powN/A
pow-to-expN/A
fabs-expN/A
pow-to-expN/A
inv-powN/A
lift-/.f64N/A
rem-sqrt-square-revN/A
lower-sqrt.f64N/A
lift-/.f64N/A
lift-/.f64N/A
frac-timesN/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f6419.8
Applied rewrites19.8%
(FPCore (x y) :precision binary64 (if (<= x -0.75) (* -1.3333333333333333 (/ x y)) (/ 1.0 y)))
double code(double x, double y) {
double tmp;
if (x <= -0.75) {
tmp = -1.3333333333333333 * (x / y);
} else {
tmp = 1.0 / y;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (x <= (-0.75d0)) then
tmp = (-1.3333333333333333d0) * (x / y)
else
tmp = 1.0d0 / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (x <= -0.75) {
tmp = -1.3333333333333333 * (x / y);
} else {
tmp = 1.0 / y;
}
return tmp;
}
def code(x, y): tmp = 0 if x <= -0.75: tmp = -1.3333333333333333 * (x / y) else: tmp = 1.0 / y return tmp
function code(x, y) tmp = 0.0 if (x <= -0.75) tmp = Float64(-1.3333333333333333 * Float64(x / y)); else tmp = Float64(1.0 / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (x <= -0.75) tmp = -1.3333333333333333 * (x / y); else tmp = 1.0 / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[x, -0.75], N[(-1.3333333333333333 * N[(x / y), $MachinePrecision]), $MachinePrecision], N[(1.0 / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.75:\\
\;\;\;\;-1.3333333333333333 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{y}\\
\end{array}
\end{array}
if x < -0.75Initial program 93.8%
Taylor expanded in x around 0
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6457.4
Applied rewrites57.4%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f649.8
Applied rewrites9.8%
if -0.75 < x Initial program 93.8%
Taylor expanded in x around 0
lower-/.f6451.7
Applied rewrites51.7%
(FPCore (x y) :precision binary64 (/ 1.0 y))
double code(double x, double y) {
return 1.0 / 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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 1.0d0 / y
end function
public static double code(double x, double y) {
return 1.0 / y;
}
def code(x, y): return 1.0 / y
function code(x, y) return Float64(1.0 / y) end
function tmp = code(x, y) tmp = 1.0 / y; end
code[x_, y_] := N[(1.0 / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{y}
\end{array}
Initial program 93.8%
Taylor expanded in x around 0
lower-/.f6451.7
Applied rewrites51.7%
herbie shell --seed 2025150
(FPCore (x y)
:name "Diagrams.TwoD.Arc:bezierFromSweepQ1 from diagrams-lib-1.3.0.3"
:precision binary64
(/ (* (- 1.0 x) (- 3.0 x)) (* y 3.0)))