
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
double t_0 = sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / sin(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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x): t_0 = math.sin((x * 0.5)) return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x))))
double code(double x) {
double t_0 = sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / sin(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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = (((8.0d0 / 3.0d0) * t_0) * t_0) / sin(x)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return (((8.0 / 3.0) * t_0) * t_0) / Math.sin(x);
}
def code(x): t_0 = math.sin((x * 0.5)) return (((8.0 / 3.0) * t_0) * t_0) / math.sin(x)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = (((8.0 / 3.0) * t_0) * t_0) / sin(x); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x}
\end{array}
\end{array}
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (* (* (/ t_0 3.0) 8.0) (/ t_0 (sin x)))))
double code(double x) {
double t_0 = sin((x * 0.5));
return ((t_0 / 3.0) * 8.0) * (t_0 / sin(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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = ((t_0 / 3.0d0) * 8.0d0) * (t_0 / sin(x))
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return ((t_0 / 3.0) * 8.0) * (t_0 / Math.sin(x));
}
def code(x): t_0 = math.sin((x * 0.5)) return ((t_0 / 3.0) * 8.0) * (t_0 / math.sin(x))
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(t_0 / 3.0) * 8.0) * Float64(t_0 / sin(x))) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = ((t_0 / 3.0) * 8.0) * (t_0 / sin(x)); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(t$95$0 / 3.0), $MachinePrecision] * 8.0), $MachinePrecision] * N[(t$95$0 / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\left(\frac{t\_0}{3} \cdot 8\right) \cdot \frac{t\_0}{\sin x}
\end{array}
\end{array}
Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
(FPCore (x) :precision binary64 (if (<= x 1e-22) (* (* (/ (sin (* x 0.5)) 3.0) 8.0) 0.5) (/ (* 2.6666666666666665 (pow (sin (* 0.5 x)) 2.0)) (sin x))))
double code(double x) {
double tmp;
if (x <= 1e-22) {
tmp = ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
} else {
tmp = (2.6666666666666665 * pow(sin((0.5 * x)), 2.0)) / sin(x);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1d-22) then
tmp = ((sin((x * 0.5d0)) / 3.0d0) * 8.0d0) * 0.5d0
else
tmp = (2.6666666666666665d0 * (sin((0.5d0 * x)) ** 2.0d0)) / sin(x)
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1e-22) {
tmp = ((Math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
} else {
tmp = (2.6666666666666665 * Math.pow(Math.sin((0.5 * x)), 2.0)) / Math.sin(x);
}
return tmp;
}
def code(x): tmp = 0 if x <= 1e-22: tmp = ((math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5 else: tmp = (2.6666666666666665 * math.pow(math.sin((0.5 * x)), 2.0)) / math.sin(x) return tmp
function code(x) tmp = 0.0 if (x <= 1e-22) tmp = Float64(Float64(Float64(sin(Float64(x * 0.5)) / 3.0) * 8.0) * 0.5); else tmp = Float64(Float64(2.6666666666666665 * (sin(Float64(0.5 * x)) ^ 2.0)) / sin(x)); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1e-22) tmp = ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5; else tmp = (2.6666666666666665 * (sin((0.5 * x)) ^ 2.0)) / sin(x); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1e-22], N[(N[(N[(N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision] * 8.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(2.6666666666666665 * N[Power[N[Sin[N[(0.5 * x), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{-22}:\\
\;\;\;\;\left(\frac{\sin \left(x \cdot 0.5\right)}{3} \cdot 8\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{2.6666666666666665 \cdot {\sin \left(0.5 \cdot x\right)}^{2}}{\sin x}\\
\end{array}
\end{array}
if x < 1e-22Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites55.5%
if 1e-22 < x Initial program 77.2%
Taylor expanded in x around inf
Applied rewrites77.2%
(FPCore (x) :precision binary64 (if (<= x 5e-20) (* (* (/ (sin (* x 0.5)) 3.0) 8.0) 0.5) (* 2.6666666666666665 (/ (pow (sin (* 0.5 x)) 2.0) (sin x)))))
double code(double x) {
double tmp;
if (x <= 5e-20) {
tmp = ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
} else {
tmp = 2.6666666666666665 * (pow(sin((0.5 * x)), 2.0) / sin(x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 5d-20) then
tmp = ((sin((x * 0.5d0)) / 3.0d0) * 8.0d0) * 0.5d0
else
tmp = 2.6666666666666665d0 * ((sin((0.5d0 * x)) ** 2.0d0) / sin(x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 5e-20) {
tmp = ((Math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
} else {
tmp = 2.6666666666666665 * (Math.pow(Math.sin((0.5 * x)), 2.0) / Math.sin(x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 5e-20: tmp = ((math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5 else: tmp = 2.6666666666666665 * (math.pow(math.sin((0.5 * x)), 2.0) / math.sin(x)) return tmp
function code(x) tmp = 0.0 if (x <= 5e-20) tmp = Float64(Float64(Float64(sin(Float64(x * 0.5)) / 3.0) * 8.0) * 0.5); else tmp = Float64(2.6666666666666665 * Float64((sin(Float64(0.5 * x)) ^ 2.0) / sin(x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 5e-20) tmp = ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5; else tmp = 2.6666666666666665 * ((sin((0.5 * x)) ^ 2.0) / sin(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 5e-20], N[(N[(N[(N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision] * 8.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(2.6666666666666665 * N[(N[Power[N[Sin[N[(0.5 * x), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{-20}:\\
\;\;\;\;\left(\frac{\sin \left(x \cdot 0.5\right)}{3} \cdot 8\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;2.6666666666666665 \cdot \frac{{\sin \left(0.5 \cdot x\right)}^{2}}{\sin x}\\
\end{array}
\end{array}
if x < 4.9999999999999999e-20Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites55.5%
if 4.9999999999999999e-20 < x Initial program 77.2%
Taylor expanded in x around inf
Applied rewrites77.2%
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (* (/ (* t_0 2.6666666666666665) (sin x)) t_0)))
double code(double x) {
double t_0 = sin((x * 0.5));
return ((t_0 * 2.6666666666666665) / sin(x)) * t_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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = ((t_0 * 2.6666666666666665d0) / sin(x)) * t_0
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return ((t_0 * 2.6666666666666665) / Math.sin(x)) * t_0;
}
def code(x): t_0 = math.sin((x * 0.5)) return ((t_0 * 2.6666666666666665) / math.sin(x)) * t_0
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(Float64(t_0 * 2.6666666666666665) / sin(x)) * t_0) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = ((t_0 * 2.6666666666666665) / sin(x)) * t_0; end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(t$95$0 * 2.6666666666666665), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{t\_0 \cdot 2.6666666666666665}{\sin x} \cdot t\_0
\end{array}
\end{array}
Initial program 77.2%
Taylor expanded in x around inf
Applied rewrites77.2%
Applied rewrites99.2%
Applied rewrites99.2%
(FPCore (x) :precision binary64 (let* ((t_0 (sin (* x 0.5)))) (* (/ t_0 (sin x)) (* t_0 2.6666666666666665))))
double code(double x) {
double t_0 = sin((x * 0.5));
return (t_0 / sin(x)) * (t_0 * 2.6666666666666665);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = sin((x * 0.5d0))
code = (t_0 / sin(x)) * (t_0 * 2.6666666666666665d0)
end function
public static double code(double x) {
double t_0 = Math.sin((x * 0.5));
return (t_0 / Math.sin(x)) * (t_0 * 2.6666666666666665);
}
def code(x): t_0 = math.sin((x * 0.5)) return (t_0 / math.sin(x)) * (t_0 * 2.6666666666666665)
function code(x) t_0 = sin(Float64(x * 0.5)) return Float64(Float64(t_0 / sin(x)) * Float64(t_0 * 2.6666666666666665)) end
function tmp = code(x) t_0 = sin((x * 0.5)); tmp = (t_0 / sin(x)) * (t_0 * 2.6666666666666665); end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(t$95$0 / N[Sin[x], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * 2.6666666666666665), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\frac{t\_0}{\sin x} \cdot \left(t\_0 \cdot 2.6666666666666665\right)
\end{array}
\end{array}
Initial program 77.2%
Taylor expanded in x around inf
Applied rewrites77.2%
Applied rewrites99.2%
(FPCore (x) :precision binary64 (if (<= x 8.2e-5) (* (* (/ (sin (* x 0.5)) 3.0) 8.0) 0.5) (* (- 0.5 (* (cos (* 0.5 (+ x x))) 0.5)) (/ 2.6666666666666665 (sin x)))))
double code(double x) {
double tmp;
if (x <= 8.2e-5) {
tmp = ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
} else {
tmp = (0.5 - (cos((0.5 * (x + x))) * 0.5)) * (2.6666666666666665 / sin(x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.2d-5) then
tmp = ((sin((x * 0.5d0)) / 3.0d0) * 8.0d0) * 0.5d0
else
tmp = (0.5d0 - (cos((0.5d0 * (x + x))) * 0.5d0)) * (2.6666666666666665d0 / sin(x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 8.2e-5) {
tmp = ((Math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
} else {
tmp = (0.5 - (Math.cos((0.5 * (x + x))) * 0.5)) * (2.6666666666666665 / Math.sin(x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 8.2e-5: tmp = ((math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5 else: tmp = (0.5 - (math.cos((0.5 * (x + x))) * 0.5)) * (2.6666666666666665 / math.sin(x)) return tmp
function code(x) tmp = 0.0 if (x <= 8.2e-5) tmp = Float64(Float64(Float64(sin(Float64(x * 0.5)) / 3.0) * 8.0) * 0.5); else tmp = Float64(Float64(0.5 - Float64(cos(Float64(0.5 * Float64(x + x))) * 0.5)) * Float64(2.6666666666666665 / sin(x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 8.2e-5) tmp = ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5; else tmp = (0.5 - (cos((0.5 * (x + x))) * 0.5)) * (2.6666666666666665 / sin(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 8.2e-5], N[(N[(N[(N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision] * 8.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(0.5 - N[(N[Cos[N[(0.5 * N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision] * N[(2.6666666666666665 / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.2 \cdot 10^{-5}:\\
\;\;\;\;\left(\frac{\sin \left(x \cdot 0.5\right)}{3} \cdot 8\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 - \cos \left(0.5 \cdot \left(x + x\right)\right) \cdot 0.5\right) \cdot \frac{2.6666666666666665}{\sin x}\\
\end{array}
\end{array}
if x < 8.20000000000000009e-5Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites55.5%
if 8.20000000000000009e-5 < x Initial program 77.2%
Taylor expanded in x around inf
Applied rewrites77.2%
Applied rewrites52.3%
(FPCore (x)
:precision binary64
(if (<= x 2.3)
(*
x
(+
0.6666666666666666
(*
(pow x 2.0)
(+
0.05555555555555555
(*
(pow x 2.0)
(+ 0.005555555555555556 (* 0.0005621693121693122 (pow x 2.0))))))))
(* 2.6666666666666665 (/ (sin 2.0) (sin x)))))
double code(double x) {
double tmp;
if (x <= 2.3) {
tmp = x * (0.6666666666666666 + (pow(x, 2.0) * (0.05555555555555555 + (pow(x, 2.0) * (0.005555555555555556 + (0.0005621693121693122 * pow(x, 2.0)))))));
} else {
tmp = 2.6666666666666665 * (sin(2.0) / sin(x));
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 2.3d0) then
tmp = x * (0.6666666666666666d0 + ((x ** 2.0d0) * (0.05555555555555555d0 + ((x ** 2.0d0) * (0.005555555555555556d0 + (0.0005621693121693122d0 * (x ** 2.0d0)))))))
else
tmp = 2.6666666666666665d0 * (sin(2.0d0) / sin(x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 2.3) {
tmp = x * (0.6666666666666666 + (Math.pow(x, 2.0) * (0.05555555555555555 + (Math.pow(x, 2.0) * (0.005555555555555556 + (0.0005621693121693122 * Math.pow(x, 2.0)))))));
} else {
tmp = 2.6666666666666665 * (Math.sin(2.0) / Math.sin(x));
}
return tmp;
}
def code(x): tmp = 0 if x <= 2.3: tmp = x * (0.6666666666666666 + (math.pow(x, 2.0) * (0.05555555555555555 + (math.pow(x, 2.0) * (0.005555555555555556 + (0.0005621693121693122 * math.pow(x, 2.0))))))) else: tmp = 2.6666666666666665 * (math.sin(2.0) / math.sin(x)) return tmp
function code(x) tmp = 0.0 if (x <= 2.3) tmp = Float64(x * Float64(0.6666666666666666 + Float64((x ^ 2.0) * Float64(0.05555555555555555 + Float64((x ^ 2.0) * Float64(0.005555555555555556 + Float64(0.0005621693121693122 * (x ^ 2.0)))))))); else tmp = Float64(2.6666666666666665 * Float64(sin(2.0) / sin(x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 2.3) tmp = x * (0.6666666666666666 + ((x ^ 2.0) * (0.05555555555555555 + ((x ^ 2.0) * (0.005555555555555556 + (0.0005621693121693122 * (x ^ 2.0))))))); else tmp = 2.6666666666666665 * (sin(2.0) / sin(x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 2.3], N[(x * N[(0.6666666666666666 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(0.05555555555555555 + N[(N[Power[x, 2.0], $MachinePrecision] * N[(0.005555555555555556 + N[(0.0005621693121693122 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.6666666666666665 * N[(N[Sin[2.0], $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.3:\\
\;\;\;\;x \cdot \left(0.6666666666666666 + {x}^{2} \cdot \left(0.05555555555555555 + {x}^{2} \cdot \left(0.005555555555555556 + 0.0005621693121693122 \cdot {x}^{2}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;2.6666666666666665 \cdot \frac{\sin 2}{\sin x}\\
\end{array}
\end{array}
if x < 2.2999999999999998Initial program 77.2%
Taylor expanded in x around 0
Applied rewrites50.9%
if 2.2999999999999998 < x Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
Applied rewrites11.8%
Taylor expanded in x around inf
Applied rewrites11.8%
(FPCore (x)
:precision binary64
(let* ((t_0 (sin (* x 0.5))))
(if (<= (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x)) 0.05)
(* (* (/ t_0 3.0) 8.0) 0.5)
(/
(* (* 1.3333333333333333 x) (fabs t_0))
(fma x -0.16666666666666666 x)))))
double code(double x) {
double t_0 = sin((x * 0.5));
double tmp;
if (((((8.0 / 3.0) * t_0) * t_0) / sin(x)) <= 0.05) {
tmp = ((t_0 / 3.0) * 8.0) * 0.5;
} else {
tmp = ((1.3333333333333333 * x) * fabs(t_0)) / fma(x, -0.16666666666666666, x);
}
return tmp;
}
function code(x) t_0 = sin(Float64(x * 0.5)) tmp = 0.0 if (Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) <= 0.05) tmp = Float64(Float64(Float64(t_0 / 3.0) * 8.0) * 0.5); else tmp = Float64(Float64(Float64(1.3333333333333333 * x) * abs(t_0)) / fma(x, -0.16666666666666666, x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision], 0.05], N[(N[(N[(t$95$0 / 3.0), $MachinePrecision] * 8.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.3333333333333333 * x), $MachinePrecision] * N[Abs[t$95$0], $MachinePrecision]), $MachinePrecision] / N[(x * -0.16666666666666666 + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\mathbf{if}\;\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x} \leq 0.05:\\
\;\;\;\;\left(\frac{t\_0}{3} \cdot 8\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1.3333333333333333 \cdot x\right) \cdot \left|t\_0\right|}{\mathsf{fma}\left(x, -0.16666666666666666, x\right)}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (*.f64 (/.f64 #s(literal 8 binary64) #s(literal 3 binary64)) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 x)) < 0.050000000000000003Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites55.5%
if 0.050000000000000003 < (/.f64 (*.f64 (*.f64 (/.f64 #s(literal 8 binary64) #s(literal 3 binary64)) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 x)) Initial program 77.2%
Taylor expanded in x around 0
Applied rewrites29.2%
Taylor expanded in x around 0
Applied rewrites29.3%
Applied rewrites13.2%
Applied rewrites10.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (sin (* x 0.5))))
(if (<= (/ (* (* (/ 8.0 3.0) t_0) t_0) (sin x)) 0.05)
(* (* (/ t_0 3.0) 8.0) 0.5)
(/
(* (* 1.3333333333333333 x) (sin 2.0))
(fma x -0.16666666666666666 x)))))
double code(double x) {
double t_0 = sin((x * 0.5));
double tmp;
if (((((8.0 / 3.0) * t_0) * t_0) / sin(x)) <= 0.05) {
tmp = ((t_0 / 3.0) * 8.0) * 0.5;
} else {
tmp = ((1.3333333333333333 * x) * sin(2.0)) / fma(x, -0.16666666666666666, x);
}
return tmp;
}
function code(x) t_0 = sin(Float64(x * 0.5)) tmp = 0.0 if (Float64(Float64(Float64(Float64(8.0 / 3.0) * t_0) * t_0) / sin(x)) <= 0.05) tmp = Float64(Float64(Float64(t_0 / 3.0) * 8.0) * 0.5); else tmp = Float64(Float64(Float64(1.3333333333333333 * x) * sin(2.0)) / fma(x, -0.16666666666666666, x)); end return tmp end
code[x_] := Block[{t$95$0 = N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(N[(8.0 / 3.0), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision], 0.05], N[(N[(N[(t$95$0 / 3.0), $MachinePrecision] * 8.0), $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(N[(1.3333333333333333 * x), $MachinePrecision] * N[Sin[2.0], $MachinePrecision]), $MachinePrecision] / N[(x * -0.16666666666666666 + x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(x \cdot 0.5\right)\\
\mathbf{if}\;\frac{\left(\frac{8}{3} \cdot t\_0\right) \cdot t\_0}{\sin x} \leq 0.05:\\
\;\;\;\;\left(\frac{t\_0}{3} \cdot 8\right) \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(1.3333333333333333 \cdot x\right) \cdot \sin 2}{\mathsf{fma}\left(x, -0.16666666666666666, x\right)}\\
\end{array}
\end{array}
if (/.f64 (*.f64 (*.f64 (/.f64 #s(literal 8 binary64) #s(literal 3 binary64)) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 x)) < 0.050000000000000003Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites55.5%
if 0.050000000000000003 < (/.f64 (*.f64 (*.f64 (/.f64 #s(literal 8 binary64) #s(literal 3 binary64)) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 (*.f64 x #s(literal 1/2 binary64)))) (sin.f64 x)) Initial program 77.2%
Taylor expanded in x around 0
Applied rewrites29.2%
Taylor expanded in x around 0
Applied rewrites29.3%
Applied rewrites6.9%
(FPCore (x) :precision binary64 (* (* (/ (sin (* x 0.5)) 3.0) 8.0) 0.5))
double code(double x) {
return ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
code = ((sin((x * 0.5d0)) / 3.0d0) * 8.0d0) * 0.5d0
end function
public static double code(double x) {
return ((Math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5;
}
def code(x): return ((math.sin((x * 0.5)) / 3.0) * 8.0) * 0.5
function code(x) return Float64(Float64(Float64(sin(Float64(x * 0.5)) / 3.0) * 8.0) * 0.5) end
function tmp = code(x) tmp = ((sin((x * 0.5)) / 3.0) * 8.0) * 0.5; end
code[x_] := N[(N[(N[(N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] / 3.0), $MachinePrecision] * 8.0), $MachinePrecision] * 0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{\sin \left(x \cdot 0.5\right)}{3} \cdot 8\right) \cdot 0.5
\end{array}
Initial program 77.2%
Applied rewrites99.2%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites55.5%
(FPCore (x) :precision binary64 (* 0.5 (* (sin (* x 0.5)) 2.6666666666666665)))
double code(double x) {
return 0.5 * (sin((x * 0.5)) * 2.6666666666666665);
}
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)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 0.5d0 * (sin((x * 0.5d0)) * 2.6666666666666665d0)
end function
public static double code(double x) {
return 0.5 * (Math.sin((x * 0.5)) * 2.6666666666666665);
}
def code(x): return 0.5 * (math.sin((x * 0.5)) * 2.6666666666666665)
function code(x) return Float64(0.5 * Float64(sin(Float64(x * 0.5)) * 2.6666666666666665)) end
function tmp = code(x) tmp = 0.5 * (sin((x * 0.5)) * 2.6666666666666665); end
code[x_] := N[(0.5 * N[(N[Sin[N[(x * 0.5), $MachinePrecision]], $MachinePrecision] * 2.6666666666666665), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(\sin \left(x \cdot 0.5\right) \cdot 2.6666666666666665\right)
\end{array}
Initial program 77.2%
Taylor expanded in x around inf
Applied rewrites77.2%
Applied rewrites99.2%
Taylor expanded in x around 0
Applied rewrites55.2%
(FPCore (x) :precision binary64 (* (fma (* 0.05555555555555555 0.05555555555555555) x (* 0.6666666666666666 0.6666666666666666)) (/ x (fma x 0.05555555555555555 0.6666666666666666))))
double code(double x) {
return fma((0.05555555555555555 * 0.05555555555555555), x, (0.6666666666666666 * 0.6666666666666666)) * (x / fma(x, 0.05555555555555555, 0.6666666666666666));
}
function code(x) return Float64(fma(Float64(0.05555555555555555 * 0.05555555555555555), x, Float64(0.6666666666666666 * 0.6666666666666666)) * Float64(x / fma(x, 0.05555555555555555, 0.6666666666666666))) end
code[x_] := N[(N[(N[(0.05555555555555555 * 0.05555555555555555), $MachinePrecision] * x + N[(0.6666666666666666 * 0.6666666666666666), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x * 0.05555555555555555 + 0.6666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(0.05555555555555555 \cdot 0.05555555555555555, x, 0.6666666666666666 \cdot 0.6666666666666666\right) \cdot \frac{x}{\mathsf{fma}\left(x, 0.05555555555555555, 0.6666666666666666\right)}
\end{array}
Initial program 77.2%
Taylor expanded in x around 0
Applied rewrites50.9%
Applied rewrites50.8%
(FPCore (x) :precision binary64 (* 0.6666666666666666 x))
double code(double x) {
return 0.6666666666666666 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 0.6666666666666666d0 * x
end function
public static double code(double x) {
return 0.6666666666666666 * x;
}
def code(x): return 0.6666666666666666 * x
function code(x) return Float64(0.6666666666666666 * x) end
function tmp = code(x) tmp = 0.6666666666666666 * x; end
code[x_] := N[(0.6666666666666666 * x), $MachinePrecision]
\begin{array}{l}
\\
0.6666666666666666 \cdot x
\end{array}
Initial program 77.2%
Taylor expanded in x around 0
Applied rewrites51.1%
(FPCore (x) :precision binary64 (* 0.7222222222222222 x))
double code(double x) {
return 0.7222222222222222 * 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)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 0.7222222222222222d0 * x
end function
public static double code(double x) {
return 0.7222222222222222 * x;
}
def code(x): return 0.7222222222222222 * x
function code(x) return Float64(0.7222222222222222 * x) end
function tmp = code(x) tmp = 0.7222222222222222 * x; end
code[x_] := N[(0.7222222222222222 * x), $MachinePrecision]
\begin{array}{l}
\\
0.7222222222222222 \cdot x
\end{array}
Initial program 77.2%
Taylor expanded in x around 0
Applied rewrites50.9%
Applied rewrites13.5%
Taylor expanded in x around 0
Applied rewrites13.5%
herbie shell --seed 2025159
(FPCore (x)
:name "Graphics.Rasterific.Svg.PathConverter:segmentToBezier from rasterific-svg-0.2.3.1, A"
:precision binary64
(/ (* (* (/ 8.0 3.0) (sin (* x 0.5))) (sin (* x 0.5))) (sin x)))