// Vector atanh inline GVector atanh(const GVector &v) { GVector result(v.m_num); for (int i = 0; i < v.m_num; ++i) result.m_data[i] = atanh(v.m_data[i]); return result; }
/* {{{ php_atanh */ static double php_atanh(double z) { #ifdef HAVE_ATANH return(atanh(z)); #else return(0.5 * log((1 + z) / (1 - z))); #endif }
/* * delta_Z0_cover() - compute the cover effect on impedance for a * stripline in a homogeneous medium */ double microstrip::delta_Z0_cover(double u, double h2h) { double P, Q; double h2hp1; h2hp1 = 1.0 + h2h; P = 270.0 * (1.0 - tanh(1.192 + 0.706 * sqrt(h2hp1) - 1.389 / h2hp1)); Q = 1.0109 - atanh((0.012 * u + 0.177 * u * u - 0.027 * u * u * u) / (h2hp1 * h2hp1)); return (P * Q); }
double nie_alphas(double x1,double x2,double re0,double rcore,double qe) { double res0; res0 = re0/sqrt(1-qe*qe); double al1,al2; al1 = atan(x1*sqrt(1-qe*qe)/(hfunc(x1,x2,rcore,qe)+rcore)); al2 = atanh(x2*sqrt(1-qe*qe)/(hfunc(x1,x2,rcore,qe)+rcore*qe*qe)); return res0*al1*res0*al2; }
bool TileProjection::Set(size_t tileX, size_t tileY, const Magnification& magnification, double dpi, size_t width, size_t height) { if (valid && this->tileX==tileY && this->tileY==tileY && this->magnification==magnification && this->dpi==dpi && this->width==width && this->height==height) { return true; } valid=true; // Make a copy of the context information this->tileX=tileX; this->tileY=tileY; this->magnification=magnification; this->dpi=dpi; this->width=width; this->height=height; latMin=TileYToLat(tileY+1, magnification); latMax=TileYToLat(tileY, magnification); lonMin=TileXToLon(tileX, magnification); lonMax=TileXToLon(tileX+1, magnification); lat=(latMin+latMax)/2; lon=(lonMin+lonMax)/2; scale=width/(gradtorad*(lonMax-lonMin)); scaleGradtorad = scale * gradtorad; lonOffset=lonMin*scaleGradtorad; latOffset=scale*atanh(sin(latMin*gradtorad)); pixelSize=earthExtent/magnification.GetMagnification()/256; #ifdef OSMSCOUT_HAVE_SSE2 sse2LonOffset = _mm_set1_pd(lonOffset); sse2LatOffset = _mm_set1_pd(latOffset); sse2Scale = _mm_set1_pd(scale); sse2ScaleGradtorad = _mm_set1_pd(scaleGradtorad); sse2Height = _mm_set1_pd(height); #endif return true; }
bool TileProjection::GeoToPixel(const GeoCoord& coord, double& x, double& y) const { assert(valid); x=coord.GetLon()*scaleGradtorad-lonOffset; y=height-(scale*atanh(sin(coord.GetLat()*gradtorad))-latOffset); return true; }
bool TileProjection::GeoToPixel(double lon, double lat, double& x, double& y) const { assert(valid); x=lon*scaleGradtorad-lonOffset; y=height-(scale*atanh(sin(lat*gradtorad))-latOffset); return true; }
/* * call-seq: * Math.atanh(x) -> float * * Computes the inverse hyperbolic tangent of <i>x</i>. */ static mrb_value math_atanh(mrb_state *mrb, mrb_value obj) { mrb_float x; mrb_get_args(mrb, "f", &x); x = atanh(x); return mrb_float_value(mrb, x); }
void geographic_to_tm_sphere(double R, double k0, double lon_mer, double FN, double FE, double lat_rad, double lon_rad, double* N, double* E) { double Rk0 = R*k0; double B = cos(lat_rad) * sin(lon_rad - lon_mer); *E = FE + Rk0*atanh(B); *N = FN + Rk0*atan(tan(lat_rad)/cos(lon_rad - lon_mer)); }
void CppShear::getEta1Eta2(double& eta1, double& eta2) const { double scale; // get ratio of eta amplitude to e amplitude: scale = std::sqrt(e1*e1 + e2*e2); if (scale>0.001) scale = atanh(scale)/scale; else scale=1.; eta1 = e1*scale; eta2 = e2*scale; }
int main () { double param= tanh( 1 ); double result; result = atanh(param) ; printf ( "The arc hyperbolic tangent of %f is %f radians.\n", param, result ); return 0; }
Matrix atanh(Matrix M1) { Matrix ret = M1; for( int i = 0; i < M1.getRows(); i++) for( int j = 0; j < M1.getCols(); j++) ret.add(i+1, j+1, atanh(M1.getMat(i+1,j+1))); return ret; }
Real MR::T(size_t i, sub_nb A) { sub_nb _nbi_min_A(G.nb(i).size()); _nbi_min_A.set(); _nbi_min_A &= ~A; Real res = theta[i]; for( size_t _j = 0; _j < _nbi_min_A.size(); _j++ ) if( _nbi_min_A.test(_j) ) res += atanh(tJ[i][_j] * M[i][_j]); return tanh(res); }
float atanhf(float x) { int ix; ix = *((int *)&x) & ~0x80000000; if (ix > 0x3f800000) /* |x| > 1 or x is nan */ return ((x * zero) / zero); if (ix == 0x3f800000) /* |x| == 1 */ return (x / zero); return ((float)atanh((double)x)); }
QPoint OSMARenderMapSource::displayFromCooordinate(const QPointF &coordinate, int zoom) { int tiles_size = (1 << zoom) * tileSize(); qreal lat_r = atanh(sin(deg2rad(coordinate.y()))); qreal lon_r = deg2rad(coordinate.x()); int x = lon_r * tiles_size / (2 * M_PI) + tiles_size / 2; int y = -lat_r * tiles_size / (2 * M_PI) + tiles_size / 2; return QPoint(x, y); }
static VALUE math_atanh(VALUE obj, VALUE x) { double d0, d; Need_Float(x); errno = 0; d0 = RFLOAT_VALUE(x); d = atanh(d0); domain_check(d0, d, "atanh"); infinity_check(x, d, "atanh"); return DBL2NUM(d); }
void Foam::equationReader::evalScalarFieldAtanh ( const equationReader * eqnReader, const label index, const label i, const label storageOffset, label& storeIndex, scalarField& x, const scalarField& source ) const { atanh(x, x); }
/***********************************************************************//** * @brief Computes atanh of vector elements * * @param[in] vector Vector. * @return Vector containing the atanh of every element. ***************************************************************************/ GVector atanh(const GVector& vector) { // Initialise result vector GVector result(vector.m_num); // Evaluate each vector element for (int i = 0; i < vector.m_num; ++i) { result.m_data[i] = atanh(vector.m_data[i]); } // Return vector return result; }
// This is the Miralda-Escude formula for adding distortions. // We convert to/from distortion to use their formula. std::complex<double> addShears( const std::complex<double> g1, const std::complex<double> g2) { double absg1 = std::abs(g1); if (absg1 == 0.) return g2; double absd1 = tanh(atanh(absg1)*2.); std::complex<double> d1 = absd1 / absg1 * g1; double absg2 = std::abs(g2); if (absg2 == 0.) return g1; double absd2 = tanh(atanh(absg2)*2.); std::complex<double> d2 = absd2 / absg2 * g2; double d2sq = absd2*absd2; double x = (1.-std::sqrt(1.-d2sq))/d2sq; std::complex<double> d3 = d1+d2*(1.+x*(std::real(d1)*d2-std::real(d2)*d1)); d3 /= 1. + std::real(d1*std::conj(d2)); double absd3 = std::abs(d3); double absg3 = tanh(atanh(absd3)/2.); std::complex<double> g3 = absg3/absd3*d3; //xdbg<<"GammaAdd: "<<g1<<" + "<<g2<<" = "<<g3<<std::endl; return g3; }
static VALUE math_atanh(VALUE unused_obj, VALUE x) { double d; d = Get_Double(x); /* check for domain error */ if (d < -1.0 || +1.0 < d) domain_error("atanh"); /* check for pole error */ if (d == -1.0) return DBL2NUM(-HUGE_VAL); if (d == +1.0) return DBL2NUM(+HUGE_VAL); return DBL2NUM(atanh(d)); }
/* * call-seq: * Math.atanh(x) -> float * * Computes the inverse hyperbolic tangent of <i>x</i>. */ static mrb_value math_atanh(mrb_state *mrb, mrb_value obj) { mrb_float x; mrb_get_args(mrb, "f", &x); if (x < -1.0 || x > 1.0) { domain_error(mrb, "atanh"); } x = atanh(x); return mrb_float_value(mrb, x); }
static ex atanh_eval(const ex & x) { if (x.info(info_flags::numeric)) { // atanh(0) -> 0 if (x.is_zero()) return _ex0; // atanh({+|-}1) -> throw if (x.is_equal(_ex1) || x.is_equal(_ex_1)) throw (pole_error("atanh_eval(): logarithmic pole",0)); // atanh(float) -> float if (!x.info(info_flags::crational)) return atanh(ex_to<numeric>(x)); // atanh() is odd if (x.info(info_flags::negative)) return -atanh(-x); } return atanh(x).hold(); }
/* Tests along the real and imaginary axes. */ void test_axes(void) { static const long double nums[] = { -2, -1, -0.5, 0.5, 1, 2 }; long double complex z; int i; for (i = 0; i < sizeof(nums) / sizeof(nums[0]); i++) { /* Real axis */ z = CMPLXL(nums[i], 0.0); if (fabs(nums[i]) <= 1) { testall_tol(cacosh, z, CMPLXL(0.0, acos(nums[i])), 1); testall_tol(cacos, z, CMPLXL(acosl(nums[i]), -0.0), 1); testall_tol(casin, z, CMPLXL(asinl(nums[i]), 0.0), 1); testall_tol(catanh, z, CMPLXL(atanh(nums[i]), 0.0), 1); } else { testall_tol(cacosh, z, CMPLXL(acosh(fabs(nums[i])), (nums[i] < 0) ? pi : 0), 1); testall_tol(cacos, z, CMPLXL((nums[i] < 0) ? pi : 0, -acosh(fabs(nums[i]))), 1); testall_tol(casin, z, CMPLXL(copysign(pi / 2, nums[i]), acosh(fabs(nums[i]))), 1); testall_tol(catanh, z, CMPLXL(atanh(1 / nums[i]), pi / 2), 1); } testall_tol(casinh, z, CMPLXL(asinh(nums[i]), 0.0), 1); testall_tol(catan, z, CMPLXL(atan(nums[i]), 0), 1); /* TODO: Test the imaginary axis. */ } }
static VALUE math_atanh(VALUE obj, VALUE x) { double d0, d; Need_Float(x); d0 = RFLOAT_VALUE(x); /* check for domain error */ if (d0 < -1.0 || +1.0 < d0) domain_error("atanh"); /* check for pole error */ if (d0 == -1.0) return DBL2NUM(-INFINITY); if (d0 == +1.0) return DBL2NUM(+INFINITY); d = atanh(d0); return DBL2NUM(d); }
double t_to_e_AstronomyAnswers(double nu) { double e = 2.0; if (e < 1.0) { return 2.0 * atan(tan(nu / 2.0) / sqrt((1.0 + e) / (1.0 - e))); } else if (e == 1.0) { return 0; } else { return 2.0 * atanh(tan(nu / 2.0) / sqrt((e + 1.0) / (e - 1.0))); } }
void incomkin(double m1, double m2, double p1, double p2, double *sqrt_S_, double *Pcm_, double * rapidity_) { double sqrt_S, Pcm,rapidity; double e1=sqrt(m1*m1+p1*p1); double e2=sqrt(m2*m2+p2*p2); sqrt_S=(e1+e2)*(e1+e2)-(p1-p2)*(p1-p2); rapidity= atanh((p1-p2)/(e1+e2)); Pcm=p1*cosh(rapidity)-e1*sinh(rapidity); if(sqrt_S_) *sqrt_S_=sqrt(sqrt_S); if(Pcm_) *Pcm_=Pcm; if(rapidity_) *rapidity_=rapidity; }
int lat2pixel( float zoom, float lat) { float lat_m; int pixel_y; lat_m = atanh(sin(lat)); pixel_y = -( (lat_m * TILESIZE * exp(zoom * M_LN2) ) / (2*M_PI)) + (exp(zoom * M_LN2) * (TILESIZE/2) ); return pixel_y; }
PredStats compute_stats(const vec& obs, const vec& pred) { size_t num_pred = 0; double sum_errors = 0; double sum_squared_errors = 0; double sum_obs = 0; double sum_pred = 0; double sum_squared_obs = 0; double sum_squared_pred = 0; double sum_prod = 0; size_t same_sign = 0; size_t num_vectors = obs.size(); if(pred.size() < num_vectors) num_vectors = pred.size(); for(size_t k = 0; k < num_vectors; ++k) { if(!std::isnan(obs[k]) && !std::isnan(pred[k])) { ++ num_pred; sum_errors += fabs(obs[k] - pred[k]); sum_squared_errors += (obs[k] - pred[k]) * (obs[k] - pred[k]); sum_obs += obs[k]; sum_pred += pred[k]; sum_squared_obs += obs[k] * obs[k]; sum_squared_pred += pred[k] * pred[k]; sum_prod += obs[k] * pred[k]; if((obs[k] >= 0 && pred[k] >= 0) || (obs[k] <= 0 && pred[k] <= 0)) ++ same_sign; } } PredStats output; output.num_pred = num_pred; output.rho = (sum_prod * num_pred - sum_obs * sum_pred) / sqrt((sum_squared_obs * num_pred - sum_obs * sum_obs) * (sum_squared_pred * num_pred - sum_pred * sum_pred)); output.mae = sum_errors / double(num_pred); output.rmse = sqrt(sum_squared_errors / double(num_pred)); output.perc = double(same_sign) / double(num_pred); output.p_val = R::pnorm(atanh(output.rho), 0.0, 1.0 / sqrt(double(output.num_pred-3)), 0.0, 0.0); return output; }
static ex atanh_series(const ex &arg, const relational &rel, int order, unsigned options) { GINAC_ASSERT(is_a<symbol>(rel.lhs())); // method: // Taylor series where there is no pole or cut falls back to atanh_deriv. // There are two branch cuts, one runnig from 1 up the real axis and one // one running from -1 down the real axis. The points 1 and -1 are poles // On the branch cuts and the poles series expand // (log(1+x)-log(1-x))/2 // instead. const ex arg_pt = arg.subs(rel, subs_options::no_pattern); if (!(arg_pt).info(info_flags::real)) throw do_taylor(); // Im(x) != 0 if ((arg_pt).info(info_flags::real) && abs(arg_pt)<_ex1) throw do_taylor(); // Im(x) == 0, but abs(x)<1 // care for the poles, using the defining formula for atanh()... if (arg_pt.is_equal(_ex1) || arg_pt.is_equal(_ex_1)) return ((log(_ex1+arg)-log(_ex1-arg))*_ex1_2).series(rel, order, options); // ...and the branch cuts (the discontinuity at the cut being just I*Pi) if (!(options & series_options::suppress_branchcut)) { // method: // This is the branch cut: assemble the primitive series manually and // then add the corresponding complex step function. const symbol &s = ex_to<symbol>(rel.lhs()); const ex &point = rel.rhs(); const symbol foo; const ex replarg = series(atanh(arg), s==foo, order).subs(foo==point, subs_options::no_pattern); ex Order0correction = replarg.op(0)+csgn(I*arg)*Pi*I*_ex1_2; if (arg_pt<_ex0) Order0correction += log((arg_pt+_ex_1)/(arg_pt+_ex1))*_ex1_2; else Order0correction += log((arg_pt+_ex1)/(arg_pt+_ex_1))*_ex_1_2; epvector seq; if (order > 0) { seq.reserve(2); seq.push_back(expair(Order0correction, _ex0)); } seq.push_back(expair(Order(_ex1), order)); return series(replarg - pseries(rel, std::move(seq)), rel, order); } throw do_taylor(); }
inline void forward_atanh_op_0( size_t i_z , size_t i_x , size_t cap_order , Base* taylor ) { // check assumptions CPPAD_ASSERT_UNKNOWN( NumArg(AtanhOp) == 1 ); CPPAD_ASSERT_UNKNOWN( NumRes(AtanhOp) == 2 ); CPPAD_ASSERT_UNKNOWN( 0 < cap_order ); // Taylor coefficients corresponding to argument and result Base* x = taylor + i_x * cap_order; Base* z = taylor + i_z * cap_order; Base* b = z - cap_order; // called y in documentation z[0] = atanh( x[0] ); b[0] = Base(1) - x[0] * x[0]; }