
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (atan (/ (/ eh ew) (tan t))))) (fabs (+ (* (* ew (sin t)) (cos t_1)) (* (* eh (cos t)) (sin t_1))))))
double code(double eh, double ew, double t) {
double t_1 = atan(((eh / ew) / tan(t)));
return fabs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
real(8) :: t_1
t_1 = atan(((eh / ew) / tan(t)))
code = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1))))
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.atan(((eh / ew) / Math.tan(t)));
return Math.abs((((ew * Math.sin(t)) * Math.cos(t_1)) + ((eh * Math.cos(t)) * Math.sin(t_1))));
}
def code(eh, ew, t): t_1 = math.atan(((eh / ew) / math.tan(t))) return math.fabs((((ew * math.sin(t)) * math.cos(t_1)) + ((eh * math.cos(t)) * math.sin(t_1))))
function code(eh, ew, t) t_1 = atan(Float64(Float64(eh / ew) / tan(t))) return abs(Float64(Float64(Float64(ew * sin(t)) * cos(t_1)) + Float64(Float64(eh * cos(t)) * sin(t_1)))) end
function tmp = code(eh, ew, t) t_1 = atan(((eh / ew) / tan(t))); tmp = abs((((ew * sin(t)) * cos(t_1)) + ((eh * cos(t)) * sin(t_1)))); end
code[eh_, ew_, t_] := Block[{t$95$1 = N[ArcTan[N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[Abs[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * N[Cos[t$95$1], $MachinePrecision]), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tan^{-1} \left(\frac{\frac{eh}{ew}}{\tan t}\right)\\
\left|\left(ew \cdot \sin t\right) \cdot \cos t\_1 + \left(eh \cdot \cos t\right) \cdot \sin t\_1\right|
\end{array}
\end{array}
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t))))
(fabs
(fma
(* (cos t) eh)
(tanh (asinh t_1))
(* (* (sin t) ew) (cos (atan t_1)))))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
return fabs(fma((cos(t) * eh), tanh(asinh(t_1)), ((sin(t) * ew) * cos(atan(t_1)))));
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) return abs(fma(Float64(cos(t) * eh), tanh(asinh(t_1)), Float64(Float64(sin(t) * ew) * cos(atan(t_1))))) end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
\left|\mathsf{fma}\left(\cos t \cdot eh, \tanh \sinh^{-1} t\_1, \left(\sin t \cdot ew\right) \cdot \cos \tan^{-1} t\_1\right)\right|
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (/ (/ eh ew) (tan t)))
(t_2 (tanh (asinh t_1)))
(t_3 (atan t_1))
(t_4 (cos t_3))
(t_5 (* (* (sin t) ew) t_4)))
(if (<= (+ (* (* ew (sin t)) t_4) (* (* eh (cos t)) (sin t_3))) -1e-262)
(fabs (fma eh t_2 t_5))
(fma (* (cos t) eh) t_2 t_5))))
double code(double eh, double ew, double t) {
double t_1 = (eh / ew) / tan(t);
double t_2 = tanh(asinh(t_1));
double t_3 = atan(t_1);
double t_4 = cos(t_3);
double t_5 = (sin(t) * ew) * t_4;
double tmp;
if ((((ew * sin(t)) * t_4) + ((eh * cos(t)) * sin(t_3))) <= -1e-262) {
tmp = fabs(fma(eh, t_2, t_5));
} else {
tmp = fma((cos(t) * eh), t_2, t_5);
}
return tmp;
}
function code(eh, ew, t) t_1 = Float64(Float64(eh / ew) / tan(t)) t_2 = tanh(asinh(t_1)) t_3 = atan(t_1) t_4 = cos(t_3) t_5 = Float64(Float64(sin(t) * ew) * t_4) tmp = 0.0 if (Float64(Float64(Float64(ew * sin(t)) * t_4) + Float64(Float64(eh * cos(t)) * sin(t_3))) <= -1e-262) tmp = abs(fma(eh, t_2, t_5)); else tmp = fma(Float64(cos(t) * eh), t_2, t_5); end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Tanh[N[ArcSinh[t$95$1], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[ArcTan[t$95$1], $MachinePrecision]}, Block[{t$95$4 = N[Cos[t$95$3], $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] * t$95$4), $MachinePrecision]}, If[LessEqual[N[(N[(N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision] * t$95$4), $MachinePrecision] + N[(N[(eh * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Sin[t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e-262], N[Abs[N[(eh * t$95$2 + t$95$5), $MachinePrecision]], $MachinePrecision], N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * t$95$2 + t$95$5), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{\frac{eh}{ew}}{\tan t}\\
t_2 := \tanh \sinh^{-1} t\_1\\
t_3 := \tan^{-1} t\_1\\
t_4 := \cos t\_3\\
t_5 := \left(\sin t \cdot ew\right) \cdot t\_4\\
\mathbf{if}\;\left(ew \cdot \sin t\right) \cdot t\_4 + \left(eh \cdot \cos t\right) \cdot \sin t\_3 \leq -1 \cdot 10^{-262}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, t\_2, t\_5\right)\right|\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos t \cdot eh, t\_2, t\_5\right)\\
\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)))))) < -1.00000000000000001e-262Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
Applied rewrites79.7%
if -1.00000000000000001e-262 < (+.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 rewrites99.8%
Applied rewrites98.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(* (cos t) eh)
(tanh (asinh (* (/ (+ 1.0 (* -0.5 (* t t))) ew) (/ eh (sin t))))))))
(t_2 (/ (/ eh ew) (tan t))))
(if (<= eh -5.1e+157)
t_1
(if (<= eh 2.3e+54)
(fabs (fma eh (tanh (asinh t_2)) (* (* (sin t) ew) (cos (atan t_2)))))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((cos(t) * eh) * tanh(asinh((((1.0 + (-0.5 * (t * t))) / ew) * (eh / sin(t)))))));
double t_2 = (eh / ew) / tan(t);
double tmp;
if (eh <= -5.1e+157) {
tmp = t_1;
} else if (eh <= 2.3e+54) {
tmp = fabs(fma(eh, tanh(asinh(t_2)), ((sin(t) * ew) * cos(atan(t_2)))));
} else {
tmp = t_1;
}
return tmp;
}
function code(eh, ew, t) t_1 = abs(Float64(Float64(cos(t) * eh) * tanh(asinh(Float64(Float64(Float64(1.0 + Float64(-0.5 * Float64(t * t))) / ew) * Float64(eh / sin(t))))))) t_2 = Float64(Float64(eh / ew) / tan(t)) tmp = 0.0 if (eh <= -5.1e+157) tmp = t_1; elseif (eh <= 2.3e+54) tmp = abs(fma(eh, tanh(asinh(t_2)), Float64(Float64(sin(t) * ew) * cos(atan(t_2))))); else tmp = t_1; end return tmp end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(N[(1.0 + N[(-0.5 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] * N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(eh / ew), $MachinePrecision] / N[Tan[t], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[eh, -5.1e+157], t$95$1, If[LessEqual[eh, 2.3e+54], N[Abs[N[(eh * N[Tanh[N[ArcSinh[t$95$2], $MachinePrecision]], $MachinePrecision] + N[(N[(N[Sin[t], $MachinePrecision] * ew), $MachinePrecision] * N[Cos[N[ArcTan[t$95$2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\left(\cos t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(\frac{1 + -0.5 \cdot \left(t \cdot t\right)}{ew} \cdot \frac{eh}{\sin t}\right)\right|\\
t_2 := \frac{\frac{eh}{ew}}{\tan t}\\
\mathbf{if}\;eh \leq -5.1 \cdot 10^{+157}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 2.3 \cdot 10^{+54}:\\
\;\;\;\;\left|\mathsf{fma}\left(eh, \tanh \sinh^{-1} t\_2, \left(\sin t \cdot ew\right) \cdot \cos \tan^{-1} t\_2\right)\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -5.09999999999999999e157 or 2.29999999999999994e54 < eh Initial program 99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
sin-atanN/A
tanh-asinh-revN/A
lower-tanh.f64N/A
lower-asinh.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-cos.f64N/A
lower-/.f64N/A
Applied rewrites88.5%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.7
Applied rewrites88.7%
if -5.09999999999999999e157 < eh < 2.29999999999999994e54Initial program 99.8%
Applied rewrites99.8%
Taylor expanded in t around 0
Applied rewrites85.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(*
(* (cos t) eh)
(tanh
(asinh (* (/ (+ 1.0 (* -0.5 (* t t))) ew) (/ eh (sin t)))))))))
(if (<= eh -1.7e-21)
t_1
(if (<= eh 1e-83)
(fabs (* (* (cos (atan (/ eh (* ew t)))) ew) (sin t)))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((cos(t) * eh) * tanh(asinh((((1.0 + (-0.5 * (t * t))) / ew) * (eh / sin(t)))))));
double tmp;
if (eh <= -1.7e-21) {
tmp = t_1;
} else if (eh <= 1e-83) {
tmp = fabs(((cos(atan((eh / (ew * t)))) * ew) * sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs(((math.cos(t) * eh) * math.tanh(math.asinh((((1.0 + (-0.5 * (t * t))) / ew) * (eh / math.sin(t))))))) tmp = 0 if eh <= -1.7e-21: tmp = t_1 elif eh <= 1e-83: tmp = math.fabs(((math.cos(math.atan((eh / (ew * t)))) * ew) * math.sin(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(Float64(cos(t) * eh) * tanh(asinh(Float64(Float64(Float64(1.0 + Float64(-0.5 * Float64(t * t))) / ew) * Float64(eh / sin(t))))))) tmp = 0.0 if (eh <= -1.7e-21) tmp = t_1; elseif (eh <= 1e-83) tmp = abs(Float64(Float64(cos(atan(Float64(eh / Float64(ew * t)))) * ew) * sin(t))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs(((cos(t) * eh) * tanh(asinh((((1.0 + (-0.5 * (t * t))) / ew) * (eh / sin(t))))))); tmp = 0.0; if (eh <= -1.7e-21) tmp = t_1; elseif (eh <= 1e-83) tmp = abs(((cos(atan((eh / (ew * t)))) * ew) * sin(t))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(N[(1.0 + N[(-0.5 * N[(t * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / ew), $MachinePrecision] * N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.7e-21], t$95$1, If[LessEqual[eh, 1e-83], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\left(\cos t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(\frac{1 + -0.5 \cdot \left(t \cdot t\right)}{ew} \cdot \frac{eh}{\sin t}\right)\right|\\
\mathbf{if}\;eh \leq -1.7 \cdot 10^{-21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 10^{-83}:\\
\;\;\;\;\left|\left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot ew\right) \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -1.7e-21 or 1e-83 < eh Initial program 99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
sin-atanN/A
tanh-asinh-revN/A
lower-tanh.f64N/A
lower-asinh.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-cos.f64N/A
lower-/.f64N/A
Applied rewrites79.6%
Taylor expanded in t around 0
lower-+.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6479.8
Applied rewrites79.8%
if -1.7e-21 < eh < 1e-83Initial program 99.8%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.5%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6467.6
Applied rewrites67.6%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1
(fabs
(* (* (cos t) eh) (tanh (asinh (* (/ 1.0 ew) (/ eh (sin t)))))))))
(if (<= eh -1.7e-21)
t_1
(if (<= eh 1.95e-83)
(fabs (* (* (cos (atan (/ eh (* ew t)))) ew) (sin t)))
t_1))))
double code(double eh, double ew, double t) {
double t_1 = fabs(((cos(t) * eh) * tanh(asinh(((1.0 / ew) * (eh / sin(t)))))));
double tmp;
if (eh <= -1.7e-21) {
tmp = t_1;
} else if (eh <= 1.95e-83) {
tmp = fabs(((cos(atan((eh / (ew * t)))) * ew) * sin(t)));
} else {
tmp = t_1;
}
return tmp;
}
def code(eh, ew, t): t_1 = math.fabs(((math.cos(t) * eh) * math.tanh(math.asinh(((1.0 / ew) * (eh / math.sin(t))))))) tmp = 0 if eh <= -1.7e-21: tmp = t_1 elif eh <= 1.95e-83: tmp = math.fabs(((math.cos(math.atan((eh / (ew * t)))) * ew) * math.sin(t))) else: tmp = t_1 return tmp
function code(eh, ew, t) t_1 = abs(Float64(Float64(cos(t) * eh) * tanh(asinh(Float64(Float64(1.0 / ew) * Float64(eh / sin(t))))))) tmp = 0.0 if (eh <= -1.7e-21) tmp = t_1; elseif (eh <= 1.95e-83) tmp = abs(Float64(Float64(cos(atan(Float64(eh / Float64(ew * t)))) * ew) * sin(t))); else tmp = t_1; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = abs(((cos(t) * eh) * tanh(asinh(((1.0 / ew) * (eh / sin(t))))))); tmp = 0.0; if (eh <= -1.7e-21) tmp = t_1; elseif (eh <= 1.95e-83) tmp = abs(((cos(atan((eh / (ew * t)))) * ew) * sin(t))); else tmp = t_1; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[Abs[N[(N[(N[Cos[t], $MachinePrecision] * eh), $MachinePrecision] * N[Tanh[N[ArcSinh[N[(N[(1.0 / ew), $MachinePrecision] * N[(eh / N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[eh, -1.7e-21], t$95$1, If[LessEqual[eh, 1.95e-83], N[Abs[N[(N[(N[Cos[N[ArcTan[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left|\left(\cos t \cdot eh\right) \cdot \tanh \sinh^{-1} \left(\frac{1}{ew} \cdot \frac{eh}{\sin t}\right)\right|\\
\mathbf{if}\;eh \leq -1.7 \cdot 10^{-21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;eh \leq 1.95 \cdot 10^{-83}:\\
\;\;\;\;\left|\left(\cos \tan^{-1} \left(\frac{eh}{ew \cdot t}\right) \cdot ew\right) \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if eh < -1.7e-21 or 1.95e-83 < eh Initial program 99.8%
Taylor expanded in eh around inf
associate-*r*N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-cos.f64N/A
sin-atanN/A
tanh-asinh-revN/A
lower-tanh.f64N/A
lower-asinh.f64N/A
*-commutativeN/A
times-fracN/A
lower-*.f64N/A
lower-/.f64N/A
lift-cos.f64N/A
lower-/.f64N/A
Applied rewrites79.6%
Taylor expanded in t around 0
Applied rewrites79.6%
if -1.7e-21 < eh < 1.95e-83Initial program 99.8%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites67.6%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6467.6
Applied rewrites67.6%
(FPCore (eh ew t) :precision binary64 (let* ((t_1 (/ eh (* ew t))) (t_2 (fabs (* (* (cos (atan t_1)) ew) (sin t))))) (if (<= t -6.5e-63) t_2 (if (<= t 3.7e-37) (fabs (* (tanh t_1) eh)) t_2))))
double code(double eh, double ew, double t) {
double t_1 = eh / (ew * t);
double t_2 = fabs(((cos(atan(t_1)) * ew) * sin(t)));
double tmp;
if (t <= -6.5e-63) {
tmp = t_2;
} else if (t <= 3.7e-37) {
tmp = fabs((tanh(t_1) * eh));
} else {
tmp = t_2;
}
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 = eh / (ew * t)
t_2 = abs(((cos(atan(t_1)) * ew) * sin(t)))
if (t <= (-6.5d-63)) then
tmp = t_2
else if (t <= 3.7d-37) then
tmp = abs((tanh(t_1) * eh))
else
tmp = t_2
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = eh / (ew * t);
double t_2 = Math.abs(((Math.cos(Math.atan(t_1)) * ew) * Math.sin(t)));
double tmp;
if (t <= -6.5e-63) {
tmp = t_2;
} else if (t <= 3.7e-37) {
tmp = Math.abs((Math.tanh(t_1) * eh));
} else {
tmp = t_2;
}
return tmp;
}
def code(eh, ew, t): t_1 = eh / (ew * t) t_2 = math.fabs(((math.cos(math.atan(t_1)) * ew) * math.sin(t))) tmp = 0 if t <= -6.5e-63: tmp = t_2 elif t <= 3.7e-37: tmp = math.fabs((math.tanh(t_1) * eh)) else: tmp = t_2 return tmp
function code(eh, ew, t) t_1 = Float64(eh / Float64(ew * t)) t_2 = abs(Float64(Float64(cos(atan(t_1)) * ew) * sin(t))) tmp = 0.0 if (t <= -6.5e-63) tmp = t_2; elseif (t <= 3.7e-37) tmp = abs(Float64(tanh(t_1) * eh)); else tmp = t_2; end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = eh / (ew * t); t_2 = abs(((cos(atan(t_1)) * ew) * sin(t))); tmp = 0.0; if (t <= -6.5e-63) tmp = t_2; elseif (t <= 3.7e-37) tmp = abs((tanh(t_1) * eh)); else tmp = t_2; end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Abs[N[(N[(N[Cos[N[ArcTan[t$95$1], $MachinePrecision]], $MachinePrecision] * ew), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -6.5e-63], t$95$2, If[LessEqual[t, 3.7e-37], N[Abs[N[(N[Tanh[t$95$1], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision], t$95$2]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{eh}{ew \cdot t}\\
t_2 := \left|\left(\cos \tan^{-1} t\_1 \cdot ew\right) \cdot \sin t\right|\\
\mathbf{if}\;t \leq -6.5 \cdot 10^{-63}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t \leq 3.7 \cdot 10^{-37}:\\
\;\;\;\;\left|\tanh t\_1 \cdot eh\right|\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if t < -6.4999999999999998e-63 or 3.7e-37 < t Initial program 99.7%
Taylor expanded in eh around 0
associate-*r*N/A
lower-*.f64N/A
Applied rewrites51.1%
Taylor expanded in t around 0
lower-/.f64N/A
lower-*.f6451.3
Applied rewrites51.3%
if -6.4999999999999998e-63 < t < 3.7e-37Initial program 100.0%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites75.6%
Taylor expanded in eh around 0
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f6475.6
Applied rewrites75.6%
Taylor expanded in t around 0
lift-/.f64N/A
lift-*.f6475.6
Applied rewrites75.6%
(FPCore (eh ew t) :precision binary64 (fabs (* (tanh (/ eh (* ew (sin t)))) eh)))
double code(double eh, double ew, double t) {
return fabs((tanh((eh / (ew * sin(t)))) * eh));
}
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((tanh((eh / (ew * sin(t)))) * eh))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.tanh((eh / (ew * Math.sin(t)))) * eh));
}
def code(eh, ew, t): return math.fabs((math.tanh((eh / (ew * math.sin(t)))) * eh))
function code(eh, ew, t) return abs(Float64(tanh(Float64(eh / Float64(ew * sin(t)))) * eh)) end
function tmp = code(eh, ew, t) tmp = abs((tanh((eh / (ew * sin(t)))) * eh)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Tanh[N[(eh / N[(ew * N[Sin[t], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\tanh \left(\frac{eh}{ew \cdot \sin t}\right) \cdot eh\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.0%
Taylor expanded in eh around 0
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f6442.0
Applied rewrites42.0%
Taylor expanded in t around 0
Applied rewrites42.0%
(FPCore (eh ew t) :precision binary64 (fabs (* (tanh (/ eh (* ew t))) eh)))
double code(double eh, double ew, double t) {
return fabs((tanh((eh / (ew * t))) * eh));
}
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((tanh((eh / (ew * t))) * eh))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((Math.tanh((eh / (ew * t))) * eh));
}
def code(eh, ew, t): return math.fabs((math.tanh((eh / (ew * t))) * eh))
function code(eh, ew, t) return abs(Float64(tanh(Float64(eh / Float64(ew * t))) * eh)) end
function tmp = code(eh, ew, t) tmp = abs((tanh((eh / (ew * t))) * eh)); end
code[eh_, ew_, t_] := N[Abs[N[(N[Tanh[N[(eh / N[(ew * t), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * eh), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\tanh \left(\frac{eh}{ew \cdot t}\right) \cdot eh\right|
\end{array}
Initial program 99.8%
Taylor expanded in t around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites42.0%
Taylor expanded in eh around 0
lower-/.f64N/A
lower-*.f64N/A
lift-cos.f64N/A
lower-*.f64N/A
lift-sin.f6442.0
Applied rewrites42.0%
Taylor expanded in t around 0
lift-/.f64N/A
lift-*.f6440.1
Applied rewrites40.1%
herbie shell --seed 2025101
(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))))))))