
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (* (- eh) (tan t)) ew)))) (fabs (- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((-eh * tan(t)) / ew));
return fabs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(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 * tan(t)) / ew))
code = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((-eh * Math.tan(t)) / ew));
return Math.abs((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((-eh * math.tan(t)) / ew)) return math.fabs((((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((-eh * tan(t)) / ew)); tmp = abs((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[((-eh) * N[Tan[t], $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\\
\left|\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* eh (sin t)) (sin (atan (/ (* eh (tan t)) (- ew))))) (* (* (cos (atan (* (/ (tan t) ew) eh))) ew) (cos t)))))
double code(double eh, double ew, double t) {
return fabs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * ew) * cos(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 * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * ew) * cos(t))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((eh * Math.sin(t)) * Math.sin(Math.atan(((eh * Math.tan(t)) / -ew)))) - ((Math.cos(Math.atan(((Math.tan(t) / ew) * eh))) * ew) * Math.cos(t))));
}
def code(eh, ew, t): return math.fabs((((eh * math.sin(t)) * math.sin(math.atan(((eh * math.tan(t)) / -ew)))) - ((math.cos(math.atan(((math.tan(t) / ew) * eh))) * ew) * math.cos(t))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(eh * tan(t)) / Float64(-ew))))) - Float64(Float64(cos(atan(Float64(Float64(tan(t) / ew) * eh))) * ew) * cos(t)))) end
function tmp = code(eh, ew, t) tmp = abs((((eh * sin(t)) * sin(atan(((eh * tan(t)) / -ew)))) - ((cos(atan(((tan(t) / ew) * eh))) * ew) * cos(t)))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right) - \left(\cos \tan^{-1} \left(\frac{\tan t}{ew} \cdot eh\right) \cdot ew\right) \cdot \cos t\right|
\end{array}
Initial program 99.8%
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-*.f64N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (tan t) ew))
(t_2 (atan (/ (* eh (tan t)) (- ew))))
(t_3 (* eh t_1))
(t_4 (* (cos t) ew))
(t_5 (- (* (* ew (cos t)) (cos t_2)) (* (* eh (sin t)) (sin t_2))))
(t_6 (atan (* t_1 eh))))
(if (<= t_5 -1e+72)
(fabs
(*
(fma
(/ eh ew)
(* (- (sin t)) (tanh (asinh (* t_1 (- eh)))))
(* (cos (atan (/ (* eh t) ew))) (cos t)))
ew))
(if (<= t_5 -2e-300)
(/ (- (fma (* t_3 eh) (sin t) t_4)) (cosh (asinh t_3)))
(fma (* (sin t_6) (sin t)) eh (* t_4 (cos t_6)))))))
double code(double eh, double ew, double t) {
double t_1 = tan(t) / ew;
double t_2 = atan(((eh * tan(t)) / -ew));
double t_3 = eh * t_1;
double t_4 = cos(t) * ew;
double t_5 = ((ew * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2));
double t_6 = atan((t_1 * eh));
double tmp;
if (t_5 <= -1e+72) {
tmp = fabs((fma((eh / ew), (-sin(t) * tanh(asinh((t_1 * -eh)))), (cos(atan(((eh * t) / ew))) * cos(t))) * ew));
} else if (t_5 <= -2e-300) {
tmp = -fma((t_3 * eh), sin(t), t_4) / cosh(asinh(t_3));
} else {
tmp = fma((sin(t_6) * sin(t)), eh, (t_4 * cos(t_6)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(tan(t) / ew) t_2 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) t_3 = Float64(eh * t_1) t_4 = Float64(cos(t) * ew) t_5 = Float64(Float64(Float64(ew * cos(t)) * cos(t_2)) - Float64(Float64(eh * sin(t)) * sin(t_2))) t_6 = atan(Float64(t_1 * eh)) tmp = 0.0 if (t_5 <= -1e+72) tmp = abs(Float64(fma(Float64(eh / ew), Float64(Float64(-sin(t)) * tanh(asinh(Float64(t_1 * Float64(-eh))))), Float64(cos(atan(Float64(Float64(eh * t) / ew))) * cos(t))) * ew)); elseif (t_5 <= -2e-300) tmp = Float64(Float64(-fma(Float64(t_3 * eh), sin(t), t_4)) / cosh(asinh(t_3))); else tmp = fma(Float64(sin(t_6) * sin(t)), eh, Float64(t_4 * cos(t_6))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(eh * t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[ArcTan[N[(t$95$1 * eh), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$5, -1e+72], N[Abs[N[(N[(N[(eh / ew), $MachinePrecision] * N[((-N[Sin[t], $MachinePrecision]) * N[Tanh[N[ArcSinh[N[(t$95$1 * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[ArcTan[N[(N[(eh * t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], If[LessEqual[t$95$5, -2e-300], N[((-N[(N[(t$95$3 * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + t$95$4), $MachinePrecision]) / N[Cosh[N[ArcSinh[t$95$3], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(N[Sin[t$95$6], $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * eh + N[(t$95$4 * N[Cos[t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\tan t}{ew}\\
t_2 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
t_3 := eh \cdot t\_1\\
t_4 := \cos t \cdot ew\\
t_5 := \left(ew \cdot \cos t\right) \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2\\
t_6 := \tan^{-1} \left(t\_1 \cdot eh\right)\\
\mathbf{if}\;t\_5 \leq -1 \cdot 10^{+72}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{eh}{ew}, \left(-\sin t\right) \cdot \tanh \sinh^{-1} \left(t\_1 \cdot \left(-eh\right)\right), \cos \tan^{-1} \left(\frac{eh \cdot t}{ew}\right) \cdot \cos t\right) \cdot ew\right|\\
\mathbf{elif}\;t\_5 \leq -2 \cdot 10^{-300}:\\
\;\;\;\;\frac{-\mathsf{fma}\left(t\_3 \cdot eh, \sin t, t\_4\right)}{\cosh \sinh^{-1} t\_3}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sin t\_6 \cdot \sin t, eh, t\_4 \cdot \cos t\_6\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -9.99999999999999944e71Initial program 99.9%
Taylor expanded in ew around inf
Applied rewrites87.4%
Applied rewrites87.4%
Taylor expanded in t around 0
Applied rewrites86.2%
if -9.99999999999999944e71 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -2.00000000000000005e-300Initial program 99.8%
Applied rewrites80.0%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrt80.6
lift-neg.f64N/A
lift-/.f64N/A
Applied rewrites93.6%
if -2.00000000000000005e-300 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
lift-fabs.f64N/A
rem-sqrt-square-revN/A
sqrt-prodN/A
rem-square-sqrt99.8
lift--.f64N/A
lift-*.f64N/A
Applied rewrites99.8%
Final simplification94.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (cos t) ew))
(t_2 (atan (/ (* eh (tan t)) (- ew))))
(t_3 (/ (tan t) ew))
(t_4 (* eh t_3)))
(if (<=
(- (* (* ew (cos t)) (cos t_2)) (* (* eh (sin t)) (sin t_2)))
-2e-300)
(/ (- (fma (* t_4 eh) (sin t) t_1)) (cosh (asinh t_4)))
(/
(+ t_1 (* (* (sin t) eh) (* (/ eh ew) (tan t))))
(cosh (asinh (* t_3 eh)))))))
double code(double eh, double ew, double t) {
double t_1 = cos(t) * ew;
double t_2 = atan(((eh * tan(t)) / -ew));
double t_3 = tan(t) / ew;
double t_4 = eh * t_3;
double tmp;
if ((((ew * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2))) <= -2e-300) {
tmp = -fma((t_4 * eh), sin(t), t_1) / cosh(asinh(t_4));
} else {
tmp = (t_1 + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / cosh(asinh((t_3 * eh)));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(cos(t) * ew) t_2 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) t_3 = Float64(tan(t) / ew) t_4 = Float64(eh * t_3) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_2)) - Float64(Float64(eh * sin(t)) * sin(t_2))) <= -2e-300) tmp = Float64(Float64(-fma(Float64(t_4 * eh), sin(t), t_1)) / cosh(asinh(t_4))); else tmp = Float64(Float64(t_1 + Float64(Float64(sin(t) * eh) * Float64(Float64(eh / ew) * tan(t)))) / cosh(asinh(Float64(t_3 * eh)))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]}, Block[{t$95$4 = N[(eh * t$95$3), $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$2], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-300], N[((-N[(N[(t$95$4 * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + t$95$1), $MachinePrecision]) / N[Cosh[N[ArcSinh[t$95$4], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 + N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Cosh[N[ArcSinh[N[(t$95$3 * eh), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \cos t \cdot ew\\
t_2 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
t_3 := \frac{\tan t}{ew}\\
t_4 := eh \cdot t\_3\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2 \leq -2 \cdot 10^{-300}:\\
\;\;\;\;\frac{-\mathsf{fma}\left(t\_4 \cdot eh, \sin t, t\_1\right)}{\cosh \sinh^{-1} t\_4}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 + \left(\sin t \cdot eh\right) \cdot \left(\frac{eh}{ew} \cdot \tan t\right)}{\cosh \sinh^{-1} \left(t\_3 \cdot eh\right)}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -2.00000000000000005e-300Initial program 99.9%
Applied rewrites65.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrt65.8
lift-neg.f64N/A
lift-/.f64N/A
Applied rewrites80.1%
if -2.00000000000000005e-300 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites78.1%
Final simplification79.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* eh (/ (tan t) ew)))
(t_2 (fma (* t_1 eh) (sin t) (* (cos t) ew)))
(t_3 (atan (/ (* eh (tan t)) (- ew))))
(t_4 (cosh (asinh t_1))))
(if (<=
(- (* (* ew (cos t)) (cos t_3)) (* (* eh (sin t)) (sin t_3)))
-2e-300)
(/ (- t_2) t_4)
(/ t_2 t_4))))
double code(double eh, double ew, double t) {
double t_1 = eh * (tan(t) / ew);
double t_2 = fma((t_1 * eh), sin(t), (cos(t) * ew));
double t_3 = atan(((eh * tan(t)) / -ew));
double t_4 = cosh(asinh(t_1));
double tmp;
if ((((ew * cos(t)) * cos(t_3)) - ((eh * sin(t)) * sin(t_3))) <= -2e-300) {
tmp = -t_2 / t_4;
} else {
tmp = t_2 / t_4;
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(eh * Float64(tan(t) / ew)) t_2 = fma(Float64(t_1 * eh), sin(t), Float64(cos(t) * ew)) t_3 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) t_4 = cosh(asinh(t_1)) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_3)) - Float64(Float64(eh * sin(t)) * sin(t_3))) <= -2e-300) tmp = Float64(Float64(-t_2) / t_4); else tmp = Float64(t_2 / t_4); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh * N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision] + N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Cosh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$3], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-300], N[((-t$95$2) / t$95$4), $MachinePrecision], N[(t$95$2 / t$95$4), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := eh \cdot \frac{\tan t}{ew}\\
t_2 := \mathsf{fma}\left(t\_1 \cdot eh, \sin t, \cos t \cdot ew\right)\\
t_3 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
t_4 := \cosh \sinh^{-1} t\_1\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_3 - \left(eh \cdot \sin t\right) \cdot \sin t\_3 \leq -2 \cdot 10^{-300}:\\
\;\;\;\;\frac{-t\_2}{t\_4}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_2}{t\_4}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -2.00000000000000005e-300Initial program 99.9%
Applied rewrites65.4%
lift-*.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrt65.8
lift-neg.f64N/A
lift-/.f64N/A
Applied rewrites80.1%
if -2.00000000000000005e-300 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites0.0%
lift-*.f64N/A
sqr-neg-revN/A
distribute-rgt-neg-outN/A
Applied rewrites78.1%
Final simplification79.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (* eh (tan t)) (- ew)))))
(if (<=
(- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1)))
-2e-300)
(*
(- ew)
(fma (* (* (* (/ (tan t) ew) eh) eh) (sin t)) (/ -0.5 (- ew)) (cos t)))
(/ (+ (* (cos t) ew) (* (* (sin t) eh) (* (/ eh ew) (tan t)))) 1.0))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
double tmp;
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -2e-300) {
tmp = -ew * fma(((((tan(t) / ew) * eh) * eh) * sin(t)), (-0.5 / -ew), cos(t));
} else {
tmp = ((cos(t) * ew) + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / 1.0;
}
return tmp;
}
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1))) <= -2e-300) tmp = Float64(Float64(-ew) * fma(Float64(Float64(Float64(Float64(tan(t) / ew) * eh) * eh) * sin(t)), Float64(-0.5 / Float64(-ew)), cos(t))); else tmp = Float64(Float64(Float64(cos(t) * ew) + Float64(Float64(sin(t) * eh) * Float64(Float64(eh / ew) * tan(t)))) / 1.0); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-300], N[((-ew) * N[(N[(N[(N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * eh), $MachinePrecision] * eh), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[(-0.5 / (-ew)), $MachinePrecision] + N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1 \leq -2 \cdot 10^{-300}:\\
\;\;\;\;\left(-ew\right) \cdot \mathsf{fma}\left(\left(\left(\frac{\tan t}{ew} \cdot eh\right) \cdot eh\right) \cdot \sin t, \frac{-0.5}{-ew}, \cos t\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos t \cdot ew + \left(\sin t \cdot eh\right) \cdot \left(\frac{eh}{ew} \cdot \tan t\right)}{1}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -2.00000000000000005e-300Initial program 99.9%
Applied rewrites65.4%
Taylor expanded in ew around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f64N/A
lower-neg.f64N/A
associate-*r*N/A
unpow2N/A
rem-square-sqrtN/A
Applied rewrites49.6%
Applied rewrites64.5%
if -2.00000000000000005e-300 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites78.1%
Taylor expanded in eh around 0
Applied rewrites60.6%
Final simplification62.5%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (* eh (tan t)) (- ew)))))
(if (<=
(- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1)))
-2e-300)
(* (- (cos t)) ew)
(/ (+ (* (cos t) ew) (* (* (sin t) eh) (* (/ eh ew) (tan t)))) 1.0))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
double tmp;
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -2e-300) {
tmp = -cos(t) * ew;
} else {
tmp = ((cos(t) * ew) + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / 1.0;
}
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) :: tmp
t_1 = atan(((eh * tan(t)) / -ew))
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= (-2d-300)) then
tmp = -cos(t) * ew
else
tmp = ((cos(t) * ew) + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / 1.0d0
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh * Math.tan(t)) / -ew));
double tmp;
if ((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))) <= -2e-300) {
tmp = -Math.cos(t) * ew;
} else {
tmp = ((Math.cos(t) * ew) + ((Math.sin(t) * eh) * ((eh / ew) * Math.tan(t)))) / 1.0;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) tmp = 0 if (((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))) <= -2e-300: tmp = -math.cos(t) * ew else: tmp = ((math.cos(t) * ew) + ((math.sin(t) * eh) * ((eh / ew) * math.tan(t)))) / 1.0 return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1))) <= -2e-300) tmp = Float64(Float64(-cos(t)) * ew); else tmp = Float64(Float64(Float64(cos(t) * ew) + Float64(Float64(sin(t) * eh) * Float64(Float64(eh / ew) * tan(t)))) / 1.0); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = 0.0; if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -2e-300) tmp = -cos(t) * ew; else tmp = ((cos(t) * ew) + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / 1.0; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-300], N[((-N[Cos[t], $MachinePrecision]) * ew), $MachinePrecision], N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1 \leq -2 \cdot 10^{-300}:\\
\;\;\;\;\left(-\cos t\right) \cdot ew\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos t \cdot ew + \left(\sin t \cdot eh\right) \cdot \left(\frac{eh}{ew} \cdot \tan t\right)}{1}\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -2.00000000000000005e-300Initial program 99.9%
Applied rewrites65.4%
Taylor expanded in t around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in eh around 0
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f6464.0
Applied rewrites64.0%
if -2.00000000000000005e-300 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites78.1%
Taylor expanded in eh around 0
Applied rewrites60.6%
Final simplification62.3%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (* eh (tan t)) (- ew)))))
(if (<=
(- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1)))
-2e-300)
(* (- (cos t)) ew)
(* (cos t) ew))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
double tmp;
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -2e-300) {
tmp = -cos(t) * ew;
} else {
tmp = cos(t) * 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) :: t_1
real(8) :: tmp
t_1 = atan(((eh * tan(t)) / -ew))
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= (-2d-300)) then
tmp = -cos(t) * ew
else
tmp = cos(t) * ew
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh * Math.tan(t)) / -ew));
double tmp;
if ((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))) <= -2e-300) {
tmp = -Math.cos(t) * ew;
} else {
tmp = Math.cos(t) * ew;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) tmp = 0 if (((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))) <= -2e-300: tmp = -math.cos(t) * ew else: tmp = math.cos(t) * ew return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1))) <= -2e-300) tmp = Float64(Float64(-cos(t)) * ew); else tmp = Float64(cos(t) * ew); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = 0.0; if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -2e-300) tmp = -cos(t) * ew; else tmp = cos(t) * ew; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-300], N[((-N[Cos[t], $MachinePrecision]) * ew), $MachinePrecision], N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1 \leq -2 \cdot 10^{-300}:\\
\;\;\;\;\left(-\cos t\right) \cdot ew\\
\mathbf{else}:\\
\;\;\;\;\cos t \cdot ew\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -2.00000000000000005e-300Initial program 99.9%
Applied rewrites65.4%
Taylor expanded in t around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in eh around 0
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f6464.0
Applied rewrites64.0%
if -2.00000000000000005e-300 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites0.0%
lift-*.f64N/A
pow2N/A
lower-pow.f640.0
Applied rewrites77.7%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6460.2
Applied rewrites60.2%
Final simplification62.1%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (atan (/ (* eh (tan t)) (- ew)))))
(if (<=
(- (* (* ew (cos t)) (cos t_1)) (* (* eh (sin t)) (sin t_1)))
-2e-300)
(- ew)
(* (cos t) ew))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh * tan(t)) / -ew));
double tmp;
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -2e-300) {
tmp = -ew;
} else {
tmp = cos(t) * 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) :: t_1
real(8) :: tmp
t_1 = atan(((eh * tan(t)) / -ew))
if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= (-2d-300)) then
tmp = -ew
else
tmp = cos(t) * ew
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh * Math.tan(t)) / -ew));
double tmp;
if ((((ew * Math.cos(t)) * Math.cos(t_1)) - ((eh * Math.sin(t)) * Math.sin(t_1))) <= -2e-300) {
tmp = -ew;
} else {
tmp = Math.cos(t) * ew;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.atan(((eh * math.tan(t)) / -ew)) tmp = 0 if (((ew * math.cos(t)) * math.cos(t_1)) - ((eh * math.sin(t)) * math.sin(t_1))) <= -2e-300: tmp = -ew else: tmp = math.cos(t) * ew return tmp
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh * tan(t)) / Float64(-ew))) tmp = 0.0 if (Float64(Float64(Float64(ew * cos(t)) * cos(t_1)) - Float64(Float64(eh * sin(t)) * sin(t_1))) <= -2e-300) tmp = Float64(-ew); else tmp = Float64(cos(t) * ew); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = atan(((eh * tan(t)) / -ew)); tmp = 0.0; if ((((ew * cos(t)) * cos(t_1)) - ((eh * sin(t)) * sin(t_1))) <= -2e-300) tmp = -ew; else tmp = cos(t) * ew; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh * N[Tan[t], $MachinePrecision]), $MachinePrecision] / (-ew)), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] - N[(N[(eh * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -2e-300], (-ew), N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{eh \cdot \tan t}{-ew}\right)\\
\mathbf{if}\;\left(ew \cdot \cos t\right) \cdot \cos t\_1 - \left(eh \cdot \sin t\right) \cdot \sin t\_1 \leq -2 \cdot 10^{-300}:\\
\;\;\;\;-ew\\
\mathbf{else}:\\
\;\;\;\;\cos t \cdot ew\\
\end{array}
\end{array}
if (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) < -2.00000000000000005e-300Initial program 99.9%
Applied rewrites65.4%
Taylor expanded in t around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6447.5
Applied rewrites47.5%
Taylor expanded in t around 0
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-neg.f6447.5
Applied rewrites47.5%
if -2.00000000000000005e-300 < (-.f64 (*.f64 (*.f64 ew (cos.f64 t)) (cos.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew)))) (*.f64 (*.f64 eh (sin.f64 t)) (sin.f64 (atan.f64 (/.f64 (*.f64 (neg.f64 eh) (tan.f64 t)) ew))))) Initial program 99.8%
Applied rewrites0.0%
lift-*.f64N/A
pow2N/A
lower-pow.f640.0
Applied rewrites77.7%
Taylor expanded in eh around 0
*-commutativeN/A
lower-*.f64N/A
lower-cos.f6460.2
Applied rewrites60.2%
Final simplification53.9%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (- eh) (sin t))))
(if (<= eh 1.55e+110)
(fabs
(*
(fma
(/ eh ew)
(* (- (sin t)) (tanh (asinh (* (/ (tan t) ew) (- eh)))))
(* (cos (atan (/ (* eh t) ew))) (cos t)))
ew))
(fabs (* t_1 (sin (atan (/ t_1 (* ew (cos t))))))))))
double code(double eh, double ew, double t) {
double t_1 = -eh * sin(t);
double tmp;
if (eh <= 1.55e+110) {
tmp = fabs((fma((eh / ew), (-sin(t) * tanh(asinh(((tan(t) / ew) * -eh)))), (cos(atan(((eh * t) / ew))) * cos(t))) * ew));
} else {
tmp = fabs((t_1 * sin(atan((t_1 / (ew * cos(t)))))));
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(-eh) * sin(t)) tmp = 0.0 if (eh <= 1.55e+110) tmp = abs(Float64(fma(Float64(eh / ew), Float64(Float64(-sin(t)) * tanh(asinh(Float64(Float64(tan(t) / ew) * Float64(-eh))))), Float64(cos(atan(Float64(Float64(eh * t) / ew))) * cos(t))) * ew)); else tmp = abs(Float64(t_1 * sin(atan(Float64(t_1 / Float64(ew * cos(t))))))); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eh, 1.55e+110], N[Abs[N[(N[(N[(eh / ew), $MachinePrecision] * N[((-N[Sin[t], $MachinePrecision]) * N[Tanh[N[ArcSinh[N[(N[(N[Tan[t], $MachinePrecision] / ew), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[N[ArcTan[N[(N[(eh * t), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * ew), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 * N[Sin[N[ArcTan[N[(t$95$1 / N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-eh\right) \cdot \sin t\\
\mathbf{if}\;eh \leq 1.55 \cdot 10^{+110}:\\
\;\;\;\;\left|\mathsf{fma}\left(\frac{eh}{ew}, \left(-\sin t\right) \cdot \tanh \sinh^{-1} \left(\frac{\tan t}{ew} \cdot \left(-eh\right)\right), \cos \tan^{-1} \left(\frac{eh \cdot t}{ew}\right) \cdot \cos t\right) \cdot ew\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1 \cdot \sin \tan^{-1} \left(\frac{t\_1}{ew \cdot \cos t}\right)\right|\\
\end{array}
\end{array}
if eh < 1.55000000000000009e110Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites95.4%
Applied rewrites95.4%
Taylor expanded in t around 0
Applied rewrites87.0%
if 1.55000000000000009e110 < eh Initial program 99.9%
Taylor expanded in ew around inf
Applied rewrites59.5%
Applied rewrites59.5%
Taylor expanded in eh around inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f6481.7
Applied rewrites81.7%
Final simplification86.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (- eh) (sin t))))
(if (or (<= eh -4.5e+94) (not (<= eh 4e+56)))
(fabs (* t_1 (sin (atan (/ t_1 (* ew (cos t)))))))
(fabs
(* (cos (atan (* (/ (- (sin t)) ew) (/ eh (cos t))))) (* (cos t) ew))))))
double code(double eh, double ew, double t) {
double t_1 = -eh * sin(t);
double tmp;
if ((eh <= -4.5e+94) || !(eh <= 4e+56)) {
tmp = fabs((t_1 * sin(atan((t_1 / (ew * cos(t)))))));
} else {
tmp = fabs((cos(atan(((-sin(t) / ew) * (eh / cos(t))))) * (cos(t) * 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) :: t_1
real(8) :: tmp
t_1 = -eh * sin(t)
if ((eh <= (-4.5d+94)) .or. (.not. (eh <= 4d+56))) then
tmp = abs((t_1 * sin(atan((t_1 / (ew * cos(t)))))))
else
tmp = abs((cos(atan(((-sin(t) / ew) * (eh / cos(t))))) * (cos(t) * ew)))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = -eh * Math.sin(t);
double tmp;
if ((eh <= -4.5e+94) || !(eh <= 4e+56)) {
tmp = Math.abs((t_1 * Math.sin(Math.atan((t_1 / (ew * Math.cos(t)))))));
} else {
tmp = Math.abs((Math.cos(Math.atan(((-Math.sin(t) / ew) * (eh / Math.cos(t))))) * (Math.cos(t) * ew)));
}
return tmp;
}
def code(eh, ew, t): t_1 = -eh * math.sin(t) tmp = 0 if (eh <= -4.5e+94) or not (eh <= 4e+56): tmp = math.fabs((t_1 * math.sin(math.atan((t_1 / (ew * math.cos(t))))))) else: tmp = math.fabs((math.cos(math.atan(((-math.sin(t) / ew) * (eh / math.cos(t))))) * (math.cos(t) * ew))) return tmp
function code(eh, ew, t) t_1 = Float64(Float64(-eh) * sin(t)) tmp = 0.0 if ((eh <= -4.5e+94) || !(eh <= 4e+56)) tmp = abs(Float64(t_1 * sin(atan(Float64(t_1 / Float64(ew * cos(t))))))); else tmp = abs(Float64(cos(atan(Float64(Float64(Float64(-sin(t)) / ew) * Float64(eh / cos(t))))) * Float64(cos(t) * ew))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = -eh * sin(t); tmp = 0.0; if ((eh <= -4.5e+94) || ~((eh <= 4e+56))) tmp = abs((t_1 * sin(atan((t_1 / (ew * cos(t))))))); else tmp = abs((cos(atan(((-sin(t) / ew) * (eh / cos(t))))) * (cos(t) * ew))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[eh, -4.5e+94], N[Not[LessEqual[eh, 4e+56]], $MachinePrecision]], N[Abs[N[(t$95$1 * N[Sin[N[ArcTan[N[(t$95$1 / N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Cos[N[ArcTan[N[(N[((-N[Sin[t], $MachinePrecision]) / ew), $MachinePrecision] * N[(eh / N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-eh\right) \cdot \sin t\\
\mathbf{if}\;eh \leq -4.5 \cdot 10^{+94} \lor \neg \left(eh \leq 4 \cdot 10^{+56}\right):\\
\;\;\;\;\left|t\_1 \cdot \sin \tan^{-1} \left(\frac{t\_1}{ew \cdot \cos t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\cos \tan^{-1} \left(\frac{-\sin t}{ew} \cdot \frac{eh}{\cos t}\right) \cdot \left(\cos t \cdot ew\right)\right|\\
\end{array}
\end{array}
if eh < -4.49999999999999972e94 or 4.00000000000000037e56 < eh Initial program 99.9%
Taylor expanded in ew around inf
Applied rewrites73.7%
Applied rewrites73.7%
Taylor expanded in eh around inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f6475.7
Applied rewrites75.7%
if -4.49999999999999972e94 < eh < 4.00000000000000037e56Initial program 99.8%
Taylor expanded in eh around 0
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.0%
Final simplification80.2%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (* (- eh) (sin t))))
(if (<= ew -3.4e-77)
(* (- (cos t)) ew)
(if (<= ew 2.3e-18)
(fabs (* t_1 (sin (atan (/ t_1 (* ew (cos t)))))))
(/ (+ (* (cos t) ew) (* (* (sin t) eh) (* (/ eh ew) (tan t)))) 1.0)))))
double code(double eh, double ew, double t) {
double t_1 = -eh * sin(t);
double tmp;
if (ew <= -3.4e-77) {
tmp = -cos(t) * ew;
} else if (ew <= 2.3e-18) {
tmp = fabs((t_1 * sin(atan((t_1 / (ew * cos(t)))))));
} else {
tmp = ((cos(t) * ew) + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / 1.0;
}
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) :: tmp
t_1 = -eh * sin(t)
if (ew <= (-3.4d-77)) then
tmp = -cos(t) * ew
else if (ew <= 2.3d-18) then
tmp = abs((t_1 * sin(atan((t_1 / (ew * cos(t)))))))
else
tmp = ((cos(t) * ew) + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / 1.0d0
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = -eh * Math.sin(t);
double tmp;
if (ew <= -3.4e-77) {
tmp = -Math.cos(t) * ew;
} else if (ew <= 2.3e-18) {
tmp = Math.abs((t_1 * Math.sin(Math.atan((t_1 / (ew * Math.cos(t)))))));
} else {
tmp = ((Math.cos(t) * ew) + ((Math.sin(t) * eh) * ((eh / ew) * Math.tan(t)))) / 1.0;
}
return tmp;
}
def code(eh, ew, t): t_1 = -eh * math.sin(t) tmp = 0 if ew <= -3.4e-77: tmp = -math.cos(t) * ew elif ew <= 2.3e-18: tmp = math.fabs((t_1 * math.sin(math.atan((t_1 / (ew * math.cos(t))))))) else: tmp = ((math.cos(t) * ew) + ((math.sin(t) * eh) * ((eh / ew) * math.tan(t)))) / 1.0 return tmp
function code(eh, ew, t) t_1 = Float64(Float64(-eh) * sin(t)) tmp = 0.0 if (ew <= -3.4e-77) tmp = Float64(Float64(-cos(t)) * ew); elseif (ew <= 2.3e-18) tmp = abs(Float64(t_1 * sin(atan(Float64(t_1 / Float64(ew * cos(t))))))); else tmp = Float64(Float64(Float64(cos(t) * ew) + Float64(Float64(sin(t) * eh) * Float64(Float64(eh / ew) * tan(t)))) / 1.0); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = -eh * sin(t); tmp = 0.0; if (ew <= -3.4e-77) tmp = -cos(t) * ew; elseif (ew <= 2.3e-18) tmp = abs((t_1 * sin(atan((t_1 / (ew * cos(t))))))); else tmp = ((cos(t) * ew) + ((sin(t) * eh) * ((eh / ew) * tan(t)))) / 1.0; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[((-eh) * N[Sin[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[ew, -3.4e-77], N[((-N[Cos[t], $MachinePrecision]) * ew), $MachinePrecision], If[LessEqual[ew, 2.3e-18], N[Abs[N[(t$95$1 * N[Sin[N[ArcTan[N[(t$95$1 / N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * eh), $MachinePrecision] * N[(N[(eh / ew), $MachinePrecision] * N[Tan[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-eh\right) \cdot \sin t\\
\mathbf{if}\;ew \leq -3.4 \cdot 10^{-77}:\\
\;\;\;\;\left(-\cos t\right) \cdot ew\\
\mathbf{elif}\;ew \leq 2.3 \cdot 10^{-18}:\\
\;\;\;\;\left|t\_1 \cdot \sin \tan^{-1} \left(\frac{t\_1}{ew \cdot \cos t}\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos t \cdot ew + \left(\sin t \cdot eh\right) \cdot \left(\frac{eh}{ew} \cdot \tan t\right)}{1}\\
\end{array}
\end{array}
if ew < -3.39999999999999983e-77Initial program 99.9%
Applied rewrites56.4%
Taylor expanded in t around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6454.9
Applied rewrites54.9%
Taylor expanded in eh around 0
*-commutativeN/A
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-cos.f6465.1
Applied rewrites65.1%
if -3.39999999999999983e-77 < ew < 2.3000000000000001e-18Initial program 99.8%
Taylor expanded in ew around inf
Applied rewrites74.7%
Applied rewrites74.7%
Taylor expanded in eh around inf
mul-1-negN/A
lower-neg.f64N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
lower-cos.f6471.4
Applied rewrites71.4%
if 2.3000000000000001e-18 < ew Initial program 99.7%
Applied rewrites78.8%
Taylor expanded in eh around 0
Applied rewrites70.5%
Final simplification68.9%
(FPCore (eh ew t) :precision binary64 (if (<= ew 1.2e-295) (- ew) (fma (* t t) (- (* -0.5 ew) (* (/ (* eh eh) ew) -0.5)) ew)))
double code(double eh, double ew, double t) {
double tmp;
if (ew <= 1.2e-295) {
tmp = -ew;
} else {
tmp = fma((t * t), ((-0.5 * ew) - (((eh * eh) / ew) * -0.5)), ew);
}
return tmp;
}
function code(eh, ew, t) tmp = 0.0 if (ew <= 1.2e-295) tmp = Float64(-ew); else tmp = fma(Float64(t * t), Float64(Float64(-0.5 * ew) - Float64(Float64(Float64(eh * eh) / ew) * -0.5)), ew); end return tmp end
code[eh_, ew_, t_] := If[LessEqual[ew, 1.2e-295], (-ew), N[(N[(t * t), $MachinePrecision] * N[(N[(-0.5 * ew), $MachinePrecision] - N[(N[(N[(eh * eh), $MachinePrecision] / ew), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] + ew), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ew \leq 1.2 \cdot 10^{-295}:\\
\;\;\;\;-ew\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot t, -0.5 \cdot ew - \frac{eh \cdot eh}{ew} \cdot -0.5, ew\right)\\
\end{array}
\end{array}
if ew < 1.1999999999999999e-295Initial program 99.9%
Applied rewrites49.2%
Taylor expanded in t around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6443.6
Applied rewrites43.6%
Taylor expanded in t around 0
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-neg.f6443.6
Applied rewrites43.6%
if 1.1999999999999999e-295 < ew Initial program 99.8%
Applied rewrites63.8%
Taylor expanded in t around 0
+-commutativeN/A
lower-fma.f64N/A
unpow2N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-*.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f6432.4
Applied rewrites32.4%
Final simplification39.0%
(FPCore (eh ew t) :precision binary64 (- ew))
double code(double eh, double ew, double t) {
return -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 = -ew
end function
public static double code(double eh, double ew, double t) {
return -ew;
}
def code(eh, ew, t): return -ew
function code(eh, ew, t) return Float64(-ew) end
function tmp = code(eh, ew, t) tmp = -ew; end
code[eh_, ew_, t_] := (-ew)
\begin{array}{l}
\\
-ew
\end{array}
Initial program 99.8%
Applied rewrites32.5%
Taylor expanded in t around 0
unpow2N/A
rem-square-sqrtN/A
lower-*.f6426.2
Applied rewrites26.2%
Taylor expanded in t around 0
*-commutativeN/A
unpow2N/A
rem-square-sqrtN/A
mul-1-negN/A
lower-neg.f6426.2
Applied rewrites26.2%
herbie shell --seed 2024356
(FPCore (eh ew t)
:name "Example 2 from Robby"
:precision binary64
(fabs (- (* (* ew (cos t)) (cos (atan (/ (* (- eh) (tan t)) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))