Example #1
0
long double TSolver::calc(const char f,const long double a,const long double b) //calculates function
{switch (f)
   {case '+' : return a+b;
    case '-' : return a-b;
    case '*' : return a*b;
    case '/' : if (b==0) {Err=E_DEV_ZERO;return 0;};return a/b;
    case '!' : if (floorl(a)!=a) {Err=E_ARG;return 0;}return factor(a);
    case '_' : return -a;

    case cpi   : return M_PI;
    case cx    : return X;

    case fexp  : return exp(a);
    case fln   : if (a<0) {Err=E_ARG;return 0;}return logl(a);
    case flog  : if (a<0) {Err=E_ARG;return 0;}return log10l(a);
    case flogn : if (a<0) {Err=E_ARG;return 0;}return log(a)/log(b);

    case '^':
    case f_op_pow:
    case fpow  : if (a<0 && b<1 && b>0 && (!fmodl(b,2))) {Err=E_ARG;return 0;}return powl(a,b);
    case fsqr  : return a*a;
    case f_op_root:
    case froot : if (a<0 && (!fmodl(b,2))){Err=E_ARG;return 0;}
                   return (a>0 || (!fmodl(b,2)))?powl(a,1/b):-powl(-a,1/b);
    case fsqrt : if (a<0) {Err=E_ARG;return 0;}return sqrtl(a);
    case f_abs  : return fabsl(a);

    case fsin  : return sinl(a);
    case fcos  : return cosl(a);
    case ftan  : if (a==M_PI_2 || a==(M_PI_2+M_PI)) {Err=E_ARG;return 0;} return tanl(a);
    case fctan : if (a==0 || a==M_PI) {Err=E_ARG;return 0;} return 1/tanl(a);

    case fsin+ARC : if (fabsl(a)>1) {Err=E_ARG;return 0;} return asinl(a);
    case fcos+ARC : if (fabsl(a)>1) {Err=E_ARG;return 0;} return acosl(a);
    case ftan+ARC : return atanl(a);
    case fctan+ARC: return atanl(1/a);

    case fsin+HYP : return sinhl(a);
    case fcos+HYP : return coshl(a);
    case ftan+HYP : return tanhl(a);
    case fctan+HYP : return 1/tanhl(a);
#ifndef _OLD_
    case fsin+HYP+ARC : return asinhl(a);
    case fcos+HYP+ARC : return acoshl(a);
    case ftan+HYP+ARC : if (fabsl(a)>=1) {Err=E_ARG;return 0;} return atanhl(a);
    case fctan+HYP+ARC : if (a==0 ) {Err=E_ARG;return 0;} return atanhl(1/a);
#endif
    default: return 0;
   }
}
void test1l(long double x)
{
  if (cosl(x) != cosl(-x))
    link_error ();

  if (cosl(x) != cosl(fabsl(x)))
    link_error ();

  if (cosl(x) != cosl(-fabsl(x)))
    link_error ();

  if (cosl(tanl(x)) != cosl(tanl(-fabsl(x))))
    link_error ();

#ifdef HAVE_C99_RUNTIME
  if (sinl(x)/cosl(x) != tanl(x))
    link_error ();

  if (cosl(x)/sinl(x) != 1.0l/tanl(x))
    link_error ();

  if (tanl(x)*cosl(x) != sinl(x))
    link_error ();

  if (cosl(x)*tanl(x) != sinl(x))
    link_error ();

  if (sinl(x)/tanl(x) != cosl(x))
    link_error ();

  if (tanl(x)/sinl(x) != 1.0l/cosl(x))
    link_error ();
#endif
}
Example #3
0
Expression *eval_builtin(enum BUILTIN builtin, Expressions *arguments)
{
    assert(arguments && arguments->dim);
    Expression *arg0 = (Expression *)arguments->data[0];
    Expression *e = NULL;
    switch (builtin)
    {
	case BUILTINsin:
	    if (arg0->op == TOKfloat64)
		e = new RealExp(0, sinl(arg0->toReal()), Type::tfloat80);
	    break;

	case BUILTINcos:
	    if (arg0->op == TOKfloat64)
		e = new RealExp(0, cosl(arg0->toReal()), Type::tfloat80);
	    break;

	case BUILTINtan:
	    if (arg0->op == TOKfloat64)
		e = new RealExp(0, tanl(arg0->toReal()), Type::tfloat80);
	    break;

	case BUILTINsqrt:
	    if (arg0->op == TOKfloat64)
		e = new RealExp(0, sqrtl(arg0->toReal()), Type::tfloat80);
	    break;

	case BUILTINfabs:
	    if (arg0->op == TOKfloat64)
		e = new RealExp(0, fabsl(arg0->toReal()), Type::tfloat80);
	    break;
    }
    return e;
}
Example #4
0
void test_tan()
{
    static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
    static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
    static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
    assert(tan(0) == 0);
}
Example #5
0
File: tanl.c Project: FEI17N/gnulib
int
main (void)
{
  printf ("%.16Lg\n", tanl (0.7853981633974483096156608458198757210492));
  printf ("%.16Lg\n", tanl (-0.7853981633974483096156608458198757210492));
  printf ("%.16Lg\n", tanl (0.7853981633974483096156608458198757210492 *3));
  printf ("%.16Lg\n", tanl (-0.7853981633974483096156608458198757210492 *31));
  printf ("%.16Lg\n", tanl (0.7853981633974483096156608458198757210492 / 2));
  printf ("%.16Lg\n", tanl (0.7853981633974483096156608458198757210492 * 3/2));
  printf ("%.16Lg\n", tanl (0.7853981633974483096156608458198757210492 * 5/2));
}
Example #6
0
long double complex
ctanl (long double complex a)
{
  long double rt, it;
  long double complex n, d;

  rt = tanl (REALPART (a));
  it = tanhl (IMAGPART (a));
  COMPLEX_ASSIGN (n, rt, it);
  COMPLEX_ASSIGN (d, 1, - (rt * it));

  return n / d;
}
/** The digamma function in long double precision.
* @param x the real value of the argument
* @return the value of the digamma (psi) function at that point
* @author Richard J. Mathar
* @since 2005-11-24
*/
long double digammal(long double x)
{
	/* force into the interval 1..3 */
	if( x < 0.0L )
		return digammal(1.0L-x)+M_PIl/tanl(M_PIl*(1.0L-x)) ;	/* reflection formula */
	else if( x < 1.0L )
		return digammal(1.0L+x)-1.0L/x ;
	else if ( x == 1.0L)
		return -M_GAMMAl ;
	else if ( x == 2.0L)
		return 1.0L-M_GAMMAl ;
	else if ( x == 3.0L)
		return 1.5L-M_GAMMAl ;
	else if ( x > 3.0L)
		/* duplication formula */
		return 0.5L*(digammal(x/2.0L)+digammal((x+1.0L)/2.0L))+M_LN2l ;
	else
	{
		static long double Kncoe[] = { .30459198558715155634315638246624251L,
		.72037977439182833573548891941219706L, -.12454959243861367729528855995001087L,
		.27769457331927827002810119567456810e-1L, -.67762371439822456447373550186163070e-2L,
		.17238755142247705209823876688592170e-2L, -.44817699064252933515310345718960928e-3L,
		.11793660000155572716272710617753373e-3L, -.31253894280980134452125172274246963e-4L,
		.83173997012173283398932708991137488e-5L, -.22191427643780045431149221890172210e-5L,
		.59302266729329346291029599913617915e-6L, -.15863051191470655433559920279603632e-6L,
		.42459203983193603241777510648681429e-7L, -.11369129616951114238848106591780146e-7L,
		.304502217295931698401459168423403510e-8L, -.81568455080753152802915013641723686e-9L,
		.21852324749975455125936715817306383e-9L, -.58546491441689515680751900276454407e-10L,
		.15686348450871204869813586459513648e-10L, -.42029496273143231373796179302482033e-11L,
		.11261435719264907097227520956710754e-11L, -.30174353636860279765375177200637590e-12L,
		.80850955256389526647406571868193768e-13L, -.21663779809421233144009565199997351e-13L,
		.58047634271339391495076374966835526e-14L, -.15553767189204733561108869588173845e-14L,
		.41676108598040807753707828039353330e-15L, -.11167065064221317094734023242188463e-15L } ;

		register long double Tn_1 = 1.0L ;	/* T_{n-1}(x), started at n=1 */
		register long double Tn = x-2.0L ;	/* T_{n}(x) , started at n=1 */
		register long double resul = Kncoe[0] + Kncoe[1]*Tn ;

		x -= 2.0L ;

		for(int n = 2 ; n < sizeof(Kncoe)/sizeof(long double) ;n++)
		{
			const long double Tn1 = 2.0L * x * Tn - Tn_1 ;	/* Chebyshev recursion, Eq. 22.7.4 Abramowitz-Stegun */
			resul += Kncoe[n]*Tn1 ;
			Tn_1 = Tn ;
			Tn = Tn1 ;
		}
		return resul ;
	}
}
Example #8
0
static TACommandVerdict tanl_cmd(TAThread thread,TAInputStream stream)
{
    long double x, res;

    x = readLongDouble(&stream);

    START_TARGET_OPERATION(thread);

    errno = 0;
    res = tanl(x);

    END_TARGET_OPERATION(thread);

    writeInt(thread, errno);
    writeLongDouble(thread, res);
    sendResponse(thread);

    return taDefaultVerdict;
}
Example #9
0
LONG_DOUBLE eval_expr_func(eval_context *ctx, ast_node *tree) {
    expr_func_data *func_data = (expr_func_data*)tree->data;
    if (strcmp(func_data->name, "sin") == 0) return sinl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "cos") == 0) return cosl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "tan") == 0) return tanl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "acos") == 0) return acosl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "asin") == 0) return asinl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "atan") == 0) return atanl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "cosh") == 0) return coshl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "sinh") == 0) return sinhl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "tanh") == 0) return tanhl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "log") == 0) return logl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "log10") == 0) return log10l(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "ceil") == 0) return ceill(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "fabs") == 0) return fabsl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "floor") == 0) return floorl(eval_expr(ctx, func_data->rhs));
    else if (strcmp(func_data->name, "sqrt") == 0) return sqrtl(eval_expr(ctx, func_data->rhs));
    else return eval_emit_error(ctx, "Unknown function %s.", func_data->name);
}
Example #10
0
void
Tangente (Token ** Pila)
{

  Token *Operando = EntornoEjecucion_BuscaSimbolo (*Pila);
  if (Buzon.GetHuboError ())
    return;
  if (NoEsReal (Operando))
    {
      BorrarTokenSiEsVariable (Operando);
      return;
    }

  long double ValorDominio = Operando->GetDatoReal ();
  BorrarTokenSiEsVariable (Operando);
  ValorDominio = Estado.AngulosEnGrados ? ValorDominio * M_PI / 180.0L :
    ValorDominio;
  long double ValorSeno = sinl (ValorDominio);
  long double ValorCoseno = cosl (ValorDominio);
  long double ValorRetorno;
  if (fabsl (ValorSeno) == 1.0L)
    {
      Buzon.Error (LLAMADO_DE_FUNCION_NO_VALIDO);
      return;
    }
  else if (ValorCoseno == 1.0L)
    ValorRetorno = 0.0L;
  else
    ValorRetorno = tanl (ValorDominio);
  if (Buzon.GetHuboError ())
    return;
  Token *TokenRetorno = ConsigueToken (ValorRetorno);
  if (Buzon.GetHuboError ())
    return;
  delete Desapila (Pila);
  Apila (Pila, TokenRetorno);
  if (FueraDeRango (TokenRetorno))
    return;
  return;
}
Example #11
0
void
domathl (void)
{
#ifndef NO_LONG_DOUBLE
  long double f1;
  long double f2;

  int i1;

  f1 = acosl(0.0);
  fprintf( stdout, "acosl          : %Lf\n", f1);

  f1 = acoshl(0.0);
  fprintf( stdout, "acoshl         : %Lf\n", f1);

  f1 = asinl(1.0);
  fprintf( stdout, "asinl          : %Lf\n", f1);

  f1 = asinhl(1.0);
  fprintf( stdout, "asinhl         : %Lf\n", f1);

  f1 = atanl(M_PI_4);
  fprintf( stdout, "atanl          : %Lf\n", f1);

  f1 = atan2l(2.3, 2.3);
  fprintf( stdout, "atan2l         : %Lf\n", f1);

  f1 = atanhl(1.0);
  fprintf( stdout, "atanhl         : %Lf\n", f1);

  f1 = cbrtl(27.0);
  fprintf( stdout, "cbrtl          : %Lf\n", f1);

  f1 = ceill(3.5);
  fprintf( stdout, "ceill          : %Lf\n", f1);

  f1 = copysignl(3.5, -2.5);
  fprintf( stdout, "copysignl      : %Lf\n", f1);

  f1 = cosl(M_PI_2);
  fprintf( stdout, "cosl           : %Lf\n", f1);

  f1 = coshl(M_PI_2);
  fprintf( stdout, "coshl          : %Lf\n", f1);

  f1 = erfl(42.0);
  fprintf( stdout, "erfl           : %Lf\n", f1);

  f1 = erfcl(42.0);
  fprintf( stdout, "erfcl          : %Lf\n", f1);

  f1 = expl(0.42);
  fprintf( stdout, "expl           : %Lf\n", f1);

  f1 = exp2l(0.42);
  fprintf( stdout, "exp2l          : %Lf\n", f1);

  f1 = expm1l(0.00042);
  fprintf( stdout, "expm1l         : %Lf\n", f1);

  f1 = fabsl(-1.123);
  fprintf( stdout, "fabsl          : %Lf\n", f1);

  f1 = fdiml(1.123, 2.123);
  fprintf( stdout, "fdiml          : %Lf\n", f1);

  f1 = floorl(0.5);
  fprintf( stdout, "floorl         : %Lf\n", f1);
  f1 = floorl(-0.5);
  fprintf( stdout, "floorl         : %Lf\n", f1);

  f1 = fmal(2.1, 2.2, 3.01);
  fprintf( stdout, "fmal           : %Lf\n", f1);

  f1 = fmaxl(-0.42, 0.42);
  fprintf( stdout, "fmaxl          : %Lf\n", f1);

  f1 = fminl(-0.42, 0.42);
  fprintf( stdout, "fminl          : %Lf\n", f1);

  f1 = fmodl(42.0, 3.0);
  fprintf( stdout, "fmodl          : %Lf\n", f1);

  /* no type-specific variant */
  i1 = fpclassify(1.0);
  fprintf( stdout, "fpclassify     : %d\n", i1);

  f1 = frexpl(42.0, &i1);
  fprintf( stdout, "frexpl         : %Lf\n", f1);

  f1 = hypotl(42.0, 42.0);
  fprintf( stdout, "hypotl         : %Lf\n", f1);

  i1 = ilogbl(42.0);
  fprintf( stdout, "ilogbl         : %d\n", i1);

  /* no type-specific variant */
  i1 = isfinite(3.0);
  fprintf( stdout, "isfinite       : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreater(3.0, 3.1);
  fprintf( stdout, "isgreater      : %d\n", i1);

  /* no type-specific variant */
  i1 = isgreaterequal(3.0, 3.1);
  fprintf( stdout, "isgreaterequal : %d\n", i1);

  /* no type-specific variant */
  i1 = isinf(3.0);
  fprintf( stdout, "isinf          : %d\n", i1);

  /* no type-specific variant */
  i1 = isless(3.0, 3.1);
  fprintf( stdout, "isless         : %d\n", i1);

  /* no type-specific variant */
  i1 = islessequal(3.0, 3.1);
  fprintf( stdout, "islessequal    : %d\n", i1);

  /* no type-specific variant */
  i1 = islessgreater(3.0, 3.1);
  fprintf( stdout, "islessgreater  : %d\n", i1);

  /* no type-specific variant */
  i1 = isnan(0.0);
  fprintf( stdout, "isnan          : %d\n", i1);

  /* no type-specific variant */
  i1 = isnormal(3.0);
  fprintf( stdout, "isnormal       : %d\n", i1);

  /* no type-specific variant */
  f1 = isunordered(1.0, 2.0);
  fprintf( stdout, "isunordered    : %d\n", i1);

  f1 = j0l(1.2);
  fprintf( stdout, "j0l            : %Lf\n", f1);

  f1 = j1l(1.2);
  fprintf( stdout, "j1l            : %Lf\n", f1);

  f1 = jnl(2,1.2);
  fprintf( stdout, "jnl            : %Lf\n", f1);

  f1 = ldexpl(1.2,3);
  fprintf( stdout, "ldexpl         : %Lf\n", f1);

  f1 = lgammal(42.0);
  fprintf( stdout, "lgammal        : %Lf\n", f1);

  f1 = llrintl(-0.5);
  fprintf( stdout, "llrintl        : %Lf\n", f1);
  f1 = llrintl(0.5);
  fprintf( stdout, "llrintl        : %Lf\n", f1);

  f1 = llroundl(-0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);
  f1 = llroundl(0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);

  f1 = logl(42.0);
  fprintf( stdout, "logl           : %Lf\n", f1);

  f1 = log10l(42.0);
  fprintf( stdout, "log10l         : %Lf\n", f1);

  f1 = log1pl(42.0);
  fprintf( stdout, "log1pl         : %Lf\n", f1);

  f1 = log2l(42.0);
  fprintf( stdout, "log2l          : %Lf\n", f1);

  f1 = logbl(42.0);
  fprintf( stdout, "logbl          : %Lf\n", f1);

  f1 = lrintl(-0.5);
  fprintf( stdout, "lrintl         : %Lf\n", f1);
  f1 = lrintl(0.5);
  fprintf( stdout, "lrintl         : %Lf\n", f1);

  f1 = lroundl(-0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);
  f1 = lroundl(0.5);
  fprintf( stdout, "lroundl        : %Lf\n", f1);

  f1 = modfl(42.0,&f2);
  fprintf( stdout, "lmodfl         : %Lf\n", f1);

  f1 = nanl("");
  fprintf( stdout, "nanl           : %Lf\n", f1);

  f1 = nearbyintl(1.5);
  fprintf( stdout, "nearbyintl     : %Lf\n", f1);

  f1 = nextafterl(1.5,2.0);
  fprintf( stdout, "nextafterl     : %Lf\n", f1);

  f1 = powl(3.01, 2.0);
  fprintf( stdout, "powl           : %Lf\n", f1);

  f1 = remainderl(3.01,2.0);
  fprintf( stdout, "remainderl     : %Lf\n", f1);

  f1 = remquol(29.0,3.0,&i1);
  fprintf( stdout, "remquol        : %Lf\n", f1);

  f1 = rintl(0.5);
  fprintf( stdout, "rintl          : %Lf\n", f1);
  f1 = rintl(-0.5);
  fprintf( stdout, "rintl          : %Lf\n", f1);

  f1 = roundl(0.5);
  fprintf( stdout, "roundl         : %Lf\n", f1);
  f1 = roundl(-0.5);
  fprintf( stdout, "roundl         : %Lf\n", f1);

  f1 = scalblnl(1.2,3);
  fprintf( stdout, "scalblnl       : %Lf\n", f1);

  f1 = scalbnl(1.2,3);
  fprintf( stdout, "scalbnl        : %Lf\n", f1);

  /* no type-specific variant */
  i1 = signbit(1.0);
  fprintf( stdout, "signbit        : %i\n", i1);

  f1 = sinl(M_PI_4);
  fprintf( stdout, "sinl           : %Lf\n", f1);

  f1 = sinhl(M_PI_4);
  fprintf( stdout, "sinhl          : %Lf\n", f1);

  f1 = sqrtl(9.0);
  fprintf( stdout, "sqrtl          : %Lf\n", f1);

  f1 = tanl(M_PI_4);
  fprintf( stdout, "tanl           : %Lf\n", f1);

  f1 = tanhl(M_PI_4);
  fprintf( stdout, "tanhl          : %Lf\n", f1);

  f1 = tgammal(2.1);
  fprintf( stdout, "tgammal        : %Lf\n", f1);

  f1 = truncl(3.5);
  fprintf( stdout, "truncl         : %Lf\n", f1);

  f1 = y0l(1.2);
  fprintf( stdout, "y0l            : %Lf\n", f1);

  f1 = y1l(1.2);
  fprintf( stdout, "y1l            : %Lf\n", f1);

  f1 = ynl(3,1.2);
  fprintf( stdout, "ynl            : %Lf\n", f1);
#endif
}
Example #12
0
int main(int argc, char *argv[])
{
  long double x = 0.0;
  if (argv) x = tanl((long double) argc);
  return 0;
}
Example #13
0
static long double
tanatanf(float x)
{

	return (tanl(atanf(x)));
}
Example #14
0
static long double
tanatanl(long double x)
{

	return (tanl(atanl(x)));
}
Example #15
0
/*
 * DCOT  - real(kind=16) - pass by value
 * 128-bit float cotangent
 */
_f_real16
_DCOT( _f_real16 x )
{
	return ( ((_f_real16) 1.0) / tanl(x) );
}
Example #16
0
sfloat math_tan(const sfloat val)
{
	return tanl(val);
}
Example #17
0
inline long double _tan(long double value) {
    return tanl(value);
}
Example #18
0
static int testl(long double long_double_x, int int_x, long long_x)
{
int r = 0;
r += __finitel(long_double_x);
r += __fpclassifyl(long_double_x);
r += __isinfl(long_double_x);
r += __isnanl(long_double_x);
r += __signbitl(long_double_x);
r += acoshl(long_double_x);
r += acosl(long_double_x);
r += asinhl(long_double_x);
r += asinl(long_double_x);
r += atan2l(long_double_x, long_double_x);
r += atanhl(long_double_x);
r += atanl(long_double_x);
r += cbrtl(long_double_x);
r += ceill(long_double_x);
r += copysignl(long_double_x, long_double_x);
r += coshl(long_double_x);
r += cosl(long_double_x);
r += erfcl(long_double_x);
r += erfl(long_double_x);
r += exp2l(long_double_x);
r += expl(long_double_x);
r += expm1l(long_double_x);
r += fabsl(long_double_x);
r += fdiml(long_double_x, long_double_x);
r += floorl(long_double_x);
r += fmal(long_double_x, long_double_x, long_double_x);
r += fmaxl(long_double_x, long_double_x);
r += fminl(long_double_x, long_double_x);
r += fmodl(long_double_x, long_double_x);
r += frexpl(long_double_x, &int_x);
r += hypotl(long_double_x, long_double_x);
r += ilogbl(long_double_x);
r += ldexpl(long_double_x, int_x);
r += lgammal(long_double_x);
r += llrintl(long_double_x);
r += llroundl(long_double_x);
r += log10l(long_double_x);
r += log1pl(long_double_x);
r += log2l(long_double_x);
r += logbl(long_double_x);
r += logl(long_double_x);
r += lrintl(long_double_x);
r += lroundl(long_double_x);
r += modfl(long_double_x, &long_double_x);
r += nearbyintl(long_double_x);
r += nextafterl(long_double_x, long_double_x);
r += nexttowardl(long_double_x, long_double_x);
r += powl(long_double_x, long_double_x);
r += remainderl(long_double_x, long_double_x);
r += remquol(long_double_x, long_double_x, &int_x);
r += rintl(long_double_x);
r += roundl(long_double_x);
r += scalblnl(long_double_x, long_x);
r += scalbnl(long_double_x, int_x);
r += sinhl(long_double_x);
r += sinl(long_double_x);
r += sqrtl(long_double_x);
r += tanhl(long_double_x);
r += tanl(long_double_x);
r += tgammal(long_double_x);
r += truncl(long_double_x);
return r;
}
Example #19
0
/*
 * Tests to ensure argument reduction for large arguments is accurate.
 */
static void
run_reduction_tests(void)
{
	/* floats very close to odd multiples of pi */
	static const float f_pi_odd[] = {
		85563208.0f,
		43998769152.0f,
		9.2763667655669323e+25f,
		1.5458357838905804e+29f,
	};
	/* doubles very close to odd multiples of pi */
	static const double d_pi_odd[] = {
		3.1415926535897931,
		91.106186954104004,
		642615.9188844458,
		3397346.5699258847,
		6134899525417045.0,
		3.0213551960457761e+43,
		1.2646209897993783e+295,
		6.2083625380677099e+307,
	};
	/* long doubles very close to odd multiples of pi */
#if LDBL_MANT_DIG == 64
	static const long double ld_pi_odd[] = {
		1.1891886960373841596e+101L,
		1.07999475322710967206e+2087L,
		6.522151627890431836e+2147L,
		8.9368974898260328229e+2484L,
		9.2961044110572205863e+2555L,
		4.90208421886578286e+3189L,
		1.5275546401232615884e+3317L,
		1.7227465626338900093e+3565L,
		2.4160090594000745334e+3808L,
		9.8477555741888350649e+4314L,
		1.6061597222105160737e+4326L,
	};
#elif LDBL_MANT_DIG == 113
	static const long double ld_pi_odd[] = {
		/* XXX */
	};
#endif

	int i;

	for (i = 0; i < nitems(f_pi_odd); i++) {
		assert(fabs(sinf(f_pi_odd[i])) < FLT_EPSILON);
		assert(cosf(f_pi_odd[i]) == -1.0);
		assert(fabs(tan(f_pi_odd[i])) < FLT_EPSILON);

		assert(fabs(sinf(-f_pi_odd[i])) < FLT_EPSILON);
		assert(cosf(-f_pi_odd[i]) == -1.0);
		assert(fabs(tanf(-f_pi_odd[i])) < FLT_EPSILON);

		assert(fabs(sinf(f_pi_odd[i] * 2)) < FLT_EPSILON);
		assert(cosf(f_pi_odd[i] * 2) == 1.0);
		assert(fabs(tanf(f_pi_odd[i] * 2)) < FLT_EPSILON);

		assert(fabs(sinf(-f_pi_odd[i] * 2)) < FLT_EPSILON);
		assert(cosf(-f_pi_odd[i] * 2) == 1.0);
		assert(fabs(tanf(-f_pi_odd[i] * 2)) < FLT_EPSILON);
	}

	for (i = 0; i < nitems(d_pi_odd); i++) {
		assert(fabs(sin(d_pi_odd[i])) < 2 * DBL_EPSILON);
		assert(cos(d_pi_odd[i]) == -1.0);
		assert(fabs(tan(d_pi_odd[i])) < 2 * DBL_EPSILON);

		assert(fabs(sin(-d_pi_odd[i])) < 2 * DBL_EPSILON);
		assert(cos(-d_pi_odd[i]) == -1.0);
		assert(fabs(tan(-d_pi_odd[i])) < 2 * DBL_EPSILON);

		assert(fabs(sin(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
		assert(cos(d_pi_odd[i] * 2) == 1.0);
		assert(fabs(tan(d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);

		assert(fabs(sin(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
		assert(cos(-d_pi_odd[i] * 2) == 1.0);
		assert(fabs(tan(-d_pi_odd[i] * 2)) < 2 * DBL_EPSILON);
	}

#if LDBL_MANT_DIG > 53
	for (i = 0; i < nitems(ld_pi_odd); i++) {
		assert(fabsl(sinl(ld_pi_odd[i])) < LDBL_EPSILON);
		assert(cosl(ld_pi_odd[i]) == -1.0);
		assert(fabsl(tanl(ld_pi_odd[i])) < LDBL_EPSILON);

		assert(fabsl(sinl(-ld_pi_odd[i])) < LDBL_EPSILON);
		assert(cosl(-ld_pi_odd[i]) == -1.0);
		assert(fabsl(tanl(-ld_pi_odd[i])) < LDBL_EPSILON);

		assert(fabsl(sinl(ld_pi_odd[i] * 2)) < LDBL_EPSILON);
		assert(cosl(ld_pi_odd[i] * 2) == 1.0);
		assert(fabsl(tanl(ld_pi_odd[i] * 2)) < LDBL_EPSILON);

		assert(fabsl(sinl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON);
		assert(cosl(-ld_pi_odd[i] * 2) == 1.0);
		assert(fabsl(tanl(-ld_pi_odd[i] * 2)) < LDBL_EPSILON);
	}
#endif
}
Example #20
0
 inline long double MathTrait<long double>::tan( const long double val )
 {
   return tanl( val ) ;
 }
Example #21
0
/*
 * DTAN: TAN of real(kind=16) - pass by value
 * 128-bit float tangent
 */
_f_real16
_DTAN( _f_real16 x )
{
	return ( (_f_real16) tanl((_f_real16) x));
}
Example #22
0
TEST(math, tanl) {
  ASSERT_FLOAT_EQ(0.0, tanl(0.0));
}
Example #23
0
TEST(math, tanl) {
  ASSERT_DOUBLE_EQ(0.0L, tanl(0.0L));
}
Example #24
0
// p3b
long double f3b(long double x){
	return (x-1)*tanl(x) + x* sinl(M_PI*x);
}
Example #25
0
// the function we are using to search
long double fex4(long double x){
	return x -tanl(x);
}
void test2l(long double x, long double y)
{
  if (-tanl(x-y) != tanl(y-x))
    link_error ();

  if (-sinl(x-y) != sinl(y-x))
    link_error ();

  if (cosl(-x*y) != cosl(x*y))
    link_error ();

  if (cosl(x*-y) != cosl(x*y))
    link_error ();

  if (cosl(-x/y) != cosl(x/y))
    link_error ();

  if (cosl(x/-y) != cosl(x/y))
    link_error ();

  if (cosl(-fabsl(tanl(x/-y))) != cosl(tanl(x/y)))
    link_error ();

  if (cosl(y<10 ? -x : y) != cosl(y<10 ? x : y))
    link_error ();

  if (cosl(y<10 ? x : -y) != cosl(y<10 ? x : y))
    link_error ();

  if (cosl(y<10 ? -fabsl(x) : tanl(x<20 ? -x : -fabsl(y)))
      != cosl(y<10 ? x : tanl(x<20 ? x : y)))
    link_error ();

  if (cosl((y*=3, -x)) != cosl((y*=3,x)))
    link_error ();

  if (cosl((y*=2, -fabsl(tanl(x/-y)))) != cosl((y*=2,tanl(x/y))))
    link_error ();

  if (cosl(copysignl(x,y)) != cosl(x))
    link_error ();

  if (cosl(copysignl(-fabsl(x),y*=2)) != cosl((y*=2,x)))
    link_error ();

  if (hypotl (x, 0) != fabsl(x))
    link_error ();

  if (hypotl (0, x) != fabsl(x))
    link_error ();

  if (hypotl (x, x) != fabsl(x) * __builtin_sqrtl(2))
    link_error ();

  if (hypotl (-x, y) != hypotl (x, y))
    link_error ();

  if (hypotl (x, -y) != hypotl (x, y))
    link_error ();

  if (hypotl (-x, -y) != hypotl (x, y))
    link_error ();

  if (hypotl (fabsl(x), y) != hypotl (x, y))
    link_error ();

  if (hypotl (x, fabsl(y)) != hypotl (x, y))
    link_error ();

  if (hypotl (fabsl(x), fabsl(y)) != hypotl (x, y))
    link_error ();

  if (hypotl (-fabsl(-x), -fabsl(fabsl(fabsl(-y)))) != hypotl (x, y))
    link_error ();

  if (hypotl (-x, 0) != fabsl(x))
    link_error ();

  if (hypotl (-x, x) != fabsl(x) * __builtin_sqrtl(2))
    link_error ();

  if (hypotl (purel(x), -purel(x)) != fabsl(purel(x)) * __builtin_sqrtl(2))
    link_error ();

  if (hypotl (tanl(-x), tanl(-fabsl(y))) != hypotl (tanl(x), tanl(y)))
    link_error ();

  if (fminl (fmaxl(x,y),y) != y)
    link_error ();

  if (fminl (fmaxl(y,x),y) != y)
    link_error ();

  if (fminl (x,fmaxl(x,y)) != x)
    link_error ();
  
  if (fminl (x,fmaxl(y,x)) != x)
    link_error ();
  
  if (fmaxl (fminl(x,y),y) != y)
    link_error ();

  if (fmaxl (fminl(y,x),y) != y)
    link_error ();

  if (fmaxl (x,fminl(x,y)) != x)
    link_error ();
  
  if (fmaxl (x,fminl(y,x)) != x)
    link_error ();

  if ((__complex__ long double) x != -(__complex__ long double) (-x))
    link_error ();

  if (x+(x-y)*1i != -(-x+(y-x)*1i))
    link_error ();

  if (x+(x-y)*1i != -(-x-(x-y)*1i))
    link_error ();

  if (ccosl(tanl(x)+sinl(y)*1i) != ccosl(-tanl(-x)+-sinl(-y)*1i))
    link_error ();

  if (ccosl(tanl(x)+sinl(x-y)*1i) != ccosl(-tanl(-x)-sinl(y-x)*1i))
    link_error ();

  if (-5+x*1i != -~(5+x*1i))
    link_error ();

  if (tanl(x)+tanl(y)*1i != -~(tanl(-x)+tanl(y)*1i))
    link_error ();
}
Example #27
0
npy_longdouble npy_tanl(npy_longdouble x)
{
    return tanl(x);
}
Example #28
0
void test (float f, double d, long double ld)
{
  if (sqrt (0.0) != 0.0)
    link_error ();

  if (sqrt (1.0) != 1.0)
    link_error ();

  if (cbrt (0.0) != 0.0)
    link_error ();

  if (cbrt (1.0) != 1.0)
    link_error ();

  if (cbrt (-1.0) != -1.0)
    link_error ();

  if (exp (0.0) != 1.0)
    link_error ();

  if (exp (1.0) <= 2.71 || exp (1.0) >= 2.72)
    link_error ();

  if (log (1.0) != 0.0)
    link_error ();

  if (sin (0.0) != 0.0)
    link_error ();

  if (cos (0.0) != 1.0)
    link_error ();

  if (tan (0.0) != 0.0)
    link_error ();

  if (atan (0.0) != 0.0)
    link_error ();

  if (4.0*atan (1.0) <= 3.14 || 4.0*atan (1.0) >= 3.15)
    link_error ();

  if (pow (d, 0.0) != 1.0)
    link_error ();

  if (pow (1.0, d) != 1.0)
    link_error ();


  if (sqrtf (0.0F) != 0.0F)
    link_error ();

  if (sqrtf (1.0F) != 1.0F)
    link_error ();

  if (cbrtf (0.0F) != 0.0F)
    link_error ();

  if (cbrtf (1.0F) != 1.0F)
    link_error ();

  if (cbrtf (-1.0F) != -1.0F)
    link_error ();

  if (expf (0.0F) != 1.0F)
    link_error ();

  if (expf (1.0F) <= 2.71F || expf (1.0F) >= 2.72F)
    link_error ();

  if (logf (1.0F) != 0.0F)
    link_error ();

  if (sinf (0.0F) != 0.0F)
    link_error ();

  if (cosf (0.0F) != 1.0F)
    link_error ();

  if (tanf (0.0F) != 0.0F)
    link_error ();

  if (atanf (0.0F) != 0.0F)
    link_error ();

  if (4.0F*atanf (1.0F) <= 3.14F || 4.0F*atanf (1.0F) >= 3.15F)
    link_error ();

  if (powf (f, 0.0F) != 1.0F)
    link_error ();

  if (powf (1.0F, f) != 1.0F)
    link_error ();


  if (sqrtl (0.0L) != 0.0L)
    link_error ();

  if (sqrtl (1.0L) != 1.0L)
    link_error ();

  if (cbrtl (0.0L) != 0.0L)
    link_error ();

  if (cbrtl (1.0L) != 1.0L)
    link_error ();

  if (cbrtl (-1.0L) != -1.0L)
    link_error ();

  if (expl (0.0L) != 1.0L)
    link_error ();

  if (expl (1.0L) <= 2.71L || expl (1.0L) >= 2.72L)
    link_error ();

  if (logl (1.0L) != 0.0L)
    link_error ();

  if (sinl (0.0L) != 0.0L)
    link_error ();

  if (cosl (0.0L) != 1.0L)
    link_error ();

  if (tanl (0.0L) != 0.0L)
    link_error ();

  if (atanl (0.0) != 0.0L)
    link_error ();

  if (4.0L*atanl (1.0L) <= 3.14L || 4.0L*atanl (1.0L) >= 3.15L)
    link_error ();

  if (powl (ld, 0.0L) != 1.0L)
    link_error ();

  if (powl (1.0L, ld) != 1.0L)
    link_error ();
}
Example #29
0
/*
 * DTAN: TAN of real(kind=16) - pass by address
 * 128-bit float tangent
 */
_f_real16
_DTAN_( _f_real16 *x )
{
	_f_real16 tanl(_f_real16 x);
	return ( (_f_real16) tanl((_f_real16) *x));
}