
(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}
Sampling outcomes in binary64 precision:
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 (fabs (+ (* (* eh (cos t)) (sin (atan (/ eh (* (tan t) ew))))) (* (* ew (sin t)) (cos (atan (/ (/ eh ew) (tan t))))))))
double code(double eh, double ew, double t) {
return fabs((((eh * cos(t)) * sin(atan((eh / (tan(t) * ew))))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t)))))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(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 * cos(t)) * sin(atan((eh / (tan(t) * ew))))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t)))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.cos(t)) * Math.sin(Math.atan((eh / (Math.tan(t) * ew))))) + ((ew * Math.sin(t)) * Math.cos(Math.atan(((eh / ew) / Math.tan(t)))))));
}
def code(eh, ew, t): return math.fabs((((eh * math.cos(t)) * math.sin(math.atan((eh / (math.tan(t) * ew))))) + ((ew * math.sin(t)) * math.cos(math.atan(((eh / ew) / math.tan(t)))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * cos(t)) * sin(atan(Float64(eh / Float64(tan(t) * ew))))) + Float64(Float64(ew * sin(t)) * cos(atan(Float64(Float64(eh / ew) / tan(t))))))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * cos(t)) * sin(atan((eh / (tan(t) * ew))))) + ((ew * sin(t)) * cos(atan(((eh / ew) / tan(t))))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(eh / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \cos t\right) \cdot \sin \tan^{-1} \left(\frac{eh}{\tan t \cdot ew}\right) + \left(ew \cdot \sin t\right) \cdot \cos \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\right|
\end{array}
Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (sin t))) (t_2 (atan (/ (/ eh ew) (tan t)))))
(if (<= (+ (* t_1 (cos t_2)) (* (* eh (cos t)) (sin t_2))) -2e-294)
(fabs
(*
(fma
(fma 0.008333333333333333 (* (* t t) ew) (* -0.16666666666666666 ew))
(* t t)
ew)
t))
t_1)))
double code(double eh, double ew, double t) {
double t_1 = ew * sin(t);
double t_2 = atan(((eh / ew) / tan(t)));
double tmp;
if (((t_1 * cos(t_2)) + ((eh * cos(t)) * sin(t_2))) <= -2e-294) {
tmp = fabs((fma(fma(0.008333333333333333, ((t * t) * ew), (-0.16666666666666666 * ew)), (t * t), ew) * t));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(ew * sin(t)) t_2 = atan(Float64(Float64(eh / ew) / tan(t))) tmp = 0.0 if (Float64(Float64(t_1 * cos(t_2)) + Float64(Float64(eh * cos(t)) * sin(t_2))) <= -2e-294) tmp = abs(Float64(fma(fma(0.008333333333333333, Float64(Float64(t * t) * ew), Float64(-0.16666666666666666 * ew)), Float64(t * t), ew) * t)); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(t$95$1 * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-294], N[Abs[N[(N[(N[(0.008333333333333333 * N[(N[(t * t), $MachinePrecision] * ew), $MachinePrecision] + N[(-0.16666666666666666 * ew), $MachinePrecision]), $MachinePrecision] * N[(t * t), $MachinePrecision] + ew), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \sin t\\
t_2 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\mathbf{if}\;t\_1 \cdot \cos t\_2 + \left(eh \cdot \cos t\right) \cdot \sin t\_2 \leq -2 \cdot 10^{-294}:\\
\;\;\;\;\left|\mathsf{fma}\left(\mathsf{fma}\left(0.008333333333333333, \left(t \cdot t\right) \cdot ew, -0.16666666666666666 \cdot ew\right), t \cdot t, ew\right) \cdot t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) < -2.00000000000000003e-294Initial program 99.8%
Applied rewrites58.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6437.9
Applied rewrites37.9%
Taylor expanded in t around 0
Applied rewrites19.0%
if -2.00000000000000003e-294 < (+.f64 (*.f64 (*.f64 ew (sin.f64 t)) (cos.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t))))) (*.f64 (*.f64 eh (cos.f64 t)) (sin.f64 (atan.f64 (/.f64 (/.f64 eh ew) (tan.f64 t)))))) Initial program 99.8%
Applied rewrites67.4%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6445.2
Applied rewrites45.2%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt45.2
Applied rewrites45.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (tan t))) (t_2 (* eh (cos t))))
(if (or (<= eh -1.6e+46) (not (<= eh 4.1e+71)))
(fabs (* t_2 (sin (atan (/ t_2 (* ew (sin t)))))))
(fabs
(/
(fma (sin t) ew (* (* t_1 (/ eh ew)) (cos t)))
(cosh (asinh (/ t_1 ew))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / tan(t);
double t_2 = eh * cos(t);
double tmp;
if ((eh <= -1.6e+46) || !(eh <= 4.1e+71)) {
tmp = fabs((t_2 * sin(atan((t_2 / (ew * sin(t)))))));
} else {
tmp = fabs((fma(sin(t), ew, ((t_1 * (eh / ew)) * cos(t))) / cosh(asinh((t_1 / ew)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / tan(t)) t_2 = Float64(eh * cos(t)) tmp = 0.0 if ((eh <= -1.6e+46) || !(eh <= 4.1e+71)) tmp = abs(Float64(t_2 * sin(atan(Float64(t_2 / Float64(ew * sin(t))))))); else tmp = abs(Float64(fma(sin(t), ew, Float64(Float64(t_1 * Float64(eh / ew)) * cos(t))) / cosh(asinh(Float64(t_1 / ew))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -1.6e+46], N[Not[LessEqual[eh, 4.1e+71]], $MachinePrecision]], N[Abs[N[(t$95$2 * N[Sin[N[ArcTan[N[(t$95$2 / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew + N[(N[(t$95$1 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[N[(t$95$1 / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{\tan t}\\
t_2 := eh \cdot \cos t\\
\mathbf{if}\;eh \leq -1.6 \cdot 10^{+46} \lor \neg \left(eh \leq 4.1 \cdot 10^{+71}\right):\\
\;\;\;\;\left|t\_2 \cdot \sin \tan^{-1} \left(\frac{t\_2}{ew \cdot \sin t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, ew, \left(t\_1 \cdot \frac{eh}{ew}\right) \cdot \cos t\right)}{\cosh \sinh^{-1} \left(\frac{t\_1}{ew}\right)}\right|\\
\end{array}
\end{array}
if eh < -1.5999999999999999e46 or 4.1000000000000002e71 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6490.8
Applied rewrites90.8%
if -1.5999999999999999e46 < eh < 4.1000000000000002e71Initial program 99.8%
Applied rewrites91.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6494.2
Applied rewrites94.2%
Final simplification92.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (tan t)))
(t_2 (* eh (cos t)))
(t_3 (fabs (* t_2 (sin (atan (/ t_2 (* ew (sin t))))))))
(t_4 (/ t_1 ew)))
(if (<= eh -1.6e+46)
t_3
(if (<= eh -2.05e-111)
(fabs
(/
(fma (sin t) ew (* (/ (* eh eh) (* (tan t) ew)) (cos t)))
(cosh (asinh t_4))))
(if (<= eh 4.1e+71)
(fabs
(/
(fma (sin t) ew (* (* t_1 (/ eh ew)) (cos t)))
(sqrt (+ 1.0 (pow t_4 2.0)))))
t_3)))))
double code(double eh, double ew, double t) {
double t_1 = eh / tan(t);
double t_2 = eh * cos(t);
double t_3 = fabs((t_2 * sin(atan((t_2 / (ew * sin(t)))))));
double t_4 = t_1 / ew;
double tmp;
if (eh <= -1.6e+46) {
tmp = t_3;
} else if (eh <= -2.05e-111) {
tmp = fabs((fma(sin(t), ew, (((eh * eh) / (tan(t) * ew)) * cos(t))) / cosh(asinh(t_4))));
} else if (eh <= 4.1e+71) {
tmp = fabs((fma(sin(t), ew, ((t_1 * (eh / ew)) * cos(t))) / sqrt((1.0 + pow(t_4, 2.0)))));
} else {
tmp = t_3;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / tan(t)) t_2 = Float64(eh * cos(t)) t_3 = abs(Float64(t_2 * sin(atan(Float64(t_2 / Float64(ew * sin(t))))))) t_4 = Float64(t_1 / ew) tmp = 0.0 if (eh <= -1.6e+46) tmp = t_3; elseif (eh <= -2.05e-111) tmp = abs(Float64(fma(sin(t), ew, Float64(Float64(Float64(eh * eh) / Float64(tan(t) * ew)) * cos(t))) / cosh(asinh(t_4)))); elseif (eh <= 4.1e+71) tmp = abs(Float64(fma(sin(t), ew, Float64(Float64(t_1 * Float64(eh / ew)) * cos(t))) / sqrt(Float64(1.0 + (t_4 ^ 2.0))))); else tmp = t_3; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Abs[N[(t$95$2 * N[Sin[N[ArcTan[N[(t$95$2 / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 / ew), $MachinePrecision]}, If[LessEqual[eh, -1.6e+46], t$95$3, If[LessEqual[eh, -2.05e-111], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew + N[(N[(N[(eh * eh), $MachinePrecision] / N[(N[Tan[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[t$95$4], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[eh, 4.1e+71], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew + N[(N[(t$95$1 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[t$95$4, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$3]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{\tan t}\\
t_2 := eh \cdot \cos t\\
t_3 := \left|t\_2 \cdot \sin \tan^{-1} \left(\frac{t\_2}{ew \cdot \sin t}\right)\right|\\
t_4 := \frac{t\_1}{ew}\\
\mathbf{if}\;eh \leq -1.6 \cdot 10^{+46}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;eh \leq -2.05 \cdot 10^{-111}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, ew, \frac{eh \cdot eh}{\tan t \cdot ew} \cdot \cos t\right)}{\cosh \sinh^{-1} t\_4}\right|\\
\mathbf{elif}\;eh \leq 4.1 \cdot 10^{+71}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, ew, \left(t\_1 \cdot \frac{eh}{ew}\right) \cdot \cos t\right)}{\sqrt{1 + {t\_4}^{2}}}\right|\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if eh < -1.5999999999999999e46 or 4.1000000000000002e71 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6490.8
Applied rewrites90.8%
if -1.5999999999999999e46 < eh < -2.04999999999999984e-111Initial program 99.7%
Applied rewrites85.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
frac-timesN/A
pow2N/A
*-commutativeN/A
lift-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-*.f6484.5
Applied rewrites84.5%
if -2.04999999999999984e-111 < eh < 4.1000000000000002e71Initial program 99.8%
Applied rewrites92.8%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6496.7
Applied rewrites96.7%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
rem-square-sqrtN/A
cosh-asinhN/A
lift-asinh.f64N/A
lift-cosh.f64N/A
cosh-asinhN/A
lift-asinh.f64N/A
lift-cosh.f64N/A
lower-sqrt.f64N/A
Applied rewrites92.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (tan t))) (t_2 (* eh (cos t))))
(if (or (<= eh -25000.0) (not (<= eh 4.1e+71)))
(fabs (* t_2 (sin (atan (/ t_2 (* ew (sin t)))))))
(fabs
(/
(fma (sin t) ew (* (* t_1 (/ eh ew)) (cos t)))
(sqrt (+ 1.0 (pow (/ t_1 ew) 2.0))))))))
double code(double eh, double ew, double t) {
double t_1 = eh / tan(t);
double t_2 = eh * cos(t);
double tmp;
if ((eh <= -25000.0) || !(eh <= 4.1e+71)) {
tmp = fabs((t_2 * sin(atan((t_2 / (ew * sin(t)))))));
} else {
tmp = fabs((fma(sin(t), ew, ((t_1 * (eh / ew)) * cos(t))) / sqrt((1.0 + pow((t_1 / ew), 2.0)))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / tan(t)) t_2 = Float64(eh * cos(t)) tmp = 0.0 if ((eh <= -25000.0) || !(eh <= 4.1e+71)) tmp = abs(Float64(t_2 * sin(atan(Float64(t_2 / Float64(ew * sin(t))))))); else tmp = abs(Float64(fma(sin(t), ew, Float64(Float64(t_1 * Float64(eh / ew)) * cos(t))) / sqrt(Float64(1.0 + (Float64(t_1 / ew) ^ 2.0))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -25000.0], N[Not[LessEqual[eh, 4.1e+71]], $MachinePrecision]], N[Abs[N[(t$95$2 * N[Sin[N[ArcTan[N[(t$95$2 / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew + N[(N[(t$95$1 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 + N[Power[N[(t$95$1 / ew), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{\tan t}\\
t_2 := eh \cdot \cos t\\
\mathbf{if}\;eh \leq -25000 \lor \neg \left(eh \leq 4.1 \cdot 10^{+71}\right):\\
\;\;\;\;\left|t\_2 \cdot \sin \tan^{-1} \left(\frac{t\_2}{ew \cdot \sin t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, ew, \left(t\_1 \cdot \frac{eh}{ew}\right) \cdot \cos t\right)}{\sqrt{1 + {\left(\frac{t\_1}{ew}\right)}^{2}}}\right|\\
\end{array}
\end{array}
if eh < -25000 or 4.1000000000000002e71 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6489.1
Applied rewrites89.1%
if -25000 < eh < 4.1000000000000002e71Initial program 99.8%
Applied rewrites92.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6495.6
Applied rewrites95.6%
lift-cosh.f64N/A
lift-asinh.f64N/A
cosh-asinhN/A
rem-square-sqrtN/A
cosh-asinhN/A
lift-asinh.f64N/A
lift-cosh.f64N/A
cosh-asinhN/A
lift-asinh.f64N/A
lift-cosh.f64N/A
lower-sqrt.f64N/A
Applied rewrites88.7%
Final simplification88.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* ew (sin t))) (t_2 (* eh (cos t))))
(if (or (<= eh -4.1e-111) (not (<= eh 1.12e-41)))
(fabs (* t_2 (sin (atan (/ t_2 t_1)))))
(fabs t_1))))
double code(double eh, double ew, double t) {
double t_1 = ew * sin(t);
double t_2 = eh * cos(t);
double tmp;
if ((eh <= -4.1e-111) || !(eh <= 1.12e-41)) {
tmp = fabs((t_2 * sin(atan((t_2 / t_1)))));
} else {
tmp = fabs(t_1);
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = ew * sin(t)
t_2 = eh * cos(t)
if ((eh <= (-4.1d-111)) .or. (.not. (eh <= 1.12d-41))) then
tmp = abs((t_2 * sin(atan((t_2 / t_1)))))
else
tmp = abs(t_1)
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = ew * Math.sin(t);
double t_2 = eh * Math.cos(t);
double tmp;
if ((eh <= -4.1e-111) || !(eh <= 1.12e-41)) {
tmp = Math.abs((t_2 * Math.sin(Math.atan((t_2 / t_1)))));
} else {
tmp = Math.abs(t_1);
}
return tmp;
}
def code(eh, ew, t): t_1 = ew * math.sin(t) t_2 = eh * math.cos(t) tmp = 0 if (eh <= -4.1e-111) or not (eh <= 1.12e-41): tmp = math.fabs((t_2 * math.sin(math.atan((t_2 / t_1))))) else: tmp = math.fabs(t_1) return tmp
function code(eh, ew, t) t_1 = Float64(ew * sin(t)) t_2 = Float64(eh * cos(t)) tmp = 0.0 if ((eh <= -4.1e-111) || !(eh <= 1.12e-41)) tmp = abs(Float64(t_2 * sin(atan(Float64(t_2 / t_1))))); else tmp = abs(t_1); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = ew * sin(t); t_2 = eh * cos(t); tmp = 0.0; if ((eh <= -4.1e-111) || ~((eh <= 1.12e-41))) tmp = abs((t_2 * sin(atan((t_2 / t_1))))); else tmp = abs(t_1); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -4.1e-111], N[Not[LessEqual[eh, 1.12e-41]], $MachinePrecision]], N[Abs[N[(t$95$2 * N[Sin[N[ArcTan[N[(t$95$2 / t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[t$95$1], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := ew \cdot \sin t\\
t_2 := eh \cdot \cos t\\
\mathbf{if}\;eh \leq -4.1 \cdot 10^{-111} \lor \neg \left(eh \leq 1.12 \cdot 10^{-41}\right):\\
\;\;\;\;\left|t\_2 \cdot \sin \tan^{-1} \left(\frac{t\_2}{t\_1}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1\right|\\
\end{array}
\end{array}
if eh < -4.09999999999999968e-111 or 1.11999999999999999e-41 < eh Initial program 99.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6499.8
Applied rewrites99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-cos.f64N/A
lower-*.f64N/A
lower-sin.f6480.6
Applied rewrites80.6%
if -4.09999999999999968e-111 < eh < 1.11999999999999999e-41Initial program 99.8%
Applied rewrites93.0%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6480.0
Applied rewrites80.0%
Final simplification80.4%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ eh (tan t))))
(if (or (<= t -3.9e-56) (not (<= t 1.55e-75)))
(fabs (/ (fma (sin t) ew (* (* t_1 (/ eh ew)) (cos t))) 1.0))
(fabs (* (tanh (asinh (/ t_1 ew))) eh)))))
double code(double eh, double ew, double t) {
double t_1 = eh / tan(t);
double tmp;
if ((t <= -3.9e-56) || !(t <= 1.55e-75)) {
tmp = fabs((fma(sin(t), ew, ((t_1 * (eh / ew)) * cos(t))) / 1.0));
} else {
tmp = fabs((tanh(asinh((t_1 / ew))) * eh));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh / tan(t)) tmp = 0.0 if ((t <= -3.9e-56) || !(t <= 1.55e-75)) tmp = abs(Float64(fma(sin(t), ew, Float64(Float64(t_1 * Float64(eh / ew)) * cos(t))) / 1.0)); else tmp = abs(Float64(tanh(asinh(Float64(t_1 / ew))) * eh)); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t, -3.9e-56], N[Not[LessEqual[t, 1.55e-75]], $MachinePrecision]], N[Abs[N[(N[(N[Sin[t], $MachinePrecision] * ew + N[(N[(t$95$1 * N[(eh / ew), $MachinePrecision]), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Tanh[N[ArcSinh[N[(t$95$1 / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{\tan t}\\
\mathbf{if}\;t \leq -3.9 \cdot 10^{-56} \lor \neg \left(t \leq 1.55 \cdot 10^{-75}\right):\\
\;\;\;\;\left|\frac{\mathsf{fma}\left(\sin t, ew, \left(t\_1 \cdot \frac{eh}{ew}\right) \cdot \cos t\right)}{1}\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\tanh \sinh^{-1} \left(\frac{t\_1}{ew}\right) \cdot eh\right|\\
\end{array}
\end{array}
if t < -3.9e-56 or 1.55000000000000003e-75 < t Initial program 99.7%
Applied rewrites71.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6472.3
Applied rewrites72.3%
Taylor expanded in eh around 0
Applied rewrites53.0%
if -3.9e-56 < t < 1.55000000000000003e-75Initial program 100.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6477.4
Applied rewrites77.4%
Applied rewrites77.4%
Final simplification63.0%
(FPCore (eh ew t) :precision binary64 (if (or (<= eh -2.3e-109) (not (<= eh 4.1e+46))) (fabs (* (tanh (asinh (/ (/ eh (tan t)) ew))) eh)) (fabs (* ew (sin t)))))
double code(double eh, double ew, double t) {
double tmp;
if ((eh <= -2.3e-109) || !(eh <= 4.1e+46)) {
tmp = fabs((tanh(asinh(((eh / tan(t)) / ew))) * eh));
} else {
tmp = fabs((ew * sin(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if (eh <= -2.3e-109) or not (eh <= 4.1e+46): tmp = math.fabs((math.tanh(math.asinh(((eh / math.tan(t)) / ew))) * eh)) else: tmp = math.fabs((ew * math.sin(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if ((eh <= -2.3e-109) || !(eh <= 4.1e+46)) tmp = abs(Float64(tanh(asinh(Float64(Float64(eh / tan(t)) / ew))) * eh)); else tmp = abs(Float64(ew * sin(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if ((eh <= -2.3e-109) || ~((eh <= 4.1e+46))) tmp = abs((tanh(asinh(((eh / tan(t)) / ew))) * eh)); else tmp = abs((ew * sin(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[Or[LessEqual[eh, -2.3e-109], N[Not[LessEqual[eh, 4.1e+46]], $MachinePrecision]], N[Abs[N[(N[Tanh[N[ArcSinh[N[(N[(eh / N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;eh \leq -2.3 \cdot 10^{-109} \lor \neg \left(eh \leq 4.1 \cdot 10^{+46}\right):\\
\;\;\;\;\left|\tanh \sinh^{-1} \left(\frac{\frac{eh}{\tan t}}{ew}\right) \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\end{array}
\end{array}
if eh < -2.3000000000000001e-109 or 4.1e46 < eh Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6455.1
Applied rewrites55.1%
Applied rewrites55.1%
if -2.3000000000000001e-109 < eh < 4.1e46Initial program 99.8%
Applied rewrites93.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6473.9
Applied rewrites73.9%
Final simplification62.7%
(FPCore (eh ew t)
:precision binary64
(if (or (<= t -1.9e-56) (not (<= t 1.08e-75)))
(fabs (* ew (sin t)))
(fabs
(*
(sin
(atan (/ (fma (* t t) (* (/ eh ew) -0.3333333333333333) (/ eh ew)) t)))
eh))))
double code(double eh, double ew, double t) {
double tmp;
if ((t <= -1.9e-56) || !(t <= 1.08e-75)) {
tmp = fabs((ew * sin(t)));
} else {
tmp = fabs((sin(atan((fma((t * t), ((eh / ew) * -0.3333333333333333), (eh / ew)) / t))) * eh));
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if ((t <= -1.9e-56) || !(t <= 1.08e-75)) tmp = abs(Float64(ew * sin(t))); else tmp = abs(Float64(sin(atan(Float64(fma(Float64(t * t), Float64(Float64(eh / ew) * -0.3333333333333333), Float64(eh / ew)) / t))) * eh)); end return tmp end
code[eh_, ew_, t_] := If[Or[LessEqual[t, -1.9e-56], N[Not[LessEqual[t, 1.08e-75]], $MachinePrecision]], N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Sin[N[ArcTan[N[(N[(N[(t * t), $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + N[(eh / ew), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.9 \cdot 10^{-56} \lor \neg \left(t \leq 1.08 \cdot 10^{-75}\right):\\
\;\;\;\;\left|ew \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\sin \tan^{-1} \left(\frac{\mathsf{fma}\left(t \cdot t, \frac{eh}{ew} \cdot -0.3333333333333333, \frac{eh}{ew}\right)}{t}\right) \cdot eh\right|\\
\end{array}
\end{array}
if t < -1.9000000000000001e-56 or 1.08e-75 < t Initial program 99.7%
Applied rewrites71.7%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6452.2
Applied rewrites52.2%
if -1.9000000000000001e-56 < t < 1.08e-75Initial program 100.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lower-cos.f64N/A
lower-/.f64N/A
lower-sin.f6477.4
Applied rewrites77.4%
Taylor expanded in t around 0
Applied rewrites60.2%
Final simplification55.5%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (sin t))))
double code(double eh, double ew, double t) {
return fabs((ew * sin(t)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((ew * sin(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.sin(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.sin(t)))
function code(eh, ew, t) return abs(Float64(ew * sin(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * sin(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot \sin t\right|
\end{array}
Initial program 99.8%
Applied rewrites63.0%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6441.5
Applied rewrites41.5%
(FPCore (eh ew t) :precision binary64 (fabs (* (fma (* -0.16666666666666666 ew) (* t t) ew) t)))
double code(double eh, double ew, double t) {
return fabs((fma((-0.16666666666666666 * ew), (t * t), ew) * t));
}
function code(eh, ew, t) return abs(Float64(fma(Float64(-0.16666666666666666 * ew), Float64(t * t), ew) * t)) end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(-0.16666666666666666 * ew), $MachinePrecision] * N[(t * t), $MachinePrecision] + ew), $MachinePrecision] * t), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\mathsf{fma}\left(-0.16666666666666666 \cdot ew, t \cdot t, ew\right) \cdot t\right|
\end{array}
Initial program 99.8%
Applied rewrites63.0%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6441.5
Applied rewrites41.5%
Taylor expanded in t around 0
Applied rewrites18.1%
(FPCore (eh ew t) :precision binary64 (fabs (* ew t)))
double code(double eh, double ew, double t) {
return fabs((ew * t));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((ew * t))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * t));
}
def code(eh, ew, t): return math.fabs((ew * t))
function code(eh, ew, t) return abs(Float64(ew * t)) end
function tmp = code(eh, ew, t) tmp = abs((ew * t)); end
code[eh_, ew_, t_] := N[Abs[N[(ew * t), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|ew \cdot t\right|
\end{array}
Initial program 99.8%
Applied rewrites63.0%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-sin.f6441.5
Applied rewrites41.5%
Taylor expanded in t around 0
Applied rewrites18.0%
herbie shell --seed 2024362
(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))))))))