
(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}
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}
Herbie found 7 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}
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}
(FPCore (eh ew t) :precision binary64 (fabs (- (* (* ew (cos t)) (cos (atan (/ (* (tan t) eh) ew)))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))
double code(double eh, double ew, double t) {
return fabs((((ew * cos(t)) * cos(atan(((tan(t) * eh) / ew)))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((((ew * cos(t)) * cos(atan(((tan(t) * eh) / ew)))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((((ew * Math.cos(t)) * Math.cos(Math.atan(((Math.tan(t) * eh) / ew)))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((-eh * Math.tan(t)) / ew))))));
}
def code(eh, ew, t): return math.fabs((((ew * math.cos(t)) * math.cos(math.atan(((math.tan(t) * eh) / ew)))) - ((eh * math.sin(t)) * math.sin(math.atan(((-eh * math.tan(t)) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(Float64(ew * cos(t)) * cos(atan(Float64(Float64(tan(t) * eh) / ew)))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs((((ew * cos(t)) * cos(atan(((tan(t) * eh) / ew)))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision] * N[Cos[N[ArcTan[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 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]), $MachinePrecision]], $MachinePrecision]
\left|\left(ew \cdot \cos t\right) \cdot \cos \tan^{-1} \left(\frac{\tan t \cdot eh}{ew}\right) - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right|
Initial program 99.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-atan.f64N/A
atan-neg-revN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-atan.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.8%
Applied rewrites99.8%
(FPCore (eh ew t) :precision binary64 (fabs (- (/ 1 (/ (sqrt (- (pow (/ (* (tan t) eh) ew) 2) -1)) (* (cos t) ew))) (* (* eh (sin t)) (sin (atan (/ (* (- eh) (tan t)) ew)))))))
double code(double eh, double ew, double t) {
return fabs(((1.0 / (sqrt((pow(((tan(t) * eh) / ew), 2.0) - -1.0)) / (cos(t) * ew))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs(((1.0d0 / (sqrt(((((tan(t) * eh) / ew) ** 2.0d0) - (-1.0d0))) / (cos(t) * ew))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew))))))
end function
public static double code(double eh, double ew, double t) {
return Math.abs(((1.0 / (Math.sqrt((Math.pow(((Math.tan(t) * eh) / ew), 2.0) - -1.0)) / (Math.cos(t) * ew))) - ((eh * Math.sin(t)) * Math.sin(Math.atan(((-eh * Math.tan(t)) / ew))))));
}
def code(eh, ew, t): return math.fabs(((1.0 / (math.sqrt((math.pow(((math.tan(t) * eh) / ew), 2.0) - -1.0)) / (math.cos(t) * ew))) - ((eh * math.sin(t)) * math.sin(math.atan(((-eh * math.tan(t)) / ew))))))
function code(eh, ew, t) return abs(Float64(Float64(1.0 / Float64(sqrt(Float64((Float64(Float64(tan(t) * eh) / ew) ^ 2.0) - -1.0)) / Float64(cos(t) * ew))) - Float64(Float64(eh * sin(t)) * sin(atan(Float64(Float64(Float64(-eh) * tan(t)) / ew)))))) end
function tmp = code(eh, ew, t) tmp = abs(((1.0 / (sqrt(((((tan(t) * eh) / ew) ^ 2.0) - -1.0)) / (cos(t) * ew))) - ((eh * sin(t)) * sin(atan(((-eh * tan(t)) / ew)))))); end
code[eh_, ew_, t_] := N[Abs[N[(N[(1 / N[(N[Sqrt[N[(N[Power[N[(N[(N[Tan[t], $MachinePrecision] * eh), $MachinePrecision] / ew), $MachinePrecision], 2], $MachinePrecision] - -1), $MachinePrecision]], $MachinePrecision] / N[(N[Cos[t], $MachinePrecision] * ew), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 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]), $MachinePrecision]], $MachinePrecision]
\left|\frac{1}{\frac{\sqrt{{\left(\frac{\tan t \cdot eh}{ew}\right)}^{2} - -1}}{\cos t \cdot ew}} - \left(eh \cdot \sin t\right) \cdot \sin \tan^{-1} \left(\frac{\left(-eh\right) \cdot \tan t}{ew}\right)\right|
Initial program 99.8%
lift-*.f64N/A
lift-cos.f64N/A
lift-atan.f64N/A
cos-atanN/A
mult-flip-revN/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f64N/A
Applied rewrites99.7%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (- (pow (* (/ (tan t) (fabs ew)) eh) 2) -1))
(t_2 (atan (/ (* -1 (* eh t)) (fabs ew)))))
(if (<= (fabs ew) 3500000000000000210333675290624)
(fabs
(-
(* (* (fabs ew) (cos t)) (cos t_2))
(* (* eh (sin t)) (sin t_2))))
(fabs (* t_1 (* (/ (cos t) (sqrt t_1)) (fabs ew)))))))double code(double eh, double ew, double t) {
double t_1 = pow(((tan(t) / fabs(ew)) * eh), 2.0) - -1.0;
double t_2 = atan(((-1.0 * (eh * t)) / fabs(ew)));
double tmp;
if (fabs(ew) <= 3.5e+30) {
tmp = fabs((((fabs(ew) * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2))));
} else {
tmp = fabs((t_1 * ((cos(t) / sqrt(t_1)) * fabs(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) :: t_2
real(8) :: tmp
t_1 = (((tan(t) / abs(ew)) * eh) ** 2.0d0) - (-1.0d0)
t_2 = atan((((-1.0d0) * (eh * t)) / abs(ew)))
if (abs(ew) <= 3.5d+30) then
tmp = abs((((abs(ew) * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2))))
else
tmp = abs((t_1 * ((cos(t) / sqrt(t_1)) * abs(ew))))
end if
code = tmp
end function
public static double code(double eh, double ew, double t) {
double t_1 = Math.pow(((Math.tan(t) / Math.abs(ew)) * eh), 2.0) - -1.0;
double t_2 = Math.atan(((-1.0 * (eh * t)) / Math.abs(ew)));
double tmp;
if (Math.abs(ew) <= 3.5e+30) {
tmp = Math.abs((((Math.abs(ew) * Math.cos(t)) * Math.cos(t_2)) - ((eh * Math.sin(t)) * Math.sin(t_2))));
} else {
tmp = Math.abs((t_1 * ((Math.cos(t) / Math.sqrt(t_1)) * Math.abs(ew))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.pow(((math.tan(t) / math.fabs(ew)) * eh), 2.0) - -1.0 t_2 = math.atan(((-1.0 * (eh * t)) / math.fabs(ew))) tmp = 0 if math.fabs(ew) <= 3.5e+30: tmp = math.fabs((((math.fabs(ew) * math.cos(t)) * math.cos(t_2)) - ((eh * math.sin(t)) * math.sin(t_2)))) else: tmp = math.fabs((t_1 * ((math.cos(t) / math.sqrt(t_1)) * math.fabs(ew)))) return tmp
function code(eh, ew, t) t_1 = Float64((Float64(Float64(tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0) t_2 = atan(Float64(Float64(-1.0 * Float64(eh * t)) / abs(ew))) tmp = 0.0 if (abs(ew) <= 3.5e+30) tmp = abs(Float64(Float64(Float64(abs(ew) * cos(t)) * cos(t_2)) - Float64(Float64(eh * sin(t)) * sin(t_2)))); else tmp = abs(Float64(t_1 * Float64(Float64(cos(t) / sqrt(t_1)) * abs(ew)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = (((tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0; t_2 = atan(((-1.0 * (eh * t)) / abs(ew))); tmp = 0.0; if (abs(ew) <= 3.5e+30) tmp = abs((((abs(ew) * cos(t)) * cos(t_2)) - ((eh * sin(t)) * sin(t_2)))); else tmp = abs((t_1 * ((cos(t) / sqrt(t_1)) * abs(ew)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Power[N[(N[(N[Tan[t], $MachinePrecision] / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision], 2], $MachinePrecision] - -1), $MachinePrecision]}, Block[{t$95$2 = N[ArcTan[N[(N[(-1 * N[(eh * t), $MachinePrecision]), $MachinePrecision] / N[Abs[ew], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[Abs[ew], $MachinePrecision], 3500000000000000210333675290624], N[Abs[N[(N[(N[(N[Abs[ew], $MachinePrecision] * 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]], $MachinePrecision], N[Abs[N[(t$95$1 * N[(N[(N[Cos[t], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Abs[ew], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
t_1 := {\left(\frac{\tan t}{\left|ew\right|} \cdot eh\right)}^{2} - -1\\
t_2 := \tan^{-1} \left(\frac{-1 \cdot \left(eh \cdot t\right)}{\left|ew\right|}\right)\\
\mathbf{if}\;\left|ew\right| \leq 3500000000000000210333675290624:\\
\;\;\;\;\left|\left(\left|ew\right| \cdot \cos t\right) \cdot \cos t\_2 - \left(eh \cdot \sin t\right) \cdot \sin t\_2\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1 \cdot \left(\frac{\cos t}{\sqrt{t\_1}} \cdot \left|ew\right|\right)\right|\\
\end{array}
if ew < 3.5000000000000002e30Initial program 99.8%
Taylor expanded in t around 0
lower-*.f64N/A
lower-*.f6489.7%
Applied rewrites89.7%
Taylor expanded in t around 0
lower-*.f64N/A
lower-*.f6489.7%
Applied rewrites89.7%
if 3.5000000000000002e30 < ew Initial program 99.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-atan.f64N/A
atan-neg-revN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-atan.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.8%
Applied rewrites99.8%
Applied rewrites77.0%
Applied rewrites76.0%
(FPCore (eh ew t)
:precision binary64
(let* ((t_1 (- (pow (* (/ (tan t) (fabs ew)) eh) 2) -1)))
(if (<=
(fabs ew)
1178420618842611/1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688)
(fabs
(* (* (- eh) (tanh (asinh (* (/ t (fabs ew)) (- eh))))) (sin t)))
(fabs (* t_1 (* (/ (cos t) (sqrt t_1)) (fabs ew)))))))double code(double eh, double ew, double t) {
double t_1 = pow(((tan(t) / fabs(ew)) * eh), 2.0) - -1.0;
double tmp;
if (fabs(ew) <= 7.2e-136) {
tmp = fabs(((-eh * tanh(asinh(((t / fabs(ew)) * -eh)))) * sin(t)));
} else {
tmp = fabs((t_1 * ((cos(t) / sqrt(t_1)) * fabs(ew))));
}
return tmp;
}
def code(eh, ew, t): t_1 = math.pow(((math.tan(t) / math.fabs(ew)) * eh), 2.0) - -1.0 tmp = 0 if math.fabs(ew) <= 7.2e-136: tmp = math.fabs(((-eh * math.tanh(math.asinh(((t / math.fabs(ew)) * -eh)))) * math.sin(t))) else: tmp = math.fabs((t_1 * ((math.cos(t) / math.sqrt(t_1)) * math.fabs(ew)))) return tmp
function code(eh, ew, t) t_1 = Float64((Float64(Float64(tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0) tmp = 0.0 if (abs(ew) <= 7.2e-136) tmp = abs(Float64(Float64(Float64(-eh) * tanh(asinh(Float64(Float64(t / abs(ew)) * Float64(-eh))))) * sin(t))); else tmp = abs(Float64(t_1 * Float64(Float64(cos(t) / sqrt(t_1)) * abs(ew)))); end return tmp end
function tmp_2 = code(eh, ew, t) t_1 = (((tan(t) / abs(ew)) * eh) ^ 2.0) - -1.0; tmp = 0.0; if (abs(ew) <= 7.2e-136) tmp = abs(((-eh * tanh(asinh(((t / abs(ew)) * -eh)))) * sin(t))); else tmp = abs((t_1 * ((cos(t) / sqrt(t_1)) * abs(ew)))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := Block[{t$95$1 = N[(N[Power[N[(N[(N[Tan[t], $MachinePrecision] / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * eh), $MachinePrecision], 2], $MachinePrecision] - -1), $MachinePrecision]}, If[LessEqual[N[Abs[ew], $MachinePrecision], 1178420618842611/1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688], N[Abs[N[(N[((-eh) * N[Tanh[N[ArcSinh[N[(N[(t / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(t$95$1 * N[(N[(N[Cos[t], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision] * N[Abs[ew], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
t_1 := {\left(\frac{\tan t}{\left|ew\right|} \cdot eh\right)}^{2} - -1\\
\mathbf{if}\;\left|ew\right| \leq \frac{1178420618842611}{1636695303948070935006594848413799576108321023021532394741645684048066898202337277441635046162952078575443342063780035504608628272942696526664263794688}:\\
\;\;\;\;\left|\left(\left(-eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{\left|ew\right|} \cdot \left(-eh\right)\right)\right) \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|t\_1 \cdot \left(\frac{\cos t}{\sqrt{t\_1}} \cdot \left|ew\right|\right)\right|\\
\end{array}
if ew < 7.1999999999999996e-136Initial program 99.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
Applied rewrites40.7%
Applied rewrites40.7%
Taylor expanded in t around 0
lower-/.f6440.9%
Applied rewrites40.9%
if 7.1999999999999996e-136 < ew Initial program 99.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-atan.f64N/A
atan-neg-revN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-atan.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.8%
Applied rewrites99.8%
Applied rewrites77.0%
Applied rewrites76.0%
(FPCore (eh ew t)
:precision binary64
(if (<=
(fabs ew)
6867846810695183/3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176)
(fabs
(* (* (- eh) (tanh (asinh (* (/ t (fabs ew)) (- eh))))) (sin t)))
(fabs (* (fabs ew) (cos t)))))double code(double eh, double ew, double t) {
double tmp;
if (fabs(ew) <= 2.2e-129) {
tmp = fabs(((-eh * tanh(asinh(((t / fabs(ew)) * -eh)))) * sin(t)));
} else {
tmp = fabs((fabs(ew) * cos(t)));
}
return tmp;
}
def code(eh, ew, t): tmp = 0 if math.fabs(ew) <= 2.2e-129: tmp = math.fabs(((-eh * math.tanh(math.asinh(((t / math.fabs(ew)) * -eh)))) * math.sin(t))) else: tmp = math.fabs((math.fabs(ew) * math.cos(t))) return tmp
function code(eh, ew, t) tmp = 0.0 if (abs(ew) <= 2.2e-129) tmp = abs(Float64(Float64(Float64(-eh) * tanh(asinh(Float64(Float64(t / abs(ew)) * Float64(-eh))))) * sin(t))); else tmp = abs(Float64(abs(ew) * cos(t))); end return tmp end
function tmp_2 = code(eh, ew, t) tmp = 0.0; if (abs(ew) <= 2.2e-129) tmp = abs(((-eh * tanh(asinh(((t / abs(ew)) * -eh)))) * sin(t))); else tmp = abs((abs(ew) * cos(t))); end tmp_2 = tmp; end
code[eh_, ew_, t_] := If[LessEqual[N[Abs[ew], $MachinePrecision], 6867846810695183/3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176], N[Abs[N[(N[((-eh) * N[Tanh[N[ArcSinh[N[(N[(t / N[Abs[ew], $MachinePrecision]), $MachinePrecision] * (-eh)), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Abs[N[(N[Abs[ew], $MachinePrecision] * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;\left|ew\right| \leq \frac{6867846810695183}{3121748550315992231381597229793166305748598142664971150859156959625371738819765620120306103063491971159826931121406622895447975679288285306290176}:\\
\;\;\;\;\left|\left(\left(-eh\right) \cdot \tanh \sinh^{-1} \left(\frac{t}{\left|ew\right|} \cdot \left(-eh\right)\right)\right) \cdot \sin t\right|\\
\mathbf{else}:\\
\;\;\;\;\left|\left|ew\right| \cdot \cos t\right|\\
\end{array}
if ew < 2.2e-129Initial program 99.8%
Taylor expanded in eh around inf
lower-*.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-sin.f64N/A
lower-atan.f64N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f64N/A
lower-sin.f64N/A
lower-*.f64N/A
Applied rewrites40.7%
Applied rewrites40.7%
Taylor expanded in t around 0
lower-/.f6440.9%
Applied rewrites40.9%
if 2.2e-129 < ew Initial program 99.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-atan.f64N/A
atan-neg-revN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-atan.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.8%
Applied rewrites99.8%
Applied rewrites77.0%
Taylor expanded in t around 0
lower-/.f6442.5%
Applied rewrites42.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6462.5%
Applied rewrites62.5%
(FPCore (eh ew t) :precision binary64 (fabs (* ew (cos t))))
double code(double eh, double ew, double t) {
return fabs((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((ew * cos(t)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((ew * Math.cos(t)));
}
def code(eh, ew, t): return math.fabs((ew * math.cos(t)))
function code(eh, ew, t) return abs(Float64(ew * cos(t))) end
function tmp = code(eh, ew, t) tmp = abs((ew * cos(t))); end
code[eh_, ew_, t_] := N[Abs[N[(ew * N[Cos[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|ew \cdot \cos t\right|
Initial program 99.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-atan.f64N/A
atan-neg-revN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-atan.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.8%
Applied rewrites99.8%
Applied rewrites77.0%
Taylor expanded in t around 0
lower-/.f6442.5%
Applied rewrites42.5%
Taylor expanded in eh around 0
lower-*.f64N/A
lower-cos.f6462.5%
Applied rewrites62.5%
(FPCore (eh ew t) :precision binary64 (fabs (/ 1 (/ 1 ew))))
double code(double eh, double ew, double t) {
return fabs((1.0 / (1.0 / ew)));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(eh, ew, t)
use fmin_fmax_functions
real(8), intent (in) :: eh
real(8), intent (in) :: ew
real(8), intent (in) :: t
code = abs((1.0d0 / (1.0d0 / ew)))
end function
public static double code(double eh, double ew, double t) {
return Math.abs((1.0 / (1.0 / ew)));
}
def code(eh, ew, t): return math.fabs((1.0 / (1.0 / ew)))
function code(eh, ew, t) return abs(Float64(1.0 / Float64(1.0 / ew))) end
function tmp = code(eh, ew, t) tmp = abs((1.0 / (1.0 / ew))); end
code[eh_, ew_, t_] := N[Abs[N[(1 / N[(1 / ew), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\left|\frac{1}{\frac{1}{ew}}\right|
Initial program 99.8%
lift-cos.f64N/A
cos-neg-revN/A
lower-cos.f64N/A
lift-atan.f64N/A
atan-neg-revN/A
lift-/.f64N/A
distribute-neg-fracN/A
lower-atan.f64N/A
lower-/.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
distribute-lft-neg-outN/A
remove-double-negN/A
*-commutativeN/A
lower-*.f6499.8%
Applied rewrites99.8%
Applied rewrites77.0%
Taylor expanded in t around 0
lower-/.f6442.5%
Applied rewrites42.5%
herbie shell --seed 2025271 -o generate:evaluate
(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)))))))