
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
double code(double x) {
return (1.0 - cos(x)) / sin(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / sin(x)
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / Math.sin(x);
}
def code(x): return (1.0 - math.cos(x)) / math.sin(x)
function code(x) return Float64(Float64(1.0 - cos(x)) / sin(x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / sin(x); end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \cos x}{\sin x}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (/ (- 1.0 (cos x)) (sin x)))
double code(double x) {
return (1.0 - cos(x)) / sin(x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 - cos(x)) / sin(x)
end function
public static double code(double x) {
return (1.0 - Math.cos(x)) / Math.sin(x);
}
def code(x): return (1.0 - math.cos(x)) / math.sin(x)
function code(x) return Float64(Float64(1.0 - cos(x)) / sin(x)) end
function tmp = code(x) tmp = (1.0 - cos(x)) / sin(x); end
code[x_] := N[(N[(1.0 - N[Cos[x], $MachinePrecision]), $MachinePrecision] / N[Sin[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1 - \cos x}{\sin x}
\end{array}
(FPCore (x) :precision binary64 (tan (/ x 2.0)))
double code(double x) {
return tan((x / 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = tan((x / 2.0d0))
end function
public static double code(double x) {
return Math.tan((x / 2.0));
}
def code(x): return math.tan((x / 2.0))
function code(x) return tan(Float64(x / 2.0)) end
function tmp = code(x) tmp = tan((x / 2.0)); end
code[x_] := N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan \left(\frac{x}{2}\right)
\end{array}
Initial program 50.3%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
(FPCore (x)
:precision binary64
(if (<= x 1800.0)
(*
x
(/
(+
(* x (* x (+ -0.041666666666666664 (* (* x x) -0.001736111111111111))))
-0.25)
(-
(*
x
(*
x
(*
(* x x)
(+ 0.004166666666666667 (* (* x x) 0.00042162698412698415)))))
(+ (* (* x x) 0.041666666666666664) 0.5))))
1.0))
double code(double x) {
double tmp;
if (x <= 1800.0) {
tmp = x * (((x * (x * (-0.041666666666666664 + ((x * x) * -0.001736111111111111)))) + -0.25) / ((x * (x * ((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))))) - (((x * x) * 0.041666666666666664) + 0.5)));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 1800.0d0) then
tmp = x * (((x * (x * ((-0.041666666666666664d0) + ((x * x) * (-0.001736111111111111d0))))) + (-0.25d0)) / ((x * (x * ((x * x) * (0.004166666666666667d0 + ((x * x) * 0.00042162698412698415d0))))) - (((x * x) * 0.041666666666666664d0) + 0.5d0)))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 1800.0) {
tmp = x * (((x * (x * (-0.041666666666666664 + ((x * x) * -0.001736111111111111)))) + -0.25) / ((x * (x * ((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))))) - (((x * x) * 0.041666666666666664) + 0.5)));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 1800.0: tmp = x * (((x * (x * (-0.041666666666666664 + ((x * x) * -0.001736111111111111)))) + -0.25) / ((x * (x * ((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))))) - (((x * x) * 0.041666666666666664) + 0.5))) else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 1800.0) tmp = Float64(x * Float64(Float64(Float64(x * Float64(x * Float64(-0.041666666666666664 + Float64(Float64(x * x) * -0.001736111111111111)))) + -0.25) / Float64(Float64(x * Float64(x * Float64(Float64(x * x) * Float64(0.004166666666666667 + Float64(Float64(x * x) * 0.00042162698412698415))))) - Float64(Float64(Float64(x * x) * 0.041666666666666664) + 0.5)))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 1800.0) tmp = x * (((x * (x * (-0.041666666666666664 + ((x * x) * -0.001736111111111111)))) + -0.25) / ((x * (x * ((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))))) - (((x * x) * 0.041666666666666664) + 0.5))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 1800.0], N[(x * N[(N[(N[(x * N[(x * N[(-0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * -0.001736111111111111), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -0.25), $MachinePrecision] / N[(N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * N[(0.004166666666666667 + N[(N[(x * x), $MachinePrecision] * 0.00042162698412698415), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(x * x), $MachinePrecision] * 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1800:\\
\;\;\;\;x \cdot \frac{x \cdot \left(x \cdot \left(-0.041666666666666664 + \left(x \cdot x\right) \cdot -0.001736111111111111\right)\right) + -0.25}{x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right)\right)\right) - \left(\left(x \cdot x\right) \cdot 0.041666666666666664 + 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1800Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6469.7%
Simplified69.7%
distribute-lft-inN/A
associate-*r*N/A
associate-+r+N/A
+-lowering-+.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6469.7%
Applied egg-rr69.7%
+-commutativeN/A
flip-+N/A
/-lowering-/.f64N/A
Applied egg-rr69.2%
Taylor expanded in x around 0
sub-negN/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
metadata-eval69.4%
Simplified69.4%
if 1800 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
Final simplification56.0%
(FPCore (x)
:precision binary64
(if (<= x 3.2)
(+
(/ x 2.0)
(*
x
(*
x
(*
x
(+
(* (* x x) (+ 0.004166666666666667 (* (* x x) 0.00042162698412698415)))
0.041666666666666664)))))
1.0))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = (x / 2.0) + (x * (x * (x * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664))));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.2d0) then
tmp = (x / 2.0d0) + (x * (x * (x * (((x * x) * (0.004166666666666667d0 + ((x * x) * 0.00042162698412698415d0))) + 0.041666666666666664d0))))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = (x / 2.0) + (x * (x * (x * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = (x / 2.0) + (x * (x * (x * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664)))) else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = Float64(Float64(x / 2.0) + Float64(x * Float64(x * Float64(x * Float64(Float64(Float64(x * x) * Float64(0.004166666666666667 + Float64(Float64(x * x) * 0.00042162698412698415))) + 0.041666666666666664))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = (x / 2.0) + (x * (x * (x * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664)))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[(N[(x / 2.0), $MachinePrecision] + N[(x * N[(x * N[(x * N[(N[(N[(x * x), $MachinePrecision] * N[(0.004166666666666667 + N[(N[(x * x), $MachinePrecision] * 0.00042162698412698415), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;\frac{x}{2} + x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right) + 0.041666666666666664\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6469.7%
Simplified69.7%
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
associate-/r/N/A
clear-numN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6469.7%
Applied egg-rr69.7%
if 3.2000000000000002 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
Final simplification56.2%
(FPCore (x)
:precision binary64
(if (<= x 3.2)
(*
x
(+
0.5
(*
(* x x)
(+
(* (* x x) (+ 0.004166666666666667 (* (* x x) 0.00042162698412698415)))
0.041666666666666664))))
1.0))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x * (0.5 + ((x * x) * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664)));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.2d0) then
tmp = x * (0.5d0 + ((x * x) * (((x * x) * (0.004166666666666667d0 + ((x * x) * 0.00042162698412698415d0))) + 0.041666666666666664d0)))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x * (0.5 + ((x * x) * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664)));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = x * (0.5 + ((x * x) * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664))) else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = Float64(x * Float64(0.5 + Float64(Float64(x * x) * Float64(Float64(Float64(x * x) * Float64(0.004166666666666667 + Float64(Float64(x * x) * 0.00042162698412698415))) + 0.041666666666666664)))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = x * (0.5 + ((x * x) * (((x * x) * (0.004166666666666667 + ((x * x) * 0.00042162698412698415))) + 0.041666666666666664))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[(x * N[(0.5 + N[(N[(x * x), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * N[(0.004166666666666667 + N[(N[(x * x), $MachinePrecision] * 0.00042162698412698415), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;x \cdot \left(0.5 + \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(0.004166666666666667 + \left(x \cdot x\right) \cdot 0.00042162698412698415\right) + 0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6469.7%
Simplified69.7%
if 3.2000000000000002 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
Final simplification56.2%
(FPCore (x)
:precision binary64
(if (<= x 3.2)
(+
(/ x 2.0)
(*
(* x (* x x))
(+ 0.041666666666666664 (* x (* x 0.004166666666666667)))))
1.0))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = (x / 2.0) + ((x * (x * x)) * (0.041666666666666664 + (x * (x * 0.004166666666666667))));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.2d0) then
tmp = (x / 2.0d0) + ((x * (x * x)) * (0.041666666666666664d0 + (x * (x * 0.004166666666666667d0))))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = (x / 2.0) + ((x * (x * x)) * (0.041666666666666664 + (x * (x * 0.004166666666666667))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = (x / 2.0) + ((x * (x * x)) * (0.041666666666666664 + (x * (x * 0.004166666666666667)))) else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = Float64(Float64(x / 2.0) + Float64(Float64(x * Float64(x * x)) * Float64(0.041666666666666664 + Float64(x * Float64(x * 0.004166666666666667))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = (x / 2.0) + ((x * (x * x)) * (0.041666666666666664 + (x * (x * 0.004166666666666667)))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[(N[(x / 2.0), $MachinePrecision] + N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(0.041666666666666664 + N[(x * N[(x * 0.004166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;\frac{x}{2} + \left(x \cdot \left(x \cdot x\right)\right) \cdot \left(0.041666666666666664 + x \cdot \left(x \cdot 0.004166666666666667\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6469.6%
Simplified69.6%
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
associate-/r/N/A
clear-numN/A
/-lowering-/.f64N/A
associate-*r*N/A
associate-*r*N/A
cube-unmultN/A
*-lowering-*.f64N/A
cube-unmultN/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f6469.6%
Applied egg-rr69.6%
if 3.2000000000000002 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
(FPCore (x)
:precision binary64
(if (<= x 3.2)
(*
x
(+
0.5
(* x (* x (+ 0.041666666666666664 (* (* x x) 0.004166666666666667))))))
1.0))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x * (0.5 + (x * (x * (0.041666666666666664 + ((x * x) * 0.004166666666666667)))));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.2d0) then
tmp = x * (0.5d0 + (x * (x * (0.041666666666666664d0 + ((x * x) * 0.004166666666666667d0)))))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x * (0.5 + (x * (x * (0.041666666666666664 + ((x * x) * 0.004166666666666667)))));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = x * (0.5 + (x * (x * (0.041666666666666664 + ((x * x) * 0.004166666666666667))))) else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = Float64(x * Float64(0.5 + Float64(x * Float64(x * Float64(0.041666666666666664 + Float64(Float64(x * x) * 0.004166666666666667)))))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = x * (0.5 + (x * (x * (0.041666666666666664 + ((x * x) * 0.004166666666666667))))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[(x * N[(0.5 + N[(x * N[(x * N[(0.041666666666666664 + N[(N[(x * x), $MachinePrecision] * 0.004166666666666667), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;x \cdot \left(0.5 + x \cdot \left(x \cdot \left(0.041666666666666664 + \left(x \cdot x\right) \cdot 0.004166666666666667\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
+-lowering-+.f64N/A
*-commutativeN/A
*-lowering-*.f64N/A
unpow2N/A
*-lowering-*.f6469.6%
Simplified69.6%
if 3.2000000000000002 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
(FPCore (x) :precision binary64 (if (<= x 3.2) (+ (/ x 2.0) (* x (* x (* x 0.041666666666666664)))) 1.0))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = (x / 2.0) + (x * (x * (x * 0.041666666666666664)));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.2d0) then
tmp = (x / 2.0d0) + (x * (x * (x * 0.041666666666666664d0)))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = (x / 2.0) + (x * (x * (x * 0.041666666666666664)));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = (x / 2.0) + (x * (x * (x * 0.041666666666666664))) else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = Float64(Float64(x / 2.0) + Float64(x * Float64(x * Float64(x * 0.041666666666666664)))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = (x / 2.0) + (x * (x * (x * 0.041666666666666664))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[(N[(x / 2.0), $MachinePrecision] + N[(x * N[(x * N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;\frac{x}{2} + x \cdot \left(x \cdot \left(x \cdot 0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6469.5%
Simplified69.5%
distribute-rgt-inN/A
*-commutativeN/A
+-lowering-+.f64N/A
metadata-evalN/A
associate-/r/N/A
clear-numN/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6469.5%
Applied egg-rr69.5%
if 3.2000000000000002 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
(FPCore (x) :precision binary64 (if (<= x 3.2) (* x (+ 0.5 (* x (* x 0.041666666666666664)))) 1.0))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x * (0.5 + (x * (x * 0.041666666666666664)));
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.2d0) then
tmp = x * (0.5d0 + (x * (x * 0.041666666666666664d0)))
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x * (0.5 + (x * (x * 0.041666666666666664)));
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = x * (0.5 + (x * (x * 0.041666666666666664))) else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = Float64(x * Float64(0.5 + Float64(x * Float64(x * 0.041666666666666664)))); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = x * (0.5 + (x * (x * 0.041666666666666664))); else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[(x * N[(0.5 + N[(x * N[(x * 0.041666666666666664), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;x \cdot \left(0.5 + x \cdot \left(x \cdot 0.041666666666666664\right)\right)\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-lowering-*.f64N/A
+-lowering-+.f64N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
*-lowering-*.f64N/A
*-commutativeN/A
*-lowering-*.f6469.5%
Simplified69.5%
if 3.2000000000000002 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
(FPCore (x) :precision binary64 (if (<= x 3.2) (/ x 2.0) 1.0))
double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x / 2.0;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 3.2d0) then
tmp = x / 2.0d0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x) {
double tmp;
if (x <= 3.2) {
tmp = x / 2.0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x): tmp = 0 if x <= 3.2: tmp = x / 2.0 else: tmp = 1.0 return tmp
function code(x) tmp = 0.0 if (x <= 3.2) tmp = Float64(x / 2.0); else tmp = 1.0; end return tmp end
function tmp_2 = code(x) tmp = 0.0; if (x <= 3.2) tmp = x / 2.0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_] := If[LessEqual[x, 3.2], N[(x / 2.0), $MachinePrecision], 1.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.2:\\
\;\;\;\;\frac{x}{2}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 3.2000000000000002Initial program 35.4%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Taylor expanded in x around 0
*-commutativeN/A
metadata-evalN/A
associate-/l*N/A
*-rgt-identityN/A
/-lowering-/.f6469.3%
Simplified69.3%
if 3.2000000000000002 < x Initial program 99.1%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr12.1%
pow-base-112.1%
Applied egg-rr12.1%
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
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 50.3%
hang-p0-tanN/A
tan-lowering-tan.f64N/A
/-lowering-/.f64100.0%
Simplified100.0%
Applied egg-rr7.1%
pow-base-17.1%
Applied egg-rr7.1%
(FPCore (x) :precision binary64 (tan (/ x 2.0)))
double code(double x) {
return tan((x / 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = tan((x / 2.0d0))
end function
public static double code(double x) {
return Math.tan((x / 2.0));
}
def code(x): return math.tan((x / 2.0))
function code(x) return tan(Float64(x / 2.0)) end
function tmp = code(x) tmp = tan((x / 2.0)); end
code[x_] := N[Tan[N[(x / 2.0), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\tan \left(\frac{x}{2}\right)
\end{array}
herbie shell --seed 2024154
(FPCore (x)
:name "tanhf (example 3.4)"
:precision binary64
:alt
(! :herbie-platform default (tan (/ x 2)))
(/ (- 1.0 (cos x)) (sin x)))