
(FPCore (x) :precision binary64 (let* ((t_0 (* (tan x) (tan x)))) (/ (- 1.0 t_0) (+ 1.0 t_0))))
double code(double x) {
double t_0 = tan(x) * tan(x);
return (1.0 - t_0) / (1.0 + t_0);
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = tan(x) * tan(x)
code = (1.0d0 - t_0) / (1.0d0 + t_0)
end function
public static double code(double x) {
double t_0 = Math.tan(x) * Math.tan(x);
return (1.0 - t_0) / (1.0 + t_0);
}
def code(x): t_0 = math.tan(x) * math.tan(x) return (1.0 - t_0) / (1.0 + t_0)
function code(x) t_0 = Float64(tan(x) * tan(x)) return Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0)) end
function tmp = code(x) t_0 = tan(x) * tan(x); tmp = (1.0 - t_0) / (1.0 + t_0); end
code[x_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan x\\
\frac{1 - t\_0}{1 + t\_0}
\end{array}
\end{array}
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (let* ((t_0 (* (tan x) (tan x)))) (/ (- 1.0 t_0) (+ 1.0 t_0))))
double code(double x) {
double t_0 = tan(x) * tan(x);
return (1.0 - t_0) / (1.0 + t_0);
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = tan(x) * tan(x)
code = (1.0d0 - t_0) / (1.0d0 + t_0)
end function
public static double code(double x) {
double t_0 = Math.tan(x) * Math.tan(x);
return (1.0 - t_0) / (1.0 + t_0);
}
def code(x): t_0 = math.tan(x) * math.tan(x) return (1.0 - t_0) / (1.0 + t_0)
function code(x) t_0 = Float64(tan(x) * tan(x)) return Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0)) end
function tmp = code(x) t_0 = tan(x) * tan(x); tmp = (1.0 - t_0) / (1.0 + t_0); end
code[x_] := Block[{t$95$0 = N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \tan x \cdot \tan x\\
\frac{1 - t\_0}{1 + t\_0}
\end{array}
\end{array}
(FPCore (x) :precision binary64 (* (pow (cos x) -2.0) (/ (cos (+ x x)) (- (pow (tan x) 2.0) -1.0))))
double code(double x) {
return pow(cos(x), -2.0) * (cos((x + x)) / (pow(tan(x), 2.0) - -1.0));
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (cos(x) ** (-2.0d0)) * (cos((x + x)) / ((tan(x) ** 2.0d0) - (-1.0d0)))
end function
public static double code(double x) {
return Math.pow(Math.cos(x), -2.0) * (Math.cos((x + x)) / (Math.pow(Math.tan(x), 2.0) - -1.0));
}
def code(x): return math.pow(math.cos(x), -2.0) * (math.cos((x + x)) / (math.pow(math.tan(x), 2.0) - -1.0))
function code(x) return Float64((cos(x) ^ -2.0) * Float64(cos(Float64(x + x)) / Float64((tan(x) ^ 2.0) - -1.0))) end
function tmp = code(x) tmp = (cos(x) ^ -2.0) * (cos((x + x)) / ((tan(x) ^ 2.0) - -1.0)); end
code[x_] := N[(N[Power[N[Cos[x], $MachinePrecision], -2.0], $MachinePrecision] * N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\cos x}^{-2} \cdot \frac{\cos \left(x + x\right)}{{\tan x}^{2} - -1}
\end{array}
Initial program 99.5%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.4
Applied rewrites99.4%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.5
Applied rewrites99.5%
Applied rewrites99.1%
lift-/.f64N/A
metadata-evalN/A
lift-*.f64N/A
lift-fma.f64N/A
lift-+.f64N/A
lift-cos.f64N/A
*-commutativeN/A
frac-timesN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
fp-cancel-sign-sub-invN/A
count-2-revN/A
metadata-evalN/A
distribute-lft-neg-inN/A
fp-cancel-sign-sub-invN/A
mult-flipN/A
Applied rewrites99.5%
(FPCore (x) :precision binary64 (let* ((t_0 (/ 1.0 (pow (tan x) -2.0)))) (/ (- 1.0 t_0) (+ 1.0 t_0))))
double code(double x) {
double t_0 = 1.0 / pow(tan(x), -2.0);
return (1.0 - t_0) / (1.0 + t_0);
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = 1.0d0 / (tan(x) ** (-2.0d0))
code = (1.0d0 - t_0) / (1.0d0 + t_0)
end function
public static double code(double x) {
double t_0 = 1.0 / Math.pow(Math.tan(x), -2.0);
return (1.0 - t_0) / (1.0 + t_0);
}
def code(x): t_0 = 1.0 / math.pow(math.tan(x), -2.0) return (1.0 - t_0) / (1.0 + t_0)
function code(x) t_0 = Float64(1.0 / (tan(x) ^ -2.0)) return Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0)) end
function tmp = code(x) t_0 = 1.0 / (tan(x) ^ -2.0); tmp = (1.0 - t_0) / (1.0 + t_0); end
code[x_] := Block[{t$95$0 = N[(1.0 / N[Power[N[Tan[x], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]}, N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{{\tan x}^{-2}}\\
\frac{1 - t\_0}{1 + t\_0}
\end{array}
\end{array}
Initial program 99.5%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.4
Applied rewrites99.4%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.5
Applied rewrites99.5%
(FPCore (x) :precision binary64 (let* ((t_0 (pow (tan x) 2.0))) (/ (- 1.0 t_0) (+ 1.0 t_0))))
double code(double x) {
double t_0 = pow(tan(x), 2.0);
return (1.0 - t_0) / (1.0 + t_0);
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
t_0 = tan(x) ** 2.0d0
code = (1.0d0 - t_0) / (1.0d0 + t_0)
end function
public static double code(double x) {
double t_0 = Math.pow(Math.tan(x), 2.0);
return (1.0 - t_0) / (1.0 + t_0);
}
def code(x): t_0 = math.pow(math.tan(x), 2.0) return (1.0 - t_0) / (1.0 + t_0)
function code(x) t_0 = tan(x) ^ 2.0 return Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0)) end
function tmp = code(x) t_0 = tan(x) ^ 2.0; tmp = (1.0 - t_0) / (1.0 + t_0); end
code[x_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
\frac{1 - t\_0}{1 + t\_0}
\end{array}
\end{array}
Initial program 99.5%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
lower-pow.f64N/A
lift-tan.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
lower-pow.f64N/A
lift-tan.f6499.5
Applied rewrites99.5%
(FPCore (x)
:precision binary64
(let* ((t_0 (pow (tan x) 2.0)))
(if (<= (tan x) -0.05)
(* 1.0 (/ (cos (+ x x)) (- t_0 -1.0)))
(/ (expm1 (* (log (tan x)) 2.0)) (- -1.0 t_0)))))
double code(double x) {
double t_0 = pow(tan(x), 2.0);
double tmp;
if (tan(x) <= -0.05) {
tmp = 1.0 * (cos((x + x)) / (t_0 - -1.0));
} else {
tmp = expm1((log(tan(x)) * 2.0)) / (-1.0 - t_0);
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.pow(Math.tan(x), 2.0);
double tmp;
if (Math.tan(x) <= -0.05) {
tmp = 1.0 * (Math.cos((x + x)) / (t_0 - -1.0));
} else {
tmp = Math.expm1((Math.log(Math.tan(x)) * 2.0)) / (-1.0 - t_0);
}
return tmp;
}
def code(x): t_0 = math.pow(math.tan(x), 2.0) tmp = 0 if math.tan(x) <= -0.05: tmp = 1.0 * (math.cos((x + x)) / (t_0 - -1.0)) else: tmp = math.expm1((math.log(math.tan(x)) * 2.0)) / (-1.0 - t_0) return tmp
function code(x) t_0 = tan(x) ^ 2.0 tmp = 0.0 if (tan(x) <= -0.05) tmp = Float64(1.0 * Float64(cos(Float64(x + x)) / Float64(t_0 - -1.0))); else tmp = Float64(expm1(Float64(log(tan(x)) * 2.0)) / Float64(-1.0 - t_0)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[Tan[x], $MachinePrecision], -0.05], N[(1.0 * N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / N[(t$95$0 - -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(Exp[N[(N[Log[N[Tan[x], $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]] - 1), $MachinePrecision] / N[(-1.0 - t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
\mathbf{if}\;\tan x \leq -0.05:\\
\;\;\;\;1 \cdot \frac{\cos \left(x + x\right)}{t\_0 - -1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\log \tan x \cdot 2\right)}{-1 - t\_0}\\
\end{array}
\end{array}
if (tan.f64 x) < -0.050000000000000003Initial program 99.0%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6498.8
Applied rewrites98.8%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.0
Applied rewrites99.0%
Applied rewrites98.2%
Taylor expanded in x around 0
Applied rewrites19.1%
if -0.050000000000000003 < (tan.f64 x) Initial program 99.7%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.6
Applied rewrites99.6%
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-flipN/A
metadata-evalN/A
lift-tan.f64N/A
lower--.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-flipN/A
metadata-evalN/A
lift-tan.f64N/A
lower-+.f64N/A
negate-sub2N/A
+-commutativeN/A
metadata-evalN/A
negate-subN/A
negate-sub2N/A
frac-2neg-revN/A
Applied rewrites66.0%
(FPCore (x)
:precision binary64
(let* ((t_0 (- (pow (tan x) 2.0) -1.0)))
(if (<= (* (tan x) (tan x)) 0.64)
(/ 1.0 (pow t_0 2.0))
(* 1.0 (/ (cos (+ x x)) t_0)))))
double code(double x) {
double t_0 = pow(tan(x), 2.0) - -1.0;
double tmp;
if ((tan(x) * tan(x)) <= 0.64) {
tmp = 1.0 / pow(t_0, 2.0);
} else {
tmp = 1.0 * (cos((x + x)) / t_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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = (tan(x) ** 2.0d0) - (-1.0d0)
if ((tan(x) * tan(x)) <= 0.64d0) then
tmp = 1.0d0 / (t_0 ** 2.0d0)
else
tmp = 1.0d0 * (cos((x + x)) / t_0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.pow(Math.tan(x), 2.0) - -1.0;
double tmp;
if ((Math.tan(x) * Math.tan(x)) <= 0.64) {
tmp = 1.0 / Math.pow(t_0, 2.0);
} else {
tmp = 1.0 * (Math.cos((x + x)) / t_0);
}
return tmp;
}
def code(x): t_0 = math.pow(math.tan(x), 2.0) - -1.0 tmp = 0 if (math.tan(x) * math.tan(x)) <= 0.64: tmp = 1.0 / math.pow(t_0, 2.0) else: tmp = 1.0 * (math.cos((x + x)) / t_0) return tmp
function code(x) t_0 = Float64((tan(x) ^ 2.0) - -1.0) tmp = 0.0 if (Float64(tan(x) * tan(x)) <= 0.64) tmp = Float64(1.0 / (t_0 ^ 2.0)); else tmp = Float64(1.0 * Float64(cos(Float64(x + x)) / t_0)); end return tmp end
function tmp_2 = code(x) t_0 = (tan(x) ^ 2.0) - -1.0; tmp = 0.0; if ((tan(x) * tan(x)) <= 0.64) tmp = 1.0 / (t_0 ^ 2.0); else tmp = 1.0 * (cos((x + x)) / t_0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] - -1.0), $MachinePrecision]}, If[LessEqual[N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision], 0.64], N[(1.0 / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision], N[(1.0 * N[(N[Cos[N[(x + x), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2} - -1\\
\mathbf{if}\;\tan x \cdot \tan x \leq 0.64:\\
\;\;\;\;\frac{1}{{t\_0}^{2}}\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \frac{\cos \left(x + x\right)}{t\_0}\\
\end{array}
\end{array}
if (*.f64 (tan.f64 x) (tan.f64 x)) < 0.640000000000000013Initial program 99.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
flip--N/A
lift-+.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
lift-tan.f64N/A
lift--.f64N/A
lift-pow.f64N/A
lift-tan.f64N/A
pow2N/A
lower-pow.f64N/A
lift-tan.f64N/A
lift-pow.f64N/A
lift--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites78.7%
if 0.640000000000000013 < (*.f64 (tan.f64 x) (tan.f64 x)) Initial program 98.9%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6498.6
Applied rewrites98.6%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6498.9
Applied rewrites98.9%
Applied rewrites97.5%
Taylor expanded in x around 0
Applied rewrites16.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (pow (tan x) 2.0)))
(if (<= (* (tan x) (tan x)) 0.62)
(/ 1.0 (pow (- t_0 -1.0) 2.0))
(- (/ 1.0 1.0) (/ t_0 1.0)))))
double code(double x) {
double t_0 = pow(tan(x), 2.0);
double tmp;
if ((tan(x) * tan(x)) <= 0.62) {
tmp = 1.0 / pow((t_0 - -1.0), 2.0);
} else {
tmp = (1.0 / 1.0) - (t_0 / 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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = tan(x) ** 2.0d0
if ((tan(x) * tan(x)) <= 0.62d0) then
tmp = 1.0d0 / ((t_0 - (-1.0d0)) ** 2.0d0)
else
tmp = (1.0d0 / 1.0d0) - (t_0 / 1.0d0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.pow(Math.tan(x), 2.0);
double tmp;
if ((Math.tan(x) * Math.tan(x)) <= 0.62) {
tmp = 1.0 / Math.pow((t_0 - -1.0), 2.0);
} else {
tmp = (1.0 / 1.0) - (t_0 / 1.0);
}
return tmp;
}
def code(x): t_0 = math.pow(math.tan(x), 2.0) tmp = 0 if (math.tan(x) * math.tan(x)) <= 0.62: tmp = 1.0 / math.pow((t_0 - -1.0), 2.0) else: tmp = (1.0 / 1.0) - (t_0 / 1.0) return tmp
function code(x) t_0 = tan(x) ^ 2.0 tmp = 0.0 if (Float64(tan(x) * tan(x)) <= 0.62) tmp = Float64(1.0 / (Float64(t_0 - -1.0) ^ 2.0)); else tmp = Float64(Float64(1.0 / 1.0) - Float64(t_0 / 1.0)); end return tmp end
function tmp_2 = code(x) t_0 = tan(x) ^ 2.0; tmp = 0.0; if ((tan(x) * tan(x)) <= 0.62) tmp = 1.0 / ((t_0 - -1.0) ^ 2.0); else tmp = (1.0 / 1.0) - (t_0 / 1.0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision], 0.62], N[(1.0 / N[Power[N[(t$95$0 - -1.0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / 1.0), $MachinePrecision] - N[(t$95$0 / 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
\mathbf{if}\;\tan x \cdot \tan x \leq 0.62:\\
\;\;\;\;\frac{1}{{\left(t\_0 - -1\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1} - \frac{t\_0}{1}\\
\end{array}
\end{array}
if (*.f64 (tan.f64 x) (tan.f64 x)) < 0.619999999999999996Initial program 99.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
flip--N/A
lift-+.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.6%
lift-*.f64N/A
lift--.f64N/A
lift-pow.f64N/A
lift-tan.f64N/A
lift--.f64N/A
lift-pow.f64N/A
lift-tan.f64N/A
pow2N/A
lower-pow.f64N/A
lift-tan.f64N/A
lift-pow.f64N/A
lift--.f6499.6
Applied rewrites99.6%
Taylor expanded in x around 0
Applied rewrites78.9%
if 0.619999999999999996 < (*.f64 (tan.f64 x) (tan.f64 x)) Initial program 98.9%
Taylor expanded in x around 0
Applied rewrites16.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
div-subN/A
Applied rewrites16.7%
(FPCore (x)
:precision binary64
(let* ((t_0 (pow (tan x) 2.0)))
(if (<= (* (tan x) (tan x)) 0.62)
(* 1.0 (pow (- t_0 -1.0) -2.0))
(- (/ 1.0 1.0) (/ t_0 1.0)))))
double code(double x) {
double t_0 = pow(tan(x), 2.0);
double tmp;
if ((tan(x) * tan(x)) <= 0.62) {
tmp = 1.0 * pow((t_0 - -1.0), -2.0);
} else {
tmp = (1.0 / 1.0) - (t_0 / 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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = tan(x) ** 2.0d0
if ((tan(x) * tan(x)) <= 0.62d0) then
tmp = 1.0d0 * ((t_0 - (-1.0d0)) ** (-2.0d0))
else
tmp = (1.0d0 / 1.0d0) - (t_0 / 1.0d0)
end if
code = tmp
end function
public static double code(double x) {
double t_0 = Math.pow(Math.tan(x), 2.0);
double tmp;
if ((Math.tan(x) * Math.tan(x)) <= 0.62) {
tmp = 1.0 * Math.pow((t_0 - -1.0), -2.0);
} else {
tmp = (1.0 / 1.0) - (t_0 / 1.0);
}
return tmp;
}
def code(x): t_0 = math.pow(math.tan(x), 2.0) tmp = 0 if (math.tan(x) * math.tan(x)) <= 0.62: tmp = 1.0 * math.pow((t_0 - -1.0), -2.0) else: tmp = (1.0 / 1.0) - (t_0 / 1.0) return tmp
function code(x) t_0 = tan(x) ^ 2.0 tmp = 0.0 if (Float64(tan(x) * tan(x)) <= 0.62) tmp = Float64(1.0 * (Float64(t_0 - -1.0) ^ -2.0)); else tmp = Float64(Float64(1.0 / 1.0) - Float64(t_0 / 1.0)); end return tmp end
function tmp_2 = code(x) t_0 = tan(x) ^ 2.0; tmp = 0.0; if ((tan(x) * tan(x)) <= 0.62) tmp = 1.0 * ((t_0 - -1.0) ^ -2.0); else tmp = (1.0 / 1.0) - (t_0 / 1.0); end tmp_2 = tmp; end
code[x_] := Block[{t$95$0 = N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision], 0.62], N[(1.0 * N[Power[N[(t$95$0 - -1.0), $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / 1.0), $MachinePrecision] - N[(t$95$0 / 1.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\tan x}^{2}\\
\mathbf{if}\;\tan x \cdot \tan x \leq 0.62:\\
\;\;\;\;1 \cdot {\left(t\_0 - -1\right)}^{-2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1} - \frac{t\_0}{1}\\
\end{array}
\end{array}
if (*.f64 (tan.f64 x) (tan.f64 x)) < 0.619999999999999996Initial program 99.7%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
metadata-evalN/A
pow-negN/A
lower-/.f64N/A
lower-pow.f64N/A
lift-tan.f6499.7
Applied rewrites99.7%
lift-/.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-flipN/A
metadata-evalN/A
lift-tan.f64N/A
lower--.f64N/A
lift-/.f64N/A
lift-pow.f64N/A
pow-flipN/A
metadata-evalN/A
lift-tan.f64N/A
lower-+.f64N/A
Applied rewrites50.8%
Taylor expanded in x around 0
Applied rewrites78.9%
if 0.619999999999999996 < (*.f64 (tan.f64 x) (tan.f64 x)) Initial program 98.9%
Taylor expanded in x around 0
Applied rewrites16.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
div-subN/A
Applied rewrites16.7%
(FPCore (x) :precision binary64 (- (/ 1.0 1.0) (/ (pow (tan x) 2.0) 1.0)))
double code(double x) {
return (1.0 / 1.0) - (pow(tan(x), 2.0) / 1.0);
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (1.0d0 / 1.0d0) - ((tan(x) ** 2.0d0) / 1.0d0)
end function
public static double code(double x) {
return (1.0 / 1.0) - (Math.pow(Math.tan(x), 2.0) / 1.0);
}
def code(x): return (1.0 / 1.0) - (math.pow(math.tan(x), 2.0) / 1.0)
function code(x) return Float64(Float64(1.0 / 1.0) - Float64((tan(x) ^ 2.0) / 1.0)) end
function tmp = code(x) tmp = (1.0 / 1.0) - ((tan(x) ^ 2.0) / 1.0); end
code[x_] := N[(N[(1.0 / 1.0), $MachinePrecision] - N[(N[Power[N[Tan[x], $MachinePrecision], 2.0], $MachinePrecision] / 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1} - \frac{{\tan x}^{2}}{1}
\end{array}
Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites59.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
pow2N/A
div-subN/A
Applied rewrites59.5%
(FPCore (x) :precision binary64 (/ (- 1.0 (pow (tan x) 4.0)) 1.0))
double code(double x) {
return (1.0 - pow(tan(x), 4.0)) / 1.0;
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = (1.0d0 - (tan(x) ** 4.0d0)) / 1.0d0
end function
public static double code(double x) {
return (1.0 - Math.pow(Math.tan(x), 4.0)) / 1.0;
}
def code(x): return (1.0 - math.pow(math.tan(x), 4.0)) / 1.0
function code(x) return Float64(Float64(1.0 - (tan(x) ^ 4.0)) / 1.0) end
function tmp = code(x) tmp = (1.0 - (tan(x) ^ 4.0)) / 1.0; end
code[x_] := N[(N[(1.0 - N[Power[N[Tan[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - {\tan x}^{4}}{1}
\end{array}
Initial program 99.5%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
flip--N/A
lift-+.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites99.3%
Taylor expanded in x around 0
Applied rewrites58.7%
(FPCore (x) :precision binary64 (if (<= (tan x) -0.05) 1.0 (* 1.0 (- (expm1 (* (log (tan x)) 2.0))))))
double code(double x) {
double tmp;
if (tan(x) <= -0.05) {
tmp = 1.0;
} else {
tmp = 1.0 * -expm1((log(tan(x)) * 2.0));
}
return tmp;
}
public static double code(double x) {
double tmp;
if (Math.tan(x) <= -0.05) {
tmp = 1.0;
} else {
tmp = 1.0 * -Math.expm1((Math.log(Math.tan(x)) * 2.0));
}
return tmp;
}
def code(x): tmp = 0 if math.tan(x) <= -0.05: tmp = 1.0 else: tmp = 1.0 * -math.expm1((math.log(math.tan(x)) * 2.0)) return tmp
function code(x) tmp = 0.0 if (tan(x) <= -0.05) tmp = 1.0; else tmp = Float64(1.0 * Float64(-expm1(Float64(log(tan(x)) * 2.0)))); end return tmp end
code[x_] := If[LessEqual[N[Tan[x], $MachinePrecision], -0.05], 1.0, N[(1.0 * (-N[(Exp[N[(N[Log[N[Tan[x], $MachinePrecision]], $MachinePrecision] * 2.0), $MachinePrecision]] - 1), $MachinePrecision])), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan x \leq -0.05:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;1 \cdot \left(-\mathsf{expm1}\left(\log \tan x \cdot 2\right)\right)\\
\end{array}
\end{array}
if (tan.f64 x) < -0.050000000000000003Initial program 99.0%
Taylor expanded in x around 0
Applied rewrites10.3%
if -0.050000000000000003 < (tan.f64 x) Initial program 99.7%
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-tan.f64N/A
lift-tan.f64N/A
mult-flipN/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites65.9%
Taylor expanded in x around 0
Applied rewrites39.8%
(FPCore (x) :precision binary64 (if (<= (* (tan x) (tan x)) 1.1) 1.0 (/ (- 1.0 (* x x)) (+ 1.0 (* x x)))))
double code(double x) {
double tmp;
if ((tan(x) * tan(x)) <= 1.1) {
tmp = 1.0;
} else {
tmp = (1.0 - (x * x)) / (1.0 + (x * x));
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8) :: tmp
if ((tan(x) * tan(x)) <= 1.1d0) then
tmp = 1.0d0
else
tmp = (1.0d0 - (x * x)) / (1.0d0 + (x * x))
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if ((Math.tan(x) * Math.tan(x)) <= 1.1) {
tmp = 1.0;
} else {
tmp = (1.0 - (x * x)) / (1.0 + (x * x));
}
return tmp;
}
def code(x): tmp = 0 if (math.tan(x) * math.tan(x)) <= 1.1: tmp = 1.0 else: tmp = (1.0 - (x * x)) / (1.0 + (x * x)) return tmp
function code(x) tmp = 0.0 if (Float64(tan(x) * tan(x)) <= 1.1) tmp = 1.0; else tmp = Float64(Float64(1.0 - Float64(x * x)) / Float64(1.0 + Float64(x * x))); end return tmp end
function tmp_2 = code(x) tmp = 0.0; if ((tan(x) * tan(x)) <= 1.1) tmp = 1.0; else tmp = (1.0 - (x * x)) / (1.0 + (x * x)); end tmp_2 = tmp; end
code[x_] := If[LessEqual[N[(N[Tan[x], $MachinePrecision] * N[Tan[x], $MachinePrecision]), $MachinePrecision], 1.1], 1.0, N[(N[(1.0 - N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\tan x \cdot \tan x \leq 1.1:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;\frac{1 - x \cdot x}{1 + x \cdot x}\\
\end{array}
\end{array}
if (*.f64 (tan.f64 x) (tan.f64 x)) < 1.1000000000000001Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites72.5%
if 1.1000000000000001 < (*.f64 (tan.f64 x) (tan.f64 x)) Initial program 99.3%
Taylor expanded in x around 0
Applied rewrites3.3%
Taylor expanded in x around 0
Applied rewrites4.2%
Taylor expanded in x around 0
Applied rewrites3.0%
Taylor expanded in x around 0
Applied rewrites10.2%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
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(x)
use fmin_fmax_functions
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites55.3%
herbie shell --seed 2025120
(FPCore (x)
:name "Trigonometry B"
:precision binary64
(/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))