def testHyperbolic(self): self.assertEqual(math.sinh(5), hyperbolic.sineh_op(5)) self.assertEqual(math.cosh(5), hyperbolic.cosineh_op(5)) self.assertEqual(math.tanh(5), hyperbolic.tangenth_op(5)) self.assertEqual(1. / math.sinh(5), hyperbolic.cosecanth_op(5)) self.assertEqual(1. / math.cosh(5), hyperbolic.secanth_op(5)) self.assertEqual(1. / math.tanh(5), hyperbolic.cotangenth_op(5))
def heisenT(beta): # Following notation of Xiang (http://arxiv.org/pdf/1201.1144v4.pdf) W=np.array([[math.sqrt(math.cosh(beta)), math.sqrt(math.sinh(beta))], [math.sqrt(math.cosh(beta)), -math.sqrt(math.sinh(beta))]]) #T=np.einsum("au,ad,al,ar->udlr",W,W,W,W) T=np.einsum("al,ar->lr",W,W) return T
def sinh(x): """ Return the hyperbolic sine of x. """ if math.isinf(x.real) or math.isinf(x.imag): # need to raise DomainError if y is +/- infinity and x is not # a NaN and not -infinity if math.isinf(x.imag) and not math.isnan(x.real): raise ValueError("math domain error") if math.isinf(x.real) and -_INF < x.imag < _INF and x.imag != .0: if x.real > 0: _real = math.copysign(_INF, cos(x.imag)) _imag = math.copysign(_INF, sin(x.imag)) else: _real = -math.copysign(_INF, cos(x.imag)) _imag = math.copysign(_INF, sin(x.imag)) return complex(_real, _imag) return _SPECIAL_VALUE(x,_sinh_special_values) if math.fabs(x.real) > _CM_LOG_LARGE_DOUBLE: x_minus_one = x.real - math.copysign(1.0, x.real) _real = math.cos(x.imag)*math.sinh(x.imag)*math.e _imag = math.sin(x.imag)*math.cosh(x.imag)*math.e else: _real = math.cos(x.imag)*math.sinh(x.real) _imag = math.sin(x.imag)*math.cosh(x.real) if math.isinf(_real) or math.isinf(_imag): raise OverflowError() return complex(_real, _imag)
def cosh(x): """Return the hyperbolic cosine of x.""" # special treatment for cosh(+/-inf + iy) if y is not a NaN if isinf(x): if -_INF < x.imag < _INF and x.imag != .0: if x.real > 0: _real = math.copysign(_INF, math.cos(x.imag)) _imag = math.copysign(_INF, math.sin(x.imag)) else: _real = math.copysign(_INF, math.cos(x.imag)) _imag = -math.copysign(_INF, math.sin(x.imag)) return complex(_real,_imag) else: # need to raise math domain error if y is +/- infinity and x is not a NaN if x.imag != .0 and not math.isnan(x.real): raise ValueError("math domain error") return _SPECIAL_VALUE(x,_cosh_special_values) if math.fabs(x.real) > _CM_LOG_LARGE_DOUBLE: # deal correctly with cases where cosh(x.real) overflows but # cosh(z) does not. x_minus_one = x.real - math.copysign(1.0, x.real) _real = cos(x.imag) * math.cosh(x_minus_one) * math.e _imag = sin(x.imag) * math.sinh(x_minus_one) * math.e else: _real = math.cos(x.imag) * math.cosh(x.real) _imag = math.sin(x.imag) * math.sinh(x.real) ret = complex(_real, _imag) # detect overflow if isinf(ret): raise OverflowError() return ret
def laplace_Dirichlet_analytic(Ttop, x, y): """ Function that calculates the analytic solution to the laplace heat equation d^2(T)/dx^2 + d^2(T)/dy^2 = 0 with Dirichlet boundary conditions: T(x, 0) = 0 T(0, y) = 0 y<1.5 T(1, y) = 0 y<1.5 T(x, 1.5) = Ttop on a square grid with xmax = 1 and ymax= 1 Args: Ttop(float): Temperature at top, T(x, 1.5) x(float): x-coordinate y(float): y-coordinate Returns: T(float): Temperature at T(x, y) """ sum = 0 for n in range(1,50, 1): lambdan = pi*n An = 2*((-1)**(n+1)+1)/(lambdan*sinh(1.5*lambdan)) term = An*sinh(lambdan*y )*sin(lambdan*x) sum += term return Ttop*sum
def to_wgs84(x, y, twd67=False): ''' The formula is based on "https://en.wikipedia.org/wiki/Universal_Transverse_Mercator_coordinate_system" ''' if twd67: x, y = twd67_to_twd97(x, y) x /= 1000.0 # m to km y /= 1000.0 # m to km xi = (y - N0) / (k0 * A) eta = (x - E0) / (k0 * A) xip = (xi - b1 * math.sin(2 * xi) * math.cosh(2 * eta) - b2 * math.sin(4 * xi) * math.cosh(4 * eta) - b3 * math.sin(6 * xi) * math.cosh(6 * eta)) etap = (eta - b1 * math.cos(2 * xi) * math.sinh(2 * eta) - b2 * math.cos(4 * xi) * math.sinh(4 * eta) - b3 * math.cos(6 * xi) * math.sinh(6 * eta)) chi = math.asin(math.sin(xip) / math.cosh(etap)) lat = math.degrees( chi + d1 * math.sin(2 * chi) + d2 * math.sin(4 * chi) + d3 * math.sin(6 * chi)) lon = lon0 + math.degrees( math.atan(math.sinh(etap) / math.cos(xip))) return (lat, lon)
def pmuboost3d(jets, met, lep): mw = 80.385 wwwtlv = ROOT.TLorentzVector(1e-9,1e-9,1e-9,1e-9) mettlv = ROOT.TLorentzVector(1e-9,1e-9,1e-9,1e-9) leptlv = ROOT.TLorentzVector(1e-9,1e-9,1e-9,1e-9) for jet in jets: # if(e.jetPt[ij] > 30.): tlvaux = ROOT.TLorentzVector(1e-9,1e-9,1e-9,1e-9) tlvaux.SetPtEtaPhiM(jet['pt'],0.,jet['phi'],0.) wwwtlv -= tlvaux mettlv.SetPtEtaPhiM(met['pt'],0.,met['phi'],0.) leptlv.SetPtEtaPhiM(lep['pt'],lep['eta'],lep['phi'], 0.) # leptlv.SetPtEtaPhiM(e.muPt[0],e.muEta[0],e.muPhi[0],0.) # calculate eta(W) estimate; take the + solution ptl = (wwwtlv - mettlv).Pt() ptn = mettlv.Pt() ptw = wwwtlv.Pt() etal = leptlv.Eta() A = (mw*mw + ptw*ptw - ptl*ptl - ptn*ptn) / (2.*ptl*ptn) if(A<1.): A=1. etaw = asinh((ptl*sinh(etal)+ptn*sinh(etal+acosh(A)))/ptw) if(abs(etaw)>10.): etaw=10*etaw/abs(etaw) # avoid too large values wwwtlv.SetPtEtaPhiM(wwwtlv.Pt(),etaw,wwwtlv.Phi(),mw) # calulate boosted lepton momentum beta = wwwtlv.BoostVector() leptlv.Boost(-beta) return leptlv.P()
def to_latlon(northings, eastings, altitude): f = 1/298.257223563 n = f / (2 - f) n_0 = 0.0 k_0 = 0.9996 e_0 = 500. a = 6378.137 #km big_a = (a / (1 + n)) * (1 + (n**2 / 4) + (n**4 / 64)) #approximately alpha_1 = .5 * n - (2. / 3.) * n**2 + (5. / 16.) * n**3 alpha_2 = (13./48.) * n**2 - (3./5.) * n**3 alpha_3 = (61./240.) * n**3 beta_1 = (1./2.) * n - (2. / 3.) * n**2 + (37./96.) * n**3 beta_2 = (1./48.) * n**2 + (1. / 15.) * n**3 beta_3 = (17. /480.) * n**3 delta_1 = 2. * n - (2./3.) * n**2 - 2* n**3 delta_2 = (7./3.) * n**2 - (8. / 5.) * n**3 delta_3 = (56./15.) * n**3 psi = (n - n_0) / (k_0 * big_a) eta = (e - e_0) / (k_0 * big_a) psi_prime = psi - ((beta_1 * sin(2. * 1 * eta) * cosh(2. * 1 * eta)) + (beta_2 * sin(2. * 2 * eta) * cosh(2. * 2 * eta)) + (beta_3 * sin(2. * 3 * eta) * cosh(2. * 3 * eta))) eta_prime = eta - ((beta_1 * cos(2. * 1 * psi) * sinh(2. * 1 * eta)) + (beta_2 * cos(2. * 2 * psi) * sinh(2. * 2 * eta)) + (beta_3 * cos(2. * 3 * psi) * sinh(2. * 3 * eta))) sigma_prime = 1. - ((2. * 1 * beta_1 * cos(2. * 1 * psi) * cosh(2. * 1 * eta)) + (2. * 2 * beta_2 * cos(2. * 2 * psi) * cosh(2. * 2 * eta)) + (2. * 3 * beta_3 * cos(2. * 3 * psi) * cosh(2. * 3 * eta))) tau_prime = ((2. * 1 * beta_1 * sin(2. * 1 * psi) * sinh(2. * 1 * eta)) + (2. * 2 * beta_2 * sin(2. * 2 * psi) * sinh(2. * 2 * eta)) + (2. * 3 * beta_3 * sin(2. * 3 * psi) * sinh(2. * 3 * eta))) chi = asin (sin(psi_prime)/cosh(eta_prime)) phi = chi + (delta_1 * sin(2. * 1 * chi)) + (delta_2 * sin(2. * 2 * chi)) + (delta_3 * sin(2. * 3 * chi)) lambda_0 = 0 lambdu = 0 k = 0 gamma = 0 return None
def lalo_to_xy(la, lo, lo0, E0, ellipsoid): lo0 = math.radians(lo0) la = math.radians(la) lo = math.radians(lo) e = ellipsoid['e'] k0 = ellipsoid['k0'] h1p = ellipsoid['h1p'] h2p = ellipsoid['h2p'] h3p = ellipsoid['h3p'] h4p = ellipsoid['h4p'] A1 = ellipsoid['A1'] Q = asinh(math.tan(la)) - e * atanh(e * math.sin(la)) be = math.atan(math.sinh(Q)) nnp = atanh(math.cos(be) * math.sin(lo - lo0)) Ep = math.asin(math.sin(be) * math.cosh(nnp)) E1 = h1p * math.sin(2.0 * Ep) * math.cosh(2.0 * nnp) E2 = h2p * math.sin(4.0 * Ep) * math.cosh(4.0 * nnp) E3 = h3p * math.sin(6.0 * Ep) * math.cosh(6.0 * nnp) E4 = h4p * math.sin(8.0 * Ep) * math.cosh(8.0 * nnp) nn1 = h1p * math.cos(2.0 * Ep) * math.sinh(2.0 * nnp) nn2 = h2p * math.cos(4.0 * Ep) * math.sinh(4.0 * nnp) nn3 = h3p * math.cos(6.0 * Ep) * math.sinh(6.0 * nnp) nn4 = h4p * math.cos(8.0 * Ep) * math.sinh(8.0 * nnp) E = Ep + E1 + E2 + E3 + E4 nn = nnp + nn1 + nn2 + nn3 + nn4 XY = {} XY['N'] = A1 * E * k0 XY['E'] = A1 * nn * k0 + E0 return XY
def eccentricAnomaly(e,M): """Returns the eccentric anomaly given the eccentricity and mean anomaly of a Keplerian orbit. Keyword arguments: e -- the eccentricity M -- the mean anomaly """ if e<1.: E = M if e<0.8 else math.pi F = E - e*math.sin(M) - M for i in range(100): E = E - F/(1.0-e*math.cos(E)) F = E - e*math.sin(E) - M if math.fabs(F)<1e-16: break E = mod2pi(E) return E else: E = M F = E - e*math.sinh(E) - M for i in range(100): E = E - F/(1.0-e*math.cosh(E)) F = E - e*math.sinh(E) - M if math.fabs(F)<1e-16: break E = mod2pi(E) return E
def tri_angles(L): ans = [0, 0, 0] for i in xrange(3): top = math.cosh(L[i])*math.cosh(L[(i+2)%3]) - math.cosh( L[(i+1)%3] ) bottom = math.sinh(L[i])*math.sinh(L[(i+2)%3]) ans[i] = math.acos(top/bottom) return ans
def robustness(self,K): """ vals is a list of tuple (eigenvalue,order id) """ if len(self.vals) < K or K == 0: K = len(self.vals) """ Robustness """ robust = 0.0 """ basic, we assume the lamda_one is large than zero """ lamda_one = self.vals[0] if lamda_one <= 0: print "the largest eigenvalue of graph is less than zero, please check the graph" return for i in range(0,len(self.vals)): """ NSC_k """ nsc = 0.0 for j in range(0,K): lamda_j = self.vals[j] nsc = nsc + self.vecs[i][j]*self.vecs[i][j]*math.sinh(lamda_j) r = math.log(self.vecs[i][0]*self.vecs[i][0]) - math.log(nsc / math.sinh(lamda_one)) r *= 0.5 robust = robust + r*r robust = robust / float(len(self.vals)) robust = math.sqrt(robust) return robust
def fromwgs84(lat, lng, pkm=False): """ Convert coordintes from WGS84 to TWD97 pkm true for Penghu, Kinmen and Matsu area The latitude and longitude can be in the following formats: [+/-]DDD°MMM'SSS.SSSS" (unicode) [+/-]DDD°MMM.MMMM' (unicode) [+/-]DDD.DDDDD (string, unicode or float) The returned coordinates are in meters """ _lng0 = lng0pkm if pkm else lng0 lat = radians(todegdec(lat)) lng = radians(todegdec(lng)) t = sinh((atanh(sin(lat)) - 2*pow(n,0.5)/(1+n)*atanh(2*pow(n,0.5)/(1+n)*sin(lat)))) epsilonp = atan(t/cos(lng-_lng0)) etap = atan(sin(lng-_lng0) / pow(1+t*t, 0.5)) E = E0 + k0*A*(etap + alpha1*cos(2*1*epsilonp)*sinh(2*1*etap) + alpha2*cos(2*2*epsilonp)*sinh(2*2*etap) + alpha3*cos(2*3*epsilonp)*sinh(2*3*etap)) N = N0 + k0*A*(epsilonp + alpha1*sin(2*1*epsilonp)*cosh(2*1*etap) + alpha2*sin(2*2*epsilonp)*cosh(2*2*etap) + alpha3*sin(2*3*epsilonp)*cosh(2*3*etap)) return E*1000, N*1000
def test_funcs_multi(self): pi = math.pi # sin family self.assertQuantity(data.sin(Quantity( (0,pi/2), (2,2))), (0,1), (2,0)) self.assertQuantity(data.sinh(Quantity((0,1), (2,2))), (0, math.sinh(1)), (2, math.cosh(1)*2)) self.assertQuantity(data.asin(Quantity((0,0.5), (2,2))), (0,math.asin(0.5)), (2,2/math.sqrt(1-0.5**2))) self.assertQuantity(data.asinh(Quantity((0,1), (2,2))), (0,math.asinh(1)), (2,2/math.sqrt(1+1**2))) # cos family self.assertQuantity(data.cos(Quantity((0,pi/2), (2,2))), (1,0), (0,-2)) self.assertQuantity(data.cosh(Quantity((0,1), (2,2))), (1,math.cosh(1)), (0,math.sinh(1)*2)) self.assertQuantity(data.acos(Quantity((0,0.5), (2,2))), (math.acos(0),math.acos(0.5)), (-2,-2/math.sqrt(1-0.5**2))) self.assertQuantity(data.acosh(Quantity((2,3), (2,2))), (math.acosh(2), math.acosh(3)), (2/math.sqrt(2**2-1),2/math.sqrt(3**2-1))) # tan family self.assertQuantity(data.tan(Quantity((0,1), (2,2))), (0,math.tan(1)), (2,2/math.cos(1)**2)) self.assertQuantity(data.tanh(Quantity((0,1), (2,2))), (0,math.tanh(1)), (2,2/math.cosh(1)**2)) self.assertQuantity(data.atan(Quantity((0,1), (2,2))), (0, math.atan(1)), (2,2/(1+1**2))) self.assertQuantity(data.atan2(Quantity((0,1), (2,2)), Quantity((1,1), (0,0))), (0,math.atan(1)), (2,2/(1+1**2))) self.assertQuantity(data.atanh(Quantity((0,0.5), (2,2))), (0,math.atanh(0.5)), (2,2/(1-0.5**2))) #misc self.assertQuantity(data.sqrt(Quantity((1,4), (2,2))), (1,2), (1,1/2)) self.assertQuantity(data.exp(Quantity((1,4), (2,2))), (math.e, math.e**4), (2 * math.e,2*math.e**4)) self.assertQuantity(data.log(Quantity((1,4), (2,2))), (0, math.log(4)), (2,1/2))
def testInnerIteration(mesh,dm): J_inc = 0 N = mesh.n_elems sig_r = [dm.getND(i).getSigmaR()[0] for i in range(N)] D = [dm.getND(i).diff_coef[0] for i in range(N)] Q = np.ones(N) S = 3 Q = np.ones((N,1))*S G = dm.n_groups J_inc = 0. phi = innerIteration(mesh,Q,dm,J_inc,verbosity=5) phi_ss = diffSSFixedSource(mesh,D,sig_r,Q,J_inc,tol=1.E-06) x = mesh.getCellCenters() from math import sinh, sqrt rex = mesh.getElement(N-1).rr + 2.*D[0] L = sqrt(D[0]/sig_r[0]) analytic = lambda r: S*sinh((rex - r)/L)/(4*pi*r*D[0]*sinh(rex/L)) analytic = lambda r: -1.*S*L*L*rex/(r*D[0]*sinh(rex/L))*sinh(r/L) + S*L*L/D[0] plt.plot(x,phi,'+-b',label='Inner') plt.plot(x,phi_ss,"o",label='Direct SS Call') exact = [analytic(i) for i in x] plt.plot(x,exact,"--r",label="exact") plt.legend() plt.show() exit()
def gridToGeodetic(self, north, east): """ Transformation from grid coordinates to geodetic coordinates. @param north (corresponds to X in RT 90 and N in SWEREF 99.) @param east (corresponds to Y in RT 90 and E in SWEREF 99.) @return (latitude, longitude) """ if (self._initialized == False): return None deg_to_rad = math.pi / 180 lambda_zero = self._central_meridian * deg_to_rad xi = (north - self._false_northing) / (self._scale * self._a_roof) eta = (east - self._false_easting) / (self._scale * self._a_roof) xi_prim = xi - \ self._delta1*math.sin(2.0*xi) * math.cosh(2.0*eta) - \ self._delta2*math.sin(4.0*xi) * math.cosh(4.0*eta) - \ self._delta3*math.sin(6.0*xi) * math.cosh(6.0*eta) - \ self._delta4*math.sin(8.0*xi) * math.cosh(8.0*eta) eta_prim = eta - \ self._delta1*math.cos(2.0*xi) * math.sinh(2.0*eta) - \ self._delta2*math.cos(4.0*xi) * math.sinh(4.0*eta) - \ self._delta3*math.cos(6.0*xi) * math.sinh(6.0*eta) - \ self._delta4*math.cos(8.0*xi) * math.sinh(8.0*eta) phi_star = math.asin(math.sin(xi_prim) / math.cosh(eta_prim)) delta_lambda = math.atan(math.sinh(eta_prim) / math.cos(xi_prim)) lon_radian = lambda_zero + delta_lambda lat_radian = phi_star + math.sin(phi_star) * math.cos(phi_star) * \ (self._Astar + \ self._Bstar*math.pow(math.sin(phi_star), 2) + \ self._Cstar*math.pow(math.sin(phi_star), 4) + \ self._Dstar*math.pow(math.sin(phi_star), 6)) lat = lat_radian * 180.0 / math.pi lon = lon_radian * 180.0 / math.pi return (lat, lon)
def from_utm(easting: float, northing: float, zone: int, hemisphere: int =1) -> (float, float): """ Convert UTM coordinates to decimal latitude and longitude coordinates. Keyword Arguments: easting: The easting in m. northing: The northing in m. zone: The zone, an integer between 1 and 60, inclusive. hemisphere: A signed number, where a negative number indicates the coordinates are located in the southern hemisphere. Returns: latitude: The latitude in decimal degrees. longitude: The longitude in deciaml degrees. Raises: OverflowError: The coordinate does not exist. """ easting, northing = easting/1000, northing/1000 northing_ = 10000 if hemisphere < 0 else 0 xi_ = xi = (northing - northing_)/(k0*A) eta_ = eta = (easting - easting_)/(k0*A) for j in range(1, 4): p, q = 2*j*xi, 2*j*eta xi_ -= beta[j - 1]*sin(p)*cosh(q) eta_ -= beta[j - 1]*cos(p)*sinh(q) chi = asin(sin(xi_)/cosh(eta_)) latitude = chi + sum(delta[j - 1]*sin(2*j*chi) for j in range(1, 4)) longitude_ = radians(6*zone - 183) longitude = longitude_ + atan2(sinh(eta_), cos(xi_)) return degrees(latitude), degrees(longitude)
def exact_fn ( x ): # ## EXACT_FN evaluates the exact solution. # from math import sinh value = x - sinh ( x ) / sinh ( 1.0 ) return value
def tileGeometry(self, x, y, z): n = 2.0 ** z xmin = x / n * 360.0 - 180.0 xmax = (x + 1) / n * 360.0 - 180 ymin = math.degrees(math.atan(math.sinh(math.pi * (1 - 2 * y / n)))) ymax = math.degrees(math.atan(math.sinh(math.pi * (1 - 2 * (y + 1) / n)))) return QgsGeometry.fromRect(QgsRectangle(xmin, ymin, xmax, ymax))
def sinh(self, other=None): # Return hiperbolic sine of interval if other != None: intv = IReal(self, other) else: if type(self) == float or type(self) == str: intv = IReal(self) else: intv = self if math.sinh(intv.inf) > math.sinh(intv.sup): inf = max(intv.inf, intv.sup) sup = min(intv.inf, intv.sup) else: inf = intv.inf sup = intv.sup ireal.rounding.set_mode(1) ireal.rounding.set_mode(-1) ireal.rounding.set_mode(-1) new_inf = math.sinh(inf) ireal.rounding.set_mode(1) new_sup = max(float(IReal('%.16f' % math.sinh(sup)).sup), float(IReal('%.20f' % math.sinh(sup)).sup)) return IReal(new_inf, new_sup)
def c_cosh(x, y): if not isfinite(x) or not isfinite(y): if isinf(x) and isfinite(y) and y != 0.: if x > 0: real = copysign(INF, math.cos(y)) imag = copysign(INF, math.sin(y)) else: real = copysign(INF, math.cos(y)) imag = -copysign(INF, math.sin(y)) r = (real, imag) else: r = cosh_special_values[special_type(x)][special_type(y)] # need to raise ValueError if y is +/- infinity and x is not # a NaN if isinf(y) and not isnan(x): raise ValueError("math domain error") return r if fabs(x) > CM_LOG_LARGE_DOUBLE: # deal correctly with cases where cosh(x) overflows but # cosh(z) does not. x_minus_one = x - copysign(1., x) real = math.cos(y) * math.cosh(x_minus_one) * math.e imag = math.sin(y) * math.sinh(x_minus_one) * math.e else: real = math.cos(y) * math.cosh(x) imag = math.sin(y) * math.sinh(x) if isinf(real) or isinf(imag): raise OverflowError("math range error") return real, imag
def c_sinh(x, y): # special treatment for sinh(+/-inf + iy) if y is finite and nonzero if not isfinite(x) or not isfinite(y): if isinf(x) and isfinite(y) and y != 0.: if x > 0: real = copysign(INF, math.cos(y)) imag = copysign(INF, math.sin(y)) else: real = -copysign(INF, math.cos(y)) imag = copysign(INF, math.sin(y)) r = (real, imag) else: r = sinh_special_values[special_type(x)][special_type(y)] # need to raise ValueError if y is +/- infinity and x is not # a NaN if isinf(y) and not isnan(x): raise ValueError("math domain error") return r if fabs(x) > CM_LOG_LARGE_DOUBLE: x_minus_one = x - copysign(1., x) real = math.cos(y) * math.sinh(x_minus_one) * math.e imag = math.sin(y) * math.cosh(x_minus_one) * math.e else: real = math.cos(y) * math.sinh(x) imag = math.sin(y) * math.cosh(x) if isinf(real) or isinf(imag): raise OverflowError("math range error") return real, imag
def cosh(x): _cosh_special = [ [inf+nanj, None, inf, complex(float("inf"), -0.0), None, inf+nanj, inf+nanj], [nan+nanj, None, None, None, None, nan+nanj, nan+nanj], [nan, None, 1, complex(1, -0.0), None, nan, nan], [nan, None, complex(1, -0.0), 1, None, nan, nan], [nan+nanj, None, None, None, None, nan+nanj, nan+nanj], [inf+nanj, None, complex(float("inf"), -0.0), inf, None, inf+nanj, inf+nanj], [nan+nanj, nan+nanj, nan, nan, nan+nanj, nan+nanj, nan+nanj] ] z = _make_complex(x) if not isfinite(z): if math.isinf(z.imag) and not math.isnan(z.real): raise ValueError if math.isinf(z.real) and math.isfinite(z.imag) and z.imag != 0: if z.real > 0: return complex(math.copysign(inf, math.cos(z.imag)), math.copysign(inf, math.sin(z.imag))) return complex(math.copysign(inf, math.cos(z.imag)), -math.copysign(inf, math.sin(z.imag))) return _cosh_special[_special_type(z.real)][_special_type(z.imag)] if abs(z.real) > _LOG_LARGE_DOUBLE: x_minus_one = z.real - math.copysign(1, z.real) ret = complex(e * math.cos(z.imag) * math.cosh(x_minus_one), e * math.sin(z.imag) * math.sinh(x_minus_one)) else: ret = complex(math.cos(z.imag) * math.cosh(z.real), math.sin(z.imag) * math.sinh(z.real)) if math.isinf(ret.real) or math.isinf(ret.imag): raise OverflowError return ret
def sinh(x): _sinh_special = [ [inf+nanj, None, complex(-float("inf"), -0.0), -inf, None, inf+nanj, inf+nanj], [nan+nanj, None, None, None, None, nan+nanj, nan+nanj], [nanj, None, complex(-0.0, -0.0), complex(-0.0, 0.0), None, nanj, nanj], [nanj, None, complex(0.0, -0.0), complex(0.0, 0.0), None, nanj, nanj], [nan+nanj, None, None, None, None, nan+nanj, nan+nanj], [inf+nanj, None, complex(float("inf"), -0.0), inf, None, inf+nanj, inf+nanj], [nan+nanj, nan+nanj, complex(float("nan"), -0.0), nan, nan+nanj, nan+nanj, nan+nanj] ] z = _make_complex(x) if not isfinite(z): if math.isinf(z.imag) and not math.isnan(z.real): raise ValueError if math.isinf(z.real) and math.isfinite(z.imag) and z.imag != 0: if z.real > 0: return complex(math.copysign(inf, math.cos(z.imag)), math.copysign(inf, math.sin(z.imag))) return complex(-math.copysign(inf, math.cos(z.imag)), math.copysign(inf, math.sin(z.imag))) return _sinh_special[_special_type(z.real)][_special_type(z.imag)] if abs(z.real) > _LOG_LARGE_DOUBLE: x_minus_one = z.real - math.copysign(1, z.real) return complex(math.cos(z.imag) * math.sinh(x_minus_one) * e, math.sin(z.imag) * math.cosh(x_minus_one) * e) return complex(math.cos(z.imag) * math.sinh(z.real), math.sin(z.imag) * math.cosh(z.real))
def test_sinh(self): self.assertAlmostEqual(qmath.sinh(self.f1), math.sinh(self.f1)) self.assertAlmostEqual(qmath.sinh(self.c1), cmath.sinh(self.c1)) self.assertAlmostEqual(qmath.sinh(self.c2), cmath.sinh(self.c2)) self.assertAlmostEqual(qmath.sinh(Quat(self.f1)), math.sinh(self.f1)) self.assertAlmostEqual(qmath.sinh(Quat(0, 3)), cmath.sinh(3J)) self.assertAlmostEqual(qmath.sinh(Quat(4, 5)), cmath.sinh(4 + 5J)) self.assertAlmostEqual(qmath.sinh(Quat(0, self.f1)), Quat(0, math.sin(self.f1)))
def levy_harmonic_path(xstart, xend, dtau, N): x = [xstart] for k in range(1, N): dtau_prime = (N - k) * dtau Ups1 = 1.0 / math.tanh(dtau) + 1.0 / math.tanh(dtau_prime) Ups2 = x[k-1] / math.sinh(dtau) + xend / math.sinh(dtau_prime) x.append(random.gauss(Ups2 / Ups1, 1.0 / math.sqrt(Ups1))) return x
def aux1(x): ''' Auxiliary function 1. Break points used to ensure maximal precision:: x Aux1(x) = ------- sinh(x) d sinh(x) - x*cosh(x) --Aux1(x) = ------------------- dx (sinh(x))^2 ''' if isinstance(x, ADVar): y = x.val else: y=float(x); if y < -_BP0_MISC: y = -_BP0_MISC elif y > _BP0_MISC: y = _BP0_MISC if y <= _BP0_AUX1: z = y / math.sinh(y) elif y <= _BP1_AUX1: z = 1 - y*y/6.0*(1.0 - 7.0*y*y/60.0) else: z = y / math.sinh(y) if not isinstance(x, ADVar): return z r = ADVar() r.val = z if y <= _BP4_DAUX1: pd = 0.0 elif y <= _BP2_DAUX1: pd = -(1+y)*math.exp(y) elif y <= _BP0_DAUX1: tmp = math.sinh(y); pd = (tmp - y*math.cosh(y))/(tmp*tmp) elif y <= _BP1_DAUX1: pd = -y/3.0*(1.0 - 7.0*y*y/30.0) elif y <= _BP3_DAUX1: tmp = math.sinh(y) pd = (z - y*math.cosh(y))/(z*z) elif y <= _BP5_DAUX1: pd = (1-y)*math.exp(-y) else: pd = 0.0 for i,dx in x.deriv: r.deriv.append( (i, pd*dx) ) return r
def heat_capacity_v_einstein(T,einstein_T,n): """ Heat capacity at constant volume. In J/K/mol """ if T <= eps: return 0. x = einstein_T/T C_v = 3.0*n*gas_constant*x*x/4/(math.sinh(x/2.)*math.sinh(x/2.)) return C_v
def t0_xi(): delta_rho = (rho0-rhou)*g rhog = rho0*g mu = mu0 k = wavenumber() return -1.0*(((delta_rho*k**2*mu - k**2*mu*rhog)*D*sinh(D*k)**2 - (delta_rho*k**2*mu - k**2*mu*rhog)*D*cosh(D*k)**2 - (delta_rho*k*mu -\ k*mu*rhog)*sinh(D*k)*cosh(D*k) + sqrt((delta_rho**2*k**2 - 2*delta_rho*k**2*rhog + k**2*rhog**2)*D**2*cosh(D*k)**4 - 2*(delta_rho**2*k -\ 2*delta_rho*k*rhog + k*rhog**2)*D*sinh(D*k)**3*cosh(D*k) + 2*(delta_rho**2*k - 2*delta_rho*k*rhog + k*rhog**2)*D*sinh(D*k)*cosh(D*k)**3 +\ ((delta_rho**2*k**2 + 2*delta_rho*k**2*rhog + k**2*rhog**2)*D**2 + 4*delta_rho*rhog)*sinh(D*k)**4 - (2*(delta_rho**2*k**2 + k**2*rhog**2)*D**2 -\ delta_rho**2 + 2*delta_rho*rhog - rhog**2)*sinh(D*k)**2*cosh(D*k)**2)*k*mu)/(delta_rho*rhog*sinh(D*k)**2))
def __conv_WGS84_SWED_RT90(lat, lon): """ Input is lat and lon as two float numbers Output is X and Y coordinates in RT90 as a tuple of float numbers The code below converts to/from the Swedish RT90 koordinate system. The converion functions use "Gauss Conformal Projection (Transverse Marcator)" Krüger Formulas. The constanst are for the Swedish RT90-system. With other constants the conversion should be useful for other geographical areas. """ # Some constants used for conversion to/from Swedish RT90 f = 1.0/298.257222101 e2 = f*(2.0-f) n = f/(2.0-f) L0 = math.radians(15.8062845294) # 15 deg 48 min 22.624306 sec k0 = 1.00000561024 a = 6378137.0 # meter at = a/(1.0+n)*(1.0+ 1.0/4.0* pow(n, 2)+1.0/64.0*pow(n, 4)) FN = -667.711 # m FE = 1500064.274 # m #the conversion lat_rad = math.radians(lat) lon_rad = math.radians(lon) A = e2 B = 1.0/6.0*(5.0*pow(e2, 2) - pow(e2, 3)) C = 1.0/120.0*(104.0*pow(e2, 3) - 45.0*pow(e2, 4)) D = 1.0/1260.0*(1237.0*pow(e2, 4)) DL = lon_rad - L0 E = A + B*pow(math.sin(lat_rad), 2) + \ C*pow(math.sin(lat_rad), 4) + \ D*pow(math.sin(lat_rad), 6) psi = lat_rad - math.sin(lat_rad)*math.cos(lat_rad)*E xi = math.atan2(math.tan(psi), math.cos(DL)) eta = atanh(math.cos(psi)*math.sin(DL)) B1 = 1.0/2.0*n - 2.0/3.0*pow(n, 2) + 5.0/16.0*pow(n, 3) + \ 41.0/180.0*pow(n, 4) B2 = 13.0/48.0*pow(n, 2) - 3.0/5.0*pow(n, 3) + 557.0/1440.0*pow(n, 4) B3 = 61.0/240.0*pow(n, 3) - 103.0/140.0*pow(n, 4) B4 = 49561.0/161280.0*pow(n, 4) X = xi + B1*math.sin(2.0*xi)*math.cosh(2.0*eta) + \ B2*math.sin(4.0*xi)*math.cosh(4.0*eta) + \ B3*math.sin(6.0*xi)*math.cosh(6.0*eta) + \ B4*math.sin(8.0*xi)*math.cosh(8.0*eta) Y = eta + B1*math.cos(2.0*xi)*math.sinh(2.0*eta) + \ B2*math.cos(4.0*xi)*math.sinh(4.0*eta) + \ B3*math.cos(6.0*xi)*math.sinh(6.0*eta) + \ B4*math.cos(8.0*xi)*math.sinh(8.0*eta) X = X*k0*at + FN Y = Y*k0*at + FE return (X, Y)
def rawf(x): return math.sinh(x)
def _zetaInv0(self, psi, lam): '''Starting point for C{zetaInv}. @return: 3-Tuple C{(u, v, trip)}. @see: C{bool TMExact::zetainv0(real psi, real lam, # radians real &u, real &v)}. ''' trip = False if (psi < -self._e_PI_4 and lam > self._1_e2_PI_2 and psi < lam - self._1_e_PI_2): # N.B. this branch is normally not taken because psi < 0 # is converted psi > 0 by Forward. # # There's a log singularity at w = w0 = Eu.K() + i * Ev.K(), # corresponding to the south pole, where we have, approximately # # psi = _e + i * pi/2 - _e * atanh(cos(i * (w - w0)/(1 + _mu/2))) # # Inverting this gives: h = sinh(1 - psi / self._e) a = (PI_2 - lam) / self._e s, c = sincos2(a) u = self._Eu_K - asinh(s / hypot(c, h)) * self._mu_2_1 v = self._Ev_K - atan2(c, h) * self._mu_2_1 elif (psi < self._e_PI_2 and lam > self._1_e2_PI_2): # At w = w0 = i * Ev.K(), we have # # zeta = zeta0 = i * (1 - _e) * pi/2 # zeta' = zeta'' = 0 # # including the next term in the Taylor series gives: # # zeta = zeta0 - (_mv * _e) / 3 * (w - w0)^3 # # When inverting this, we map arg(w - w0) = [-90, 0] to # arg(zeta - zeta0) = [-90, 180] d = lam - self._1_e_PI_2 r = hypot(psi, d) # Error using this guess is about 0.21 * (rad/e)^(5/3) trip = r < self._e_taytol_ # atan2(dlam-psi, psi+dlam) + 45d gives arg(zeta - zeta0) # in range [-135, 225). Subtracting 180 (since multiplier # is negative) makes range [-315, 45). Multiplying by 1/3 # (for cube root) gives range [-105, 15). In particular # the range [-90, 180] in zeta space maps to [-90, 0] in # w space as required. r = cbrt(r * self._3_mv_e) a = atan2(d - psi, psi + d) / 3.0 - PI_4 s, c = sincos2(a) u = r * c v = r * s + self._Ev_K else: # Use spherical TM, Lee 12.6 -- writing C{atanh(sin(lam) / # cosh(psi)) = asinh(sin(lam) / hypot(cos(lam), sinh(psi)))}. # This takes care of the log singularity at C{zeta = Eu.K()}, # corresponding to the north pole. s, c = sincos2(lam) h, r = sinh(psi), self._Eu_K / PI_2 # But scale to put 90, 0 on the right place u = r * atan2(h, c) v = r * asinh(s / hypot(c, h)) return u, v, trip
def nond_F(x, t): k = nond_wavenumber() F0 = nond_eta0() G0 = nond_xi0() delta_rho = (rho0 - rhou) * nond_factor() / rho0 zprime = depth / D T0 = deltaT alphag = nond_factor() * alpha * T0 rhog = nond_factor( ) # use this as a proxy for the nondimensional factorisation return ((-0.5*(exp(-delta_rho*rhog*t*sinh(k)**2/((delta_rho*k - k*rhog)*sinh(k)*cosh(k) + delta_rho*k**2 - k**2*rhog -\ sqrt((delta_rho**2 + 2*delta_rho*rhog + rhog**2)*sinh(k)**4 + delta_rho**2*k**2 - 2*delta_rho*k**2*rhog + k**2*rhog**2 + 2*(delta_rho**2*k -\ 2*delta_rho*k*rhog + k*rhog**2)*sinh(k)*cosh(k) - (4*delta_rho*k**2*rhog - delta_rho**2 + 2*delta_rho*rhog -\ rhog**2)*sinh(k)**2)*k))/((k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3 - rhog*sinh(k)*cosh(k)**2)/((delta_rho +\ rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2 - sqrt(delta_rho**2*k**2*sinh(k)**4 -\ 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 + 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4\ + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 + k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) +\ 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k) - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 -\ 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 + delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 -\ 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 + rhog**2*sinh(k)**2*cosh(k)**2)) - (k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3\ - rhog*sinh(k)*cosh(k)**2)/((delta_rho + rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2\ + sqrt(delta_rho**2*k**2*sinh(k)**4 - 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 +\ 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4 + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 +\ k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) + 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k)\ - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 - 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 +\ delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 - 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 +\ rhog**2*sinh(k)**2*cosh(k)**2))) - exp(-delta_rho*rhog*t*sinh(k)**2/((delta_rho*k - k*rhog)*sinh(k)*cosh(k) + delta_rho*k**2 - k**2*rhog +\ sqrt((delta_rho**2 + 2*delta_rho*rhog + rhog**2)*sinh(k)**4 + delta_rho**2*k**2 - 2*delta_rho*k**2*rhog + k**2*rhog**2 + 2*(delta_rho**2*k -\ 2*delta_rho*k*rhog + k*rhog**2)*sinh(k)*cosh(k) - (4*delta_rho*k**2*rhog - delta_rho**2 + 2*delta_rho*rhog -\ rhog**2)*sinh(k)**2)*k))/((k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3 - rhog*sinh(k)*cosh(k)**2)/((delta_rho +\ rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2 - sqrt(delta_rho**2*k**2*sinh(k)**4 -\ 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 + 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4\ + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 + k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) +\ 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k) - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 -\ 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 + delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 -\ 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 + rhog**2*sinh(k)**2*cosh(k)**2)) - (k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3\ - rhog*sinh(k)*cosh(k)**2)/((delta_rho + rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2\ + sqrt(delta_rho**2*k**2*sinh(k)**4 - 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 +\ 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4 + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 +\ k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) + 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k)\ - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 - 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 +\ delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 - 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 +\ rhog**2*sinh(k)**2*cosh(k)**2))))*(G0 + (alphag*k*sinh(k*zprime)*cosh(k) - (alphag*k*zprime*cosh(k*zprime) -\ alphag*sinh(k*zprime))*sinh(k))/(T0*delta_rho*sinh(k)**2)) + (F0 - ((alphag*k*zprime*cosh(k*zprime) -\ alphag*sinh(k*zprime))*sinh(k)*cosh(k) - (alphag*k*zprime*sinh(k*zprime) - alphag*cosh(k*zprime))*sinh(k)**2 -\ alphag*k*sinh(k*zprime))/(T0*rhog*sinh(k)**2))*(((k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3 -\ rhog*sinh(k)*cosh(k)**2)/(((k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3 - rhog*sinh(k)*cosh(k)**2)/((delta_rho +\ rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2 - sqrt(delta_rho**2*k**2*sinh(k)**4 -\ 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 + 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4\ + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 + k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) +\ 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k) - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 -\ 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 + delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 -\ 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 + rhog**2*sinh(k)**2*cosh(k)**2)) - (k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3\ - rhog*sinh(k)*cosh(k)**2)/((delta_rho + rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2\ + sqrt(delta_rho**2*k**2*sinh(k)**4 - 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 +\ 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4 + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 +\ k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) + 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k)\ - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 - 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 +\ delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 - 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 +\ rhog**2*sinh(k)**2*cosh(k)**2)))*((delta_rho + rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k +\ k*rhog)*cosh(k)**2 + sqrt(delta_rho**2*k**2*sinh(k)**4 - 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 +\ 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4 + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 +\ k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) + 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k)\ - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 - 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 +\ delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 - 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 +\ rhog**2*sinh(k)**2*cosh(k)**2))) + 1)*exp(-delta_rho*rhog*t*sinh(k)**2/((delta_rho*k - k*rhog)*sinh(k)*cosh(k) + delta_rho*k**2 - k**2*rhog\ + sqrt((delta_rho**2 + 2*delta_rho*rhog + rhog**2)*sinh(k)**4 + delta_rho**2*k**2 - 2*delta_rho*k**2*rhog + k**2*rhog**2 + 2*(delta_rho**2*k\ - 2*delta_rho*k*rhog + k*rhog**2)*sinh(k)*cosh(k) - (4*delta_rho*k**2*rhog - delta_rho**2 + 2*delta_rho*rhog - rhog**2)*sinh(k)**2)*k)) -\ (k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3 -\ rhog*sinh(k)*cosh(k)**2)*exp(-delta_rho*rhog*t*sinh(k)**2/((delta_rho*k - k*rhog)*sinh(k)*cosh(k) + delta_rho*k**2 - k**2*rhog -\ sqrt((delta_rho**2 + 2*delta_rho*rhog + rhog**2)*sinh(k)**4 + delta_rho**2*k**2 - 2*delta_rho*k**2*rhog + k**2*rhog**2 + 2*(delta_rho**2*k -\ 2*delta_rho*k*rhog + k*rhog**2)*sinh(k)*cosh(k) - (4*delta_rho*k**2*rhog - delta_rho**2 + 2*delta_rho*rhog -\ rhog**2)*sinh(k)**2)*k))/(((k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3 - rhog*sinh(k)*cosh(k)**2)/((delta_rho +\ rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2 - sqrt(delta_rho**2*k**2*sinh(k)**4 -\ 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 + 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4\ + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 + k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) +\ 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k) - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 -\ 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 + delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 -\ 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 + rhog**2*sinh(k)**2*cosh(k)**2)) - (k*rhog*sinh(k)**2*cosh(k) - k*rhog*cosh(k)**3 + rhog*sinh(k)**3\ - rhog*sinh(k)*cosh(k)**2)/((delta_rho + rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k + k*rhog)*cosh(k)**2\ + sqrt(delta_rho**2*k**2*sinh(k)**4 - 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 +\ 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4 + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 +\ k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) + 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k)\ - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 - 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 +\ delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 - 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 +\ rhog**2*sinh(k)**2*cosh(k)**2)))*((delta_rho + rhog)*sinh(k)*cosh(k) - (delta_rho*k + k*rhog)*sinh(k)**2 + (delta_rho*k +\ k*rhog)*cosh(k)**2 + sqrt(delta_rho**2*k**2*sinh(k)**4 - 2*delta_rho**2*k**2*sinh(k)**2*cosh(k)**2 + delta_rho**2*k**2*cosh(k)**4 +\ 2*delta_rho*k**2*rhog*sinh(k)**4 - 2*delta_rho*k**2*rhog*cosh(k)**4 + k**2*rhog**2*sinh(k)**4 - 2*k**2*rhog**2*sinh(k)**2*cosh(k)**2 +\ k**2*rhog**2*cosh(k)**4 - 2*delta_rho**2*k*sinh(k)**3*cosh(k) + 2*delta_rho**2*k*sinh(k)*cosh(k)**3 + 4*delta_rho*k*rhog*sinh(k)**3*cosh(k)\ - 4*delta_rho*k*rhog*sinh(k)*cosh(k)**3 - 2*k*rhog**2*sinh(k)**3*cosh(k) + 2*k*rhog**2*sinh(k)*cosh(k)**3 +\ delta_rho**2*sinh(k)**2*cosh(k)**2 + 4*delta_rho*rhog*sinh(k)**4 - 2*delta_rho*rhog*sinh(k)**2*cosh(k)**2 +\ rhog**2*sinh(k)**2*cosh(k)**2)))) + ((alphag*k*zprime*cosh(k*zprime) - alphag*sinh(k*zprime))*sinh(k)*cosh(k) -\ (alphag*k*zprime*sinh(k*zprime) - alphag*cosh(k*zprime))*sinh(k)**2 - alphag*k*sinh(k*zprime))/(T0*rhog*sinh(k)**2)))*cos(k*x)
def funcl(x): return -(a / x) * mt.cosh(a * x) + (x**-2) * mt.sinh( a * x) + (b / x) * mt.cosh(b * x) - (x**-2) * mt.sinh(b * x)
print(math.pow(x, y)) print(math.acos(0.55)) print(math.asin(0.55)) print(math.atan(0.55)) print(math.atan2(0.55, 0.55)) print(math.cos(x)) print(math.hypot(x, y)) print(math.sin(x)) print(math.tan(x)) print(math.degrees(x)) print(math.radians(x)) print(math.acosh(x)) print(math.asinh(x)) print(math.atan(0.39)) print(math.cosh(x)) print(math.sinh(x)) print(math.tanh(x)) print(math.erf(x)) print(math.erfc(x)) print(math.gamma(x)) print(math.lgamma(x)) print(math.pi) print(math.e) # Random module print(random.seed(3)) print(random.getstate()) state = random.getstate() print(random.setstate(state)) print(random.getrandbits(43))
# Three ways to define a grid (inpired by http://mapproxy.org/docs/1.8.0/configuration.html#id6): # - submit a list of resolutions > "resolutions": [32,16,8,4] (This parameters override the others) # - submit just "resFactor", initial res is computed such as at zoom level zero, 1 tile covers whole bounding box # - submit "resFactor" and "initRes" # About Web Mercator # Technically, the Mercator projection is defined for any latitude up to (but not including) # 90 degrees, but it makes sense to cut it off sooner because it grows exponentially with # increasing latitude. The logic behind this particular cutoff value, which is the one used # by Google Maps, is that it makes the projection square. That is, the rectangle is equal in # the X and Y directions. In this case the maximum latitude attained must correspond to y = w/2. # y = 2*pi*R / 2 = pi*R --> y/R = pi # lat = atan(sinh(y/R)) = atan(sinh(pi)) # wm_origin = (-20037508, 20037508) with 20037508 = GRS80.perimeter / 2 cutoff_lat = math.atan(math.sinh(math.pi)) * 180 / math.pi #= 85.05112° GRIDS = { "WM": { "name": 'Web Mercator', "description": 'Global grid in web mercator projection', "CRS": 'EPSG:3857', "bbox": [-180, -cutoff_lat, 180, cutoff_lat], #w,s,e,n "bboxCRS": 'EPSG:4326', #"bbox": [-20037508, -20037508, 20037508, 20037508], #"bboxCRS": 3857, "tileSize": 256, "originLoc": "NW", #North West or South West "resFactor": 2 }, "WGS84": {
def toUtm(latlon, lon=None, datum=None, Utm=Utm, name='', cmoff=True): '''Convert a lat-/longitude point to a UTM coordinate. @param latlon: Latitude (C{degrees}) or an (ellipsoidal) geodetic C{LatLon} point. @keyword lon: Optional longitude (C{degrees} or C{None}). @keyword datum: Optional datum for this UTM coordinate, overriding I{latlon}'s datum (C{Datum}). @keyword Utm: Optional (sub-)class to use for the UTM coordinate (L{Utm}) or C{None}. @keyword name: Optional I{Utm} name (C{str}). @keyword cmoff: Offset longitude from zone's central meridian, apply false easting and false northing (C{bool}). @return: The UTM coordinate (L{Utm}) or a 6-tuple (zone, easting, northing, band, convergence, scale) if I{Utm} is C{None} or I{cmoff} is C{False}. @raise TypeError: If I{latlon} is not ellipsoidal. @raise RangeError: If I{lat} is outside the valid UTM bands or if I{lat} or I{lon} outside the valid range and I{rangerrrors} set to C{True}. @raise ValueError: If I{lon} value is missing or if I{latlon} is invalid. @note: Implements Karney’s method, using 8-th order Krüger series, giving results accurate to 5 nm (or better) for distances up to 3900 km from the central meridian. @example: >>> p = LatLon(48.8582, 2.2945) # 31 N 448251.8 5411932.7 >>> u = toUtm(p) # 31 N 448252 5411933 >>> p = LatLon(13.4125, 103.8667) # 48 N 377302.4 1483034.8 >>> u = toUtm(p) # 48 N 377302 1483035 ''' try: lat, lon = latlon.lat, latlon.lon if not isinstance(latlon, _LLEB): raise TypeError('%s not %s: %r' % ('latlon', 'ellipsoidal', latlon)) if not name: # use latlon.name name = _nameof(latlon) or name # PYCHOK no effect d = datum or latlon.datum except AttributeError: lat, lon = parseDMS2(latlon, lon) d = datum or Datums.WGS84 E = d.ellipsoid z, B, a, b = _toZBab4(lat, lon, cmoff) # easting, northing: Karney 2011 Eq 7-14, 29, 35 cb, sb, tb = cos(b), sin(b), tan(b) T = tan(a) T12 = hypot1(T) S = sinh(E.e * atanh(E.e * T / T12)) T_ = T * hypot1(S) - S * T12 H = hypot(T_, cb) y = atan2(T_, cb) # ξ' ksi x = asinh(sb / H) # η' eta A0 = _K0 * E.A Ks = _Kseries(E.AlphaKs, x, y) # Krüger series y = Ks.ys(y) * A0 # ξ x = Ks.xs(x) * A0 # η if cmoff: # C.F.F. Karney, "Test data for the transverse Mercator projection (2009)", # <http://GeographicLib.SourceForge.io/html/transversemercator.html> and # <http://Zenodo.org/record/32470#.W4LEJS2ZON8> x += _FalseEasting # make x relative to false easting if y < 0: y += _FalseNorthing # y relative to false northing in S # convergence: Karney 2011 Eq 23, 24 p_ = Ks.ps(1) q_ = Ks.qs(0) c = degrees(atan(T_ / hypot1(T_) * tb) + atan2(q_, p_)) # scale: Karney 2011 Eq 25 s = E.e2s(sin(a)) * T12 / H * (A0 / E.a * hypot(p_, q_)) if cmoff and Utm is not None: h = 'S' if a < 0 else 'N' # hemisphere return _xnamed(Utm(z, h, x, y, band=B, datum=d, convergence=c, scale=s), name) else: # zone, easting, northing, band, convergence and scale return z, x, y, B, c, s
def compute_delta_phi(r, rp): return math.atan(math.tanh(r / K) / math.sinh(rp / K))
def func_sinh(x): """Return sinh(x) where x is in radians""" # use the function from the 'math' library return sinh(x)
def _marcToLat(x): return math.degrees(math.atan(math.sinh(x)))
def compute_delta_theta(r, rp, phi): return math.atan(math.tanh(r / K) / (math.sinh(rp / K) * math.sinh(phi)))
def num2deg(xtile: int, ytile: int, zoom: int) -> Tuple[float, float]: n = 2.0**zoom lon_deg = xtile / n * 360.0 - 180.0 lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * ytile / n))) lat_deg = math.degrees(lat_rad) return (lon_deg, lat_deg)
def sinh(self): self.result = False self.current = math.sinh(math.radians(float(txtDisplay.get()))) self.display(self.current)
def func(x): return -(1 / x) * (mt.sinh(a * x) - mt.sinh(b * x)) - l
def tile2ll(x, y, z): n = 2**z lon = x / n * 360.0 - 180.0 lat = atan(sinh(π * (1 - 2 * y / n))) * 180.0 / π return [lon, lat]
def csch(x): return 1 / math.sinh(x)
def b(x1,x2): return sinh(As*ksi(x1,x2))/(As*ksi(x1,x2));
def lum_4(gen_z, omm, oml, omk, c_0, h0, n_sn, dlum): #integrating for first z point (needs to be done seperately to avoid indexing errors) cd, err = quad(integrand, 0, gen_z[0], args=(omm, oml, omk)) const = (abs(omk))**0.5 #defining constant for dlum calculation #calculating dlum for respecive omk values if omk < 0: dlum[0] = (c_0 / (h0 * const)) * (1.0 + gen_z[0]) * math.sin(const * cd) elif omk > 0: dlum[0] = (c_0 / (h0 * const)) * (1.0 + gen_z[0]) * math.sinh(const * cd) else: dlum[0] = (c_0 / h0) * (1.0 + gen_z[0]) * cd #loop over rest of z values (different calculation for varying omk values) if omk < 0: for i in range(1, n_sn): #looping through all z values if gen_z[i] == gen_z[ i - 1]: #if statment campares new point to last, if equal assign same dlum value (saves coputational cost) dlum[i] = dlum[i - 1] else: temp = quad( integrand, gen_z[i - 1], gen_z[i], args=( omm, oml, omk)) #integrates area between current and next point cd = cd + temp[ 0] #cumulative uses previous calculations for next dlum[i] = (c_0 / (h0 * const)) * (1.0 + gen_z[i]) * math.sin( const * cd) elif omk > 0: for i in range(1, n_sn): if gen_z[i] == gen_z[i - 1]: dlum[i] = dlum[i - 1] else: temp = quad(integrand, gen_z[i - 1], gen_z[i], args=(omm, oml, omk)) cd = cd + temp[0] dlum[i] = (c_0 / (h0 * const)) * (1.0 + gen_z[i]) * math.sinh( const * cd) else: for i in range(1, n_sn): if gen_z[i] == gen_z[i - 1]: dlum[i] = dlum[i - 1] else: temp = quad(integrand, gen_z[i - 1], gen_z[i], args=(omm, oml, omk)) cd = cd + temp[0] dlum[i] = (c_0 / h0) * (1.0 + gen_z[i]) * cd return dlum
def uEF(k, L, x, A, U_o): u_exact = [ ((sinh(k * (L - x)) + sinh(k * x)) / sinh(k * L) - 1) * A / k**2 + U_o * sinh(k * (L - x)) / sinh(k * L) for x in x[1:-1] ] return (u_exact)
def cdf(dist, a, *args, **kwargs): G = dist.cdf(*args, **kwargs) return 2 * math.exp(a) / (math.exp(2 * a) - 1) * math.sinh(a * G)
def toLatLon(self, LatLon=None): '''Convert this UTM coordinate to an (ellipsoidal) geodetic point. @keyword LatLon: Optional, ellipsoidal (sub-)class to use for the point (C{LatLon}) or C{None}. @return: This UTM coordinate as (I{LatLon}) or 5-tuple (lat, lon, datum, convergence, scale) if I{LatLon} is C{None}. @raise TypeError: If I{LatLon} is not ellipsoidal. @raise UTMError: Invalid meridional radius or H-value. @example: >>> u = Utm(31, 'N', 448251.795, 5411932.678) >>> from pygeodesy import ellipsoidalVincenty as eV >>> ll = u.toLatLon(eV.LatLon) # 48°51′29.52″N, 002°17′40.20″E ''' if self._latlon: return self._latlon5(LatLon) E = self._datum.ellipsoid # XXX vs LatLon.datum.ellipsoid x = self._easting - _FalseEasting # relative to central meridian y = self._northing if self._hemi == 'S': # relative to equator y -= _FalseNorthing # from Karney 2011 Eq 15-22, 36 A0 = _K0 * E.A if A0 < EPS: raise UTMError('%s invalid: %r' % ('meridional', E.A)) x /= A0 # η eta y /= A0 # ξ ksi Ks = _Kseries(E.BetaKs, x, y) # Krüger series y = -Ks.ys(-y) # ξ' x = -Ks.xs(-x) # η' shx = sinh(x) cy, sy = cos(y), sin(y) H = hypot(shx, cy) if H < EPS: raise UTMError('%s invalid: %r' % ('H', H)) T = t0 = sy / H # τʹ q = 1.0 / E.e12 d = 1 sd = Fsum(T) # toggles on +/-1.12e-16 eg. 31 N 400000 5000000 while abs(d) > EPS: # 1e-12 h = hypot1(T) s = sinh(E.e * atanh(E.e * T / h)) t = T * hypot1(s) - s * h d = (t0 - t) / hypot1(t) * (q + T**2) / h T = sd.fsum_(d) # τi a = atan(T) # lat b = atan2(shx, cy) + radians(_cmlon(self._zone)) ll = _LLEB(degrees90(a), degrees180(b), datum=self._datum, name=self.name) # convergence: Karney 2011 Eq 26, 27 p = -Ks.ps(-1) q = Ks.qs(0) ll._convergence = degrees(atan(tan(y) * tanh(x)) + atan2(q, p)) # scale: Karney 2011 Eq 28 ll._scale = E.e2s(sin(a)) * hypot1(T) * H * (A0 / E.a / hypot(p, q)) self._latlon = ll return self._latlon5(LatLon)
def yfun(t): return s_y_max / 2 * math.cosh(t / T_c) + T_c * vy_0 * math.sinh( t / T_c)
def acoth(x): return math.cosh(x) / math.sinh(x)
def xfun(t): return -s_x / 2 * math.cosh(t / T_c) + T_c * vx_0 * math.sinh(t / T_c)
'cbf', None, "test", None, params.distance, verbose=True, header_only=True) img = FormatCBFCspadInMemory(cbf) beam = BeamFactory.simple(params.wavelength).get_s0() beam_center = (0, 0) data = numpy.zeros((11840, 194)) if annulus: inner = params.distance * math.tan( 2 * math.sinh(params.wavelength / (2 * params.annulus_inner))) outer = params.distance * math.tan( 2 * math.sinh(params.wavelength / (2 * params.annulus_outer))) print "Inner (mm):", inner print "Outer (mm):", outer if params.resolution is not None: radius = params.distance * math.tan( 2 * math.sinh(params.wavelength / (2 * params.resolution))) print "Radius (mm):", radius print "Panel:", sys.stdout.flush() for p_id, panel in enumerate(img.get_detector()): print p_id, sys.stdout.flush() for y in xrange(185):
def get_com_locus(theta): s0 = 0.04 s_x = s0 * math.cos(theta) s_y = s0 * math.sin(theta) s_y_max = s_y / 2 + 0.12 s_y_min = -s_y / 2 + 0.12 z = 0.3 g = 9.8 T_c = math.sqrt(z / g) T = 1 vx_0 = s_x / 2 * (math.cosh(T / T_c) + 1) / (T_c * math.sinh(T / T_c)) vy_0 = (s_y_min / 2 - s_y_max / 2 * math.cosh(T / T_c)) / (T_c * math.sinh(T / T_c)) def xfun(t): return -s_x / 2 * math.cosh(t / T_c) + T_c * vx_0 * math.sinh(t / T_c) def yfun(t): return s_y_max / 2 * math.cosh(t / T_c) + T_c * vy_0 * math.sinh( t / T_c) # locus for steps with even number comx_b1 = [0.0] * N comy_b1 = [0.0] * N t_b1 = [0.0] * N for i in range(N): t_b1[i] = (i + 1) * T / (N - 1) comx_b1[i] = xfun(t_b1[i] - T / (N - 1)) comy_b1[i] = yfun(t_b1[i] - T / (N - 1)) locus_b1 = (comx_b1, comy_b1, t_b1) # Locus for steps with odd number comx_b2 = comx_b1 comy_b2 = comy_b1[-1::-1] t_b2 = t_b1 locus_b2 = (comx_b2, comy_b2, t_b2) # locus for the first step comx_s = [0.0] * N * 2 comy_s = [0.0] * N * 2 t_s = [0.0] * N * 2 def yfun_s(t): return (-vy_0 / (2 * T)**6 - 3 * s_y / 2 / (2 * T)**7) * t**7 + (3.5 * s_y / 2 / (2 * T)**6 + vy_0 / (2 * T)**5) * t**6 + 0.06 def xfun_s(t): if t > T: return s_x / 2 / math.cosh(T / T_c) * math.cosh((t - T) / T_c) else: return s_x / 2 / math.cosh(T / T_c) * (t / T)**2 for i in range(N * 2): t_s[i] = (i + 1) * 2 * T / (2 * N - 1) comy_s[i] = yfun_s(t_s[i] - 2 * T / (2 * N - 1)) comx_s[i] = xfun_s(t_s[i] - 2 * T / (2 * N - 1)) locus_s = (comx_s, comy_s, t_s) # locus for the last step comx_e = [-x for x in comx_s][-1::-1] comy_e = comy_s[-1::-1] locus_e = (comx_e, comy_e, t_s) return locus_b1, locus_b2, locus_s, locus_e pass
def exactFiFunc(x): return math.sinh(2 * x + 0.45)
def method_sinh(self, space, value): try: res = math.sinh(value) except OverflowError: res = rfloat.copysign(rfloat.INFINITY, value) return space.newfloat(res)
def num2deg(xtile, ytile, zoom): n = 2.0**zoom lon_deg = xtile / n * 360.0 - 180.0 lat_rad = math.atan(math.sinh(math.pi * (1 - 2 * ytile / n))) lat_deg = math.degrees(lat_rad) return (lat_deg, lon_deg)
epsilon = 0.00000001 maxIter = 50 print("Q1. Determinando o Comprimento de L através dos Métodos: \n") print("Método da Bisseção") (houveErro, raiz, k) = bissecao(l_bissecao, a, b, epsilon, maxIter, mostraTabela=True) if houveErro: print("O Método da Bisseção retornou um erro.") if raiz is not None: print("Raiz encontrada: %s" % raiz) L = 2 * raiz * sinh(50 / (2 * raiz)) print("Valor de L: %s" % L) #print("O número de iterações: %s"%k) ''' Raiz da Equação: 390.75826058909297 Interações: 28 E o Valor de L encontrado foi: 50.034117037925476 ''' def l_false_pos(x): return x * (cosh(50 / (2 * x)) - 1) - 0.80