
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
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(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
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(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (asinh (/ eh (* (tan t) ew))))) (fabs (fma (* (cos t) eh) (tanh t_1) (* (/ (sin t) (cosh t_1)) ew)))))
double code(double eh, double ew, double t) {
double t_1 = asinh((eh / (tan(t) * ew)));
return fabs(fma((cos(t) * eh), tanh(t_1), ((sin(t) / cosh(t_1)) * ew)));
}
function code(eh, ew, t) t_1 = asinh(Float64(eh / Float64(tan(t) * ew))) return abs(fma(Float64(cos(t) * eh), tanh(t_1), Float64(Float64(sin(t) / cosh(t_1)) * ew))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcSinh[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[t$95$1], $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] / N[Cosh[t$95$1], $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sinh^{-1} \left(\frac{eh}{\tan t \cdot ew}\right)\\
\left|\mathsf{fma}\left(\cos t \cdot eh, \tanh t\_1, \frac{\sin t}{\cosh t\_1} \cdot ew\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around inf
lift-sin.f6499.8
Applied rewrites99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew)))
(t_2 (* eh (cos t)))
(t_3 (* ew (sin t)))
(t_4 (atan (/ (/ (fma (* -0.3333333333333333 (* t t)) eh eh) ew) t))))
(if (<= ew 4.4e-57)
(fabs (+ (* t_3 (cos t_4)) (* t_2 (sin t_4))))
(fabs
(fma
t_3
(/ 1.0 (sqrt (+ 1.0 (* t_1 t_1))))
(* t_2 (tanh (asinh t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
double t_2 = eh * cos(t);
double t_3 = ew * sin(t);
double t_4 = atan(((fma((-0.3333333333333333 * (t * t)), eh, eh) / ew) / t));
double tmp;
if (ew <= 4.4e-57) {
tmp = fabs(((t_3 * cos(t_4)) + (t_2 * sin(t_4))));
} else {
tmp = fabs(fma(t_3, (1.0 / sqrt((1.0 + (t_1 * t_1)))), (t_2 * tanh(asinh(t_1)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) t_2 = Float64(eh * cos(t)) t_3 = Float64(ew * sin(t)) t_4 = atan(Float64(Float64(fma(Float64(-0.3333333333333333 * Float64(t * t)), eh, eh) / ew) / t)) tmp = 0.0 if (ew <= 4.4e-57) tmp = abs(Float64(Float64(t_3 * cos(t_4)) + Float64(t_2 * sin(t_4)))); else tmp = abs(fma(t_3, Float64(1.0 / sqrt(Float64(1.0 + Float64(t_1 * t_1)))), Float64(t_2 * tanh(asinh(t_1))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[ArcTan[N[(N[(N[(N[(-0.3333333333333333 * N[(t * t), $MachinePrecision]), $MachinePrecision] * eh + eh), $MachinePrecision] / ew), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[ew, 4.4e-57], N[Abs[N[(N[(t$95$3 * N[Cos[t$95$4], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[Sin[t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$3 * N[(1.0 / N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(t$95$2 * N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
t_2 := eh \cdot \cos t\\
t_3 := ew \cdot \sin t\\
t_4 := \tan^{-1} \left(\frac{\frac{\mathsf{fma}\left(-0.3333333333333333 \cdot \left(t \cdot t\right), eh, eh\right)}{ew}}{t}\right)\\
\mathbf{if}\;ew \leq 4.4 \cdot 10^{-57}:\\
\;\;\;\;\left|t\_3 \cdot \cos t\_4 + t\_2 \cdot \sin t\_4\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(t\_3, \frac{1}{\sqrt{1 + t\_1 \cdot t\_1}}, t\_2 \cdot \tanh \sinh^{-1} t\_1\right)\right|\\
\end{array}
\end{array}
if ew < 4.39999999999999997e-57Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.6
Applied rewrites86.6%
Taylor expanded in t around 0
lower-/.f64N/A
associate-*r/N/A
div-add-revN/A
lower-/.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6486.6
Applied rewrites86.6%
if 4.39999999999999997e-57 < ew Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.8
Applied rewrites90.8%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites75.3%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
tanh-asinh-revN/A
lower-tanh.f64N/A
Applied rewrites90.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew))))
(if (<= ew 1e-180)
(fabs (* (* (tanh (asinh (* (cos t) (/ eh (* (sin t) ew))))) (cos t)) eh))
(fabs
(fma
(* ew (sin t))
(/ 1.0 (sqrt (+ 1.0 (* t_1 t_1))))
(* (* eh (cos t)) (tanh (asinh t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
double tmp;
if (ew <= 1e-180) {
tmp = fabs(((tanh(asinh((cos(t) * (eh / (sin(t) * ew))))) * cos(t)) * eh));
} else {
tmp = fabs(fma((ew * sin(t)), (1.0 / sqrt((1.0 + (t_1 * t_1)))), ((eh * cos(t)) * tanh(asinh(t_1)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) tmp = 0.0 if (ew <= 1e-180) tmp = abs(Float64(Float64(tanh(asinh(Float64(cos(t) * Float64(eh / Float64(sin(t) * ew))))) * cos(t)) * eh)); else tmp = abs(fma(Float64(ew * sin(t)), Float64(1.0 / sqrt(Float64(1.0 + Float64(t_1 * t_1)))), Float64(Float64(eh * cos(t)) * tanh(asinh(t_1))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, 1e-180], N[Abs[N[(N[(N[Tanh[N[ArcSinh[N[(N[Cos[t], $MachinePrecision] * N[(eh / N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
\mathbf{if}\;ew \leq 10^{-180}:\\
\;\;\;\;\left|\left(\tanh \sinh^{-1} \left(\cos t \cdot \frac{eh}{\sin t \cdot ew}\right) \cdot \cos t\right) \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\sqrt{1 + t\_1 \cdot t\_1}}, \left(eh \cdot \cos t\right) \cdot \tanh \sinh^{-1} t\_1\right)\right|\\
\end{array}
\end{array}
if ew < 1e-180Initial program 99.8%
Taylor expanded in eh around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites66.3%
if 1e-180 < ew Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.4
Applied rewrites90.4%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites66.0%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
tanh-asinh-revN/A
lower-tanh.f64N/A
Applied rewrites90.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew))))
(fabs
(fma
(* ew (sin t))
(/ 1.0 (sqrt (+ 1.0 (* t_1 t_1))))
(* (* eh (cos t)) (tanh (asinh t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
return fabs(fma((ew * sin(t)), (1.0 / sqrt((1.0 + (t_1 * t_1)))), ((eh * cos(t)) * tanh(asinh(t_1)))));
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) return abs(fma(Float64(ew * sin(t)), Float64(1.0 / sqrt(Float64(1.0 + Float64(t_1 * t_1)))), Float64(Float64(eh * cos(t)) * tanh(asinh(t_1))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
\left|\mathsf{fma}\left(ew \cdot \sin t, \frac{1}{\sqrt{1 + t\_1 \cdot t\_1}}, \left(eh \cdot \cos t\right) \cdot \tanh \sinh^{-1} t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites57.5%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
tanh-asinh-revN/A
lower-tanh.f64N/A
Applied rewrites89.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew)))
(t_2 (* eh (cos t)))
(t_3 (sqrt (+ 1.0 (* t_1 t_1)))))
(if (<= t 1600.0)
(fabs (fma (* ew t) (/ 1.0 t_3) (* t_2 (tanh (asinh t_1)))))
(fabs (fma (* ew (sin t)) 1.0 (* t_2 (/ t_1 t_3)))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
double t_2 = eh * cos(t);
double t_3 = sqrt((1.0 + (t_1 * t_1)));
double tmp;
if (t <= 1600.0) {
tmp = fabs(fma((ew * t), (1.0 / t_3), (t_2 * tanh(asinh(t_1)))));
} else {
tmp = fabs(fma((ew * sin(t)), 1.0, (t_2 * (t_1 / t_3))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) t_2 = Float64(eh * cos(t)) t_3 = sqrt(Float64(1.0 + Float64(t_1 * t_1))) tmp = 0.0 if (t <= 1600.0) tmp = abs(fma(Float64(ew * t), Float64(1.0 / t_3), Float64(t_2 * tanh(asinh(t_1))))); else tmp = abs(fma(Float64(ew * sin(t)), 1.0, Float64(t_2 * Float64(t_1 / t_3)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, 1600.0], N[Abs[N[(N[(ew * t), $MachinePrecision] * N[(1.0 / t$95$3), $MachinePrecision] + N[(t$95$2 * N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * 1.0 + N[(t$95$2 * N[(t$95$1 / t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
t_2 := eh \cdot \cos t\\
t_3 := \sqrt{1 + t\_1 \cdot t\_1}\\
\mathbf{if}\;t \leq 1600:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot t, \frac{1}{t\_3}, t\_2 \cdot \tanh \sinh^{-1} t\_1\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot \sin t, 1, t\_2 \cdot \frac{t\_1}{t\_3}\right)\right|\\
\end{array}
\end{array}
if t < 1600Initial program 99.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.3
Applied rewrites99.3%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.1
Applied rewrites93.1%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites54.9%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
tanh-asinh-revN/A
lower-tanh.f64N/A
Applied rewrites93.1%
Taylor expanded in t around 0
Applied rewrites77.2%
if 1600 < t Initial program 99.6%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.0
Applied rewrites98.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6479.0
Applied rewrites79.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites65.6%
Taylor expanded in eh around 0
Applied rewrites65.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew)))
(t_2 (sqrt (+ 1.0 (* t_1 t_1))))
(t_3 (/ 1.0 t_2)))
(if (<= eh 9.5e-34)
(fabs (fma (* ew (sin t)) t_3 (* eh (/ t_1 t_2))))
(fabs (fma (* ew t) t_3 (* (* eh (cos t)) (tanh (asinh t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
double t_2 = sqrt((1.0 + (t_1 * t_1)));
double t_3 = 1.0 / t_2;
double tmp;
if (eh <= 9.5e-34) {
tmp = fabs(fma((ew * sin(t)), t_3, (eh * (t_1 / t_2))));
} else {
tmp = fabs(fma((ew * t), t_3, ((eh * cos(t)) * tanh(asinh(t_1)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) t_2 = sqrt(Float64(1.0 + Float64(t_1 * t_1))) t_3 = Float64(1.0 / t_2) tmp = 0.0 if (eh <= 9.5e-34) tmp = abs(fma(Float64(ew * sin(t)), t_3, Float64(eh * Float64(t_1 / t_2)))); else tmp = abs(fma(Float64(ew * t), t_3, Float64(Float64(eh * cos(t)) * tanh(asinh(t_1))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(1.0 / t$95$2), $MachinePrecision]}, If[LessEqual[eh, 9.5e-34], N[Abs[N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * t$95$3 + N[(eh * N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * t), $MachinePrecision] * t$95$3 + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
t_2 := \sqrt{1 + t\_1 \cdot t\_1}\\
t_3 := \frac{1}{t\_2}\\
\mathbf{if}\;eh \leq 9.5 \cdot 10^{-34}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot \sin t, t\_3, eh \cdot \frac{t\_1}{t\_2}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot t, t\_3, \left(eh \cdot \cos t\right) \cdot \tanh \sinh^{-1} t\_1\right)\right|\\
\end{array}
\end{array}
if eh < 9.49999999999999985e-34Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6490.5
Applied rewrites90.5%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites64.2%
Taylor expanded in t around 0
Applied rewrites59.6%
if 9.49999999999999985e-34 < eh Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.7
Applied rewrites87.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites39.9%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
tanh-asinh-revN/A
lower-tanh.f64N/A
Applied rewrites87.7%
Taylor expanded in t around 0
Applied rewrites74.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew))))
(if (<= eh 1.68e-106)
(fabs (* ew (sin t)))
(fabs
(fma
(* ew t)
(/ 1.0 (sqrt (+ 1.0 (* t_1 t_1))))
(* (* eh (cos t)) (tanh (asinh t_1))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
double tmp;
if (eh <= 1.68e-106) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs(fma((ew * t), (1.0 / sqrt((1.0 + (t_1 * t_1)))), ((eh * cos(t)) * tanh(asinh(t_1)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) tmp = 0.0 if (eh <= 1.68e-106) tmp = abs(Float64(ew * sin(t))); else tmp = abs(fma(Float64(ew * t), Float64(1.0 / sqrt(Float64(1.0 + Float64(t_1 * t_1)))), Float64(Float64(eh * cos(t)) * tanh(asinh(t_1))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eh, 1.68e-106], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(ew * t), $MachinePrecision] * N[(1.0 / N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
\mathbf{if}\;eh \leq 1.68 \cdot 10^{-106}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot t, \frac{1}{\sqrt{1 + t\_1 \cdot t\_1}}, \left(eh \cdot \cos t\right) \cdot \tanh \sinh^{-1} t\_1\right)\right|\\
\end{array}
\end{array}
if eh < 1.6799999999999999e-106Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in eh around 0
lift-sin.f64N/A
lift-*.f6450.5
Applied rewrites50.5%
if 1.6799999999999999e-106 < eh Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.6
Applied rewrites87.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites44.6%
lift-/.f64N/A
lift-sqrt.f64N/A
lift-+.f64N/A
lift-*.f64N/A
tanh-asinh-revN/A
lower-tanh.f64N/A
Applied rewrites87.6%
Taylor expanded in t around 0
Applied rewrites72.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew))) (t_2 (sqrt (+ 1.0 (* t_1 t_1)))))
(if (<= t 7.6e-65)
(fabs (/ eh (* ew (/ 1.0 ew))))
(if (<= t 0.00048)
(fabs
(fma
(* ew t)
(/ 1.0 t_2)
(*
(* eh (+ 1.0 (* (* t t) (- (* 0.041666666666666664 (* t t)) 0.5))))
(/ t_1 t_2))))
(fabs (* ew (sin t)))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
double t_2 = sqrt((1.0 + (t_1 * t_1)));
double tmp;
if (t <= 7.6e-65) {
tmp = fabs((eh / (ew * (1.0 / ew))));
} else if (t <= 0.00048) {
tmp = fabs(fma((ew * t), (1.0 / t_2), ((eh * (1.0 + ((t * t) * ((0.041666666666666664 * (t * t)) - 0.5)))) * (t_1 / t_2))));
} else {
tmp = fabs((ew * sin(t)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) t_2 = sqrt(Float64(1.0 + Float64(t_1 * t_1))) tmp = 0.0 if (t <= 7.6e-65) tmp = abs(Float64(eh / Float64(ew * Float64(1.0 / ew)))); elseif (t <= 0.00048) tmp = abs(fma(Float64(ew * t), Float64(1.0 / t_2), Float64(Float64(eh * Float64(1.0 + Float64(Float64(t * t) * Float64(Float64(0.041666666666666664 * Float64(t * t)) - 0.5)))) * Float64(t_1 / t_2)))); else tmp = abs(Float64(ew * sin(t))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, 7.6e-65], N[Abs[N[(eh / N[(ew * N[(1.0 / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 0.00048], N[Abs[N[(N[(ew * t), $MachinePrecision] * N[(1.0 / t$95$2), $MachinePrecision] + N[(N[(eh * N[(1.0 + N[(N[(t * t), $MachinePrecision] * N[(N[(0.041666666666666664 * N[(t * t), $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
t_2 := \sqrt{1 + t\_1 \cdot t\_1}\\
\mathbf{if}\;t \leq 7.6 \cdot 10^{-65}:\\
\;\;\;\;\left|\frac{eh}{ew \cdot \frac{1}{ew}}\right|\\
\mathbf{elif}\;t \leq 0.00048:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot t, \frac{1}{t\_2}, \left(eh \cdot \left(1 + \left(t \cdot t\right) \cdot \left(0.041666666666666664 \cdot \left(t \cdot t\right) - 0.5\right)\right)\right) \cdot \frac{t\_1}{t\_2}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if t < 7.6000000000000003e-65Initial program 99.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6492.6
Applied rewrites92.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites53.7%
Taylor expanded in t around 0
cos-atan-revN/A
sin-atan-revN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
Applied rewrites13.6%
Taylor expanded in eh around 0
lower-/.f64N/A
pow-flipN/A
metadata-evalN/A
sqrt-pow1N/A
metadata-evalN/A
inv-powN/A
lower-*.f64N/A
lower-/.f6451.4
Applied rewrites51.4%
if 7.6000000000000003e-65 < t < 4.80000000000000012e-4Initial program 100.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites68.9%
Taylor expanded in t around 0
lift-*.f6468.1
Applied rewrites68.1%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.1
Applied rewrites68.1%
if 4.80000000000000012e-4 < t Initial program 99.6%
Applied rewrites99.6%
Taylor expanded in eh around 0
lift-sin.f64N/A
lift-*.f6452.4
Applied rewrites52.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (* t ew))) (t_2 (sqrt (+ 1.0 (* t_1 t_1)))))
(if (<= t 7.6e-65)
(fabs (/ eh (* ew (/ 1.0 ew))))
(if (<= t 0.00035)
(fabs
(fma
(* ew t)
(/ 1.0 t_2)
(* (* eh (- 1.0 (* 0.5 (* t t)))) (/ t_1 t_2))))
(fabs (* ew (sin t)))))))
double code(double eh, double ew, double t) {
double t_1 = eh / (t * ew);
double t_2 = sqrt((1.0 + (t_1 * t_1)));
double tmp;
if (t <= 7.6e-65) {
tmp = fabs((eh / (ew * (1.0 / ew))));
} else if (t <= 0.00035) {
tmp = fabs(fma((ew * t), (1.0 / t_2), ((eh * (1.0 - (0.5 * (t * t)))) * (t_1 / t_2))));
} else {
tmp = fabs((ew * sin(t)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / Float64(t * ew)) t_2 = sqrt(Float64(1.0 + Float64(t_1 * t_1))) tmp = 0.0 if (t <= 7.6e-65) tmp = abs(Float64(eh / Float64(ew * Float64(1.0 / ew)))); elseif (t <= 0.00035) tmp = abs(fma(Float64(ew * t), Float64(1.0 / t_2), Float64(Float64(eh * Float64(1.0 - Float64(0.5 * Float64(t * t)))) * Float64(t_1 / t_2)))); else tmp = abs(Float64(ew * sin(t))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(t * ew), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 + N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, 7.6e-65], N[Abs[N[(eh / N[(ew * N[(1.0 / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[t, 0.00035], N[Abs[N[(N[(ew * t), $MachinePrecision] * N[(1.0 / t$95$2), $MachinePrecision] + N[(N[(eh * N[(1.0 - N[(0.5 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(t$95$1 / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{t \cdot ew}\\
t_2 := \sqrt{1 + t\_1 \cdot t\_1}\\
\mathbf{if}\;t \leq 7.6 \cdot 10^{-65}:\\
\;\;\;\;\left|\frac{eh}{ew \cdot \frac{1}{ew}}\right|\\
\mathbf{elif}\;t \leq 0.00035:\\
\;\;\;\;\left|\mathsf{fma}\left(ew \cdot t, \frac{1}{t\_2}, \left(eh \cdot \left(1 - 0.5 \cdot \left(t \cdot t\right)\right)\right) \cdot \frac{t\_1}{t\_2}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if t < 7.6000000000000003e-65Initial program 99.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6492.6
Applied rewrites92.6%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites53.7%
Taylor expanded in t around 0
cos-atan-revN/A
sin-atan-revN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
Applied rewrites13.6%
Taylor expanded in eh around 0
lower-/.f64N/A
pow-flipN/A
metadata-evalN/A
sqrt-pow1N/A
metadata-evalN/A
inv-powN/A
lower-*.f64N/A
lower-/.f6451.4
Applied rewrites51.4%
if 7.6000000000000003e-65 < t < 3.49999999999999996e-4Initial program 100.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites68.9%
Taylor expanded in t around 0
lift-*.f6468.1
Applied rewrites68.1%
Taylor expanded in t around 0
fp-cancel-sign-sub-invN/A
lower--.f64N/A
metadata-evalN/A
lower-*.f64N/A
unpow2N/A
lower-*.f6468.1
Applied rewrites68.1%
if 3.49999999999999996e-4 < t Initial program 99.6%
Applied rewrites99.6%
Taylor expanded in eh around 0
lift-sin.f64N/A
lift-*.f6452.4
Applied rewrites52.4%
(FPCore (eh ew t) :precision binary64 (if (<= t 0.00016) (fabs (/ eh (* ew (/ 1.0 ew)))) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if (t <= 0.00016) {
tmp = fabs((eh / (ew * (1.0 / ew))));
} else {
tmp = fabs((ew * sin(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(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if (t <= 0.00016d0) then
tmp = abs((eh / (ew * (1.0d0 / ew))))
else
tmp = abs((ew * sin(t)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (t <= 0.00016) {
tmp = Math.abs((eh / (ew * (1.0 / ew))));
} else {
tmp = Math.abs((ew * Math.sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if t <= 0.00016: tmp = math.fabs((eh / (ew * (1.0 / ew)))) else: tmp = math.fabs((ew * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if (t <= 0.00016) tmp = abs(Float64(eh / Float64(ew * Float64(1.0 / ew)))); else tmp = abs(Float64(ew * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (t <= 0.00016) tmp = abs((eh / (ew * (1.0 / ew)))); else tmp = abs((ew * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[t, 0.00016], N[Abs[N[(eh / N[(ew * N[(1.0 / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq 0.00016:\\
\;\;\;\;\left|\frac{eh}{ew \cdot \frac{1}{ew}}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if t < 1.60000000000000013e-4Initial program 99.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6493.1
Applied rewrites93.1%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites54.8%
Taylor expanded in t around 0
cos-atan-revN/A
sin-atan-revN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
Applied rewrites13.4%
Taylor expanded in eh around 0
lower-/.f64N/A
pow-flipN/A
metadata-evalN/A
sqrt-pow1N/A
metadata-evalN/A
inv-powN/A
lower-*.f64N/A
lower-/.f6451.5
Applied rewrites51.5%
if 1.60000000000000013e-4 < t Initial program 99.6%
Applied rewrites99.6%
Taylor expanded in eh around 0
lift-sin.f64N/A
lift-*.f6452.4
Applied rewrites52.4%
(FPCore (eh ew t) :precision binary64 (if (<= eh 4.4e-56) (* ew (sin t)) (fabs (/ eh (* ew (/ 1.0 ew))))))
double code(double eh, double ew, double t) {
double tmp;
if (eh <= 4.4e-56) {
tmp = ew * sin(t);
} else {
tmp = fabs((eh / (ew * (1.0 / ew))));
}
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(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: tmp
if (eh <= 4.4d-56) then
tmp = ew * sin(t)
else
tmp = abs((eh / (ew * (1.0d0 / ew))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double tmp;
if (eh <= 4.4e-56) {
tmp = ew * Math.sin(t);
} else {
tmp = Math.abs((eh / (ew * (1.0 / ew))));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if eh <= 4.4e-56: tmp = ew * math.sin(t) else: tmp = math.fabs((eh / (ew * (1.0 / ew)))) return tmp
function code(eh, ew, t) tmp = 0.0 if (eh <= 4.4e-56) tmp = Float64(ew * sin(t)); else tmp = abs(Float64(eh / Float64(ew * Float64(1.0 / ew)))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (eh <= 4.4e-56) tmp = ew * sin(t); else tmp = abs((eh / (ew * (1.0 / ew)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[eh, 4.4e-56], N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision], N[Abs[N[(eh / N[(ew * N[(1.0 / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq 4.4 \cdot 10^{-56}:\\
\;\;\;\;ew \cdot \sin t\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{eh}{ew \cdot \frac{1}{ew}}\right|\\
\end{array}
\end{array}
if eh < 4.40000000000000008e-56Initial program 99.8%
Applied rewrites49.3%
Taylor expanded in ew around -inf
rem-square-sqrtN/A
lower-*.f64N/A
Applied rewrites12.5%
Taylor expanded in eh around 0
lift-sin.f64N/A
lift-*.f6426.1
Applied rewrites26.1%
if 4.40000000000000008e-56 < eh Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6487.7
Applied rewrites87.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites41.5%
Taylor expanded in t around 0
cos-atan-revN/A
sin-atan-revN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
Applied rewrites14.0%
Taylor expanded in eh around 0
lower-/.f64N/A
pow-flipN/A
metadata-evalN/A
sqrt-pow1N/A
metadata-evalN/A
inv-powN/A
lower-*.f64N/A
lower-/.f6452.9
Applied rewrites52.9%
(FPCore (eh ew t) :precision binary64 (fabs (/ eh (* ew (/ 1.0 ew)))))
double code(double eh, double ew, double t) {
return fabs((eh / (ew * (1.0 / ew))));
}
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(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((eh / (ew * (1.0d0 / ew))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((eh / (ew * (1.0 / ew))));
}
def code(eh, ew, t): return math.fabs((eh / (ew * (1.0 / ew))))
function code(eh, ew, t) return abs(Float64(eh / Float64(ew * Float64(1.0 / ew)))) end
function tmp = code(eh, ew, t) tmp = abs((eh / (ew * (1.0 / ew)))); end
code[eh_, ew_, t_] := N[Abs[N[(eh / N[(ew * N[(1.0 / ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{eh}{ew \cdot \frac{1}{ew}}\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.0
Applied rewrites99.0%
Taylor expanded in t around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f6489.7
Applied rewrites89.7%
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-sin.f64N/A
lower-fma.f64N/A
Applied rewrites57.5%
Taylor expanded in t around 0
cos-atan-revN/A
sin-atan-revN/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sqrt.f64N/A
Applied rewrites11.2%
Taylor expanded in eh around 0
lower-/.f64N/A
pow-flipN/A
metadata-evalN/A
sqrt-pow1N/A
metadata-evalN/A
inv-powN/A
lower-*.f64N/A
lower-/.f6442.1
Applied rewrites42.1%
herbie shell --seed 2025134
(FPCore (eh ew t)
:name "Example from Robby"
:precision binary64
(fabs (+ (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))) (* (* eh (cos t)) (sin (atan (/ (/ eh ew) (tan t))))))))