
(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}
Sampling outcomes in binary64 precision:
Herbie found 6 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}
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (tan x_m) -0.005) (- (tanh (log (- (tan x_m))))) (- (tanh (log (tan x_m))))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if (tan(x_m) <= -0.005) {
tmp = -tanh(log(-tan(x_m)));
} else {
tmp = -tanh(log(tan(x_m)));
}
return tmp;
}
x_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8) :: tmp
if (tan(x_m) <= (-0.005d0)) then
tmp = -tanh(log(-tan(x_m)))
else
tmp = -tanh(log(tan(x_m)))
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m) {
double tmp;
if (Math.tan(x_m) <= -0.005) {
tmp = -Math.tanh(Math.log(-Math.tan(x_m)));
} else {
tmp = -Math.tanh(Math.log(Math.tan(x_m)));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m): tmp = 0 if math.tan(x_m) <= -0.005: tmp = -math.tanh(math.log(-math.tan(x_m))) else: tmp = -math.tanh(math.log(math.tan(x_m))) return tmp
x_m = abs(x) function code(x_m) tmp = 0.0 if (tan(x_m) <= -0.005) tmp = Float64(-tanh(log(Float64(-tan(x_m))))); else tmp = Float64(-tanh(log(tan(x_m)))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m) tmp = 0.0; if (tan(x_m) <= -0.005) tmp = -tanh(log(-tan(x_m))); else tmp = -tanh(log(tan(x_m))); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[Tan[x$95$m], $MachinePrecision], -0.005], (-N[Tanh[N[Log[(-N[Tan[x$95$m], $MachinePrecision])], $MachinePrecision]], $MachinePrecision]), (-N[Tanh[N[Log[N[Tan[x$95$m], $MachinePrecision]], $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\tan x\_m \leq -0.005:\\
\;\;\;\;-\tanh \log \left(-\tan x\_m\right)\\
\mathbf{else}:\\
\;\;\;\;-\tanh \log \tan x\_m\\
\end{array}
\end{array}
if (tan.f64 x) < -0.0050000000000000001Initial program 99.2%
Applied rewrites99.1%
lift-/.f64N/A
lift-fma.f64N/A
sqr-neg-revN/A
lift-neg.f64N/A
lift-neg.f64N/A
difference-of-sqr--1N/A
difference-of-sqr-1N/A
pow2N/A
exp-to-powN/A
lift-log.f64N/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
Applied rewrites99.3%
if -0.0050000000000000001 < (tan.f64 x) Initial program 99.5%
lift-*.f64N/A
pow2N/A
lower-pow.f6499.5
Applied rewrites99.5%
Applied rewrites72.3%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (- (fma (tan x_m) (tan x_m) -1.0)) (- (pow (tan x_m) 2.0) -1.0)))
x_m = fabs(x);
double code(double x_m) {
return -fma(tan(x_m), tan(x_m), -1.0) / (pow(tan(x_m), 2.0) - -1.0);
}
x_m = abs(x) function code(x_m) return Float64(Float64(-fma(tan(x_m), tan(x_m), -1.0)) / Float64((tan(x_m) ^ 2.0) - -1.0)) end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[((-N[(N[Tan[x$95$m], $MachinePrecision] * N[Tan[x$95$m], $MachinePrecision] + -1.0), $MachinePrecision]) / N[(N[Power[N[Tan[x$95$m], $MachinePrecision], 2.0], $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{-\mathsf{fma}\left(\tan x\_m, \tan x\_m, -1\right)}{{\tan x\_m}^{2} - -1}
\end{array}
Initial program 99.5%
Applied rewrites99.5%
lift-tan.f64N/A
tan-quotN/A
lift-sin.f64N/A
lift-cos.f64N/A
lower-/.f6499.4
Applied rewrites99.4%
lift-fma.f64N/A
flip-+N/A
Applied rewrites99.5%
Final simplification99.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (let* ((t_0 (pow (tan x_m) 2.0))) (/ (- 1.0 t_0) (+ 1.0 t_0))))
x_m = fabs(x);
double code(double x_m) {
double t_0 = pow(tan(x_m), 2.0);
return (1.0 - t_0) / (1.0 + t_0);
}
x_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8) :: t_0
t_0 = tan(x_m) ** 2.0d0
code = (1.0d0 - t_0) / (1.0d0 + t_0)
end function
x_m = Math.abs(x);
public static double code(double x_m) {
double t_0 = Math.pow(Math.tan(x_m), 2.0);
return (1.0 - t_0) / (1.0 + t_0);
}
x_m = math.fabs(x) def code(x_m): t_0 = math.pow(math.tan(x_m), 2.0) return (1.0 - t_0) / (1.0 + t_0)
x_m = abs(x) function code(x_m) t_0 = tan(x_m) ^ 2.0 return Float64(Float64(1.0 - t_0) / Float64(1.0 + t_0)) end
x_m = abs(x); function tmp = code(x_m) t_0 = tan(x_m) ^ 2.0; tmp = (1.0 - t_0) / (1.0 + t_0); end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_] := Block[{t$95$0 = N[Power[N[Tan[x$95$m], $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(1.0 - t$95$0), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := {\tan x\_m}^{2}\\
\frac{1 - t\_0}{1 + t\_0}
\end{array}
\end{array}
Initial program 99.5%
lift-*.f64N/A
pow2N/A
lower-pow.f6499.5
Applied rewrites99.5%
lift-*.f64N/A
pow2N/A
lift-pow.f6499.5
Applied rewrites99.5%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (if (<= (tan x_m) -0.005) (/ (- 1.0 (* (tan x_m) (tan x_m))) 1.0) (- (tanh (log (tan x_m))))))
x_m = fabs(x);
double code(double x_m) {
double tmp;
if (tan(x_m) <= -0.005) {
tmp = (1.0 - (tan(x_m) * tan(x_m))) / 1.0;
} else {
tmp = -tanh(log(tan(x_m)));
}
return tmp;
}
x_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
real(8) :: tmp
if (tan(x_m) <= (-0.005d0)) then
tmp = (1.0d0 - (tan(x_m) * tan(x_m))) / 1.0d0
else
tmp = -tanh(log(tan(x_m)))
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m) {
double tmp;
if (Math.tan(x_m) <= -0.005) {
tmp = (1.0 - (Math.tan(x_m) * Math.tan(x_m))) / 1.0;
} else {
tmp = -Math.tanh(Math.log(Math.tan(x_m)));
}
return tmp;
}
x_m = math.fabs(x) def code(x_m): tmp = 0 if math.tan(x_m) <= -0.005: tmp = (1.0 - (math.tan(x_m) * math.tan(x_m))) / 1.0 else: tmp = -math.tanh(math.log(math.tan(x_m))) return tmp
x_m = abs(x) function code(x_m) tmp = 0.0 if (tan(x_m) <= -0.005) tmp = Float64(Float64(1.0 - Float64(tan(x_m) * tan(x_m))) / 1.0); else tmp = Float64(-tanh(log(tan(x_m)))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m) tmp = 0.0; if (tan(x_m) <= -0.005) tmp = (1.0 - (tan(x_m) * tan(x_m))) / 1.0; else tmp = -tanh(log(tan(x_m))); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := If[LessEqual[N[Tan[x$95$m], $MachinePrecision], -0.005], N[(N[(1.0 - N[(N[Tan[x$95$m], $MachinePrecision] * N[Tan[x$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], (-N[Tanh[N[Log[N[Tan[x$95$m], $MachinePrecision]], $MachinePrecision]], $MachinePrecision])]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\tan x\_m \leq -0.005:\\
\;\;\;\;\frac{1 - \tan x\_m \cdot \tan x\_m}{1}\\
\mathbf{else}:\\
\;\;\;\;-\tanh \log \tan x\_m\\
\end{array}
\end{array}
if (tan.f64 x) < -0.0050000000000000001Initial program 99.2%
Taylor expanded in x around 0
Applied rewrites19.9%
if -0.0050000000000000001 < (tan.f64 x) Initial program 99.5%
lift-*.f64N/A
pow2N/A
lower-pow.f6499.5
Applied rewrites99.5%
Applied rewrites72.3%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 (/ (- 1.0 (* (tan x_m) (tan x_m))) 1.0))
x_m = fabs(x);
double code(double x_m) {
return (1.0 - (tan(x_m) * tan(x_m))) / 1.0;
}
x_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
code = (1.0d0 - (tan(x_m) * tan(x_m))) / 1.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return (1.0 - (Math.tan(x_m) * Math.tan(x_m))) / 1.0;
}
x_m = math.fabs(x) def code(x_m): return (1.0 - (math.tan(x_m) * math.tan(x_m))) / 1.0
x_m = abs(x) function code(x_m) return Float64(Float64(1.0 - Float64(tan(x_m) * tan(x_m))) / 1.0) end
x_m = abs(x); function tmp = code(x_m) tmp = (1.0 - (tan(x_m) * tan(x_m))) / 1.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := N[(N[(1.0 - N[(N[Tan[x$95$m], $MachinePrecision] * N[Tan[x$95$m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1 - \tan x\_m \cdot \tan x\_m}{1}
\end{array}
Initial program 99.5%
Taylor expanded in x around 0
Applied rewrites55.4%
x_m = (fabs.f64 x) (FPCore (x_m) :precision binary64 1.0)
x_m = fabs(x);
double code(double x_m) {
return 1.0;
}
x_m = private
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_m)
use fmin_fmax_functions
real(8), intent (in) :: x_m
code = 1.0d0
end function
x_m = Math.abs(x);
public static double code(double x_m) {
return 1.0;
}
x_m = math.fabs(x) def code(x_m): return 1.0
x_m = abs(x) function code(x_m) return 1.0 end
x_m = abs(x); function tmp = code(x_m) tmp = 1.0; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_] := 1.0
\begin{array}{l}
x_m = \left|x\right|
\\
1
\end{array}
Initial program 99.5%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites50.1%
herbie shell --seed 2024347
(FPCore (x)
:name "Trigonometry B"
:precision binary64
(/ (- 1.0 (* (tan x) (tan x))) (+ 1.0 (* (tan x) (tan x)))))