def atan(self, x) -> complex: """ Returns the atan of the input, handles output in radians and degrees. """ if self.use_radians: return cmath.atan(x) else: return degrees(cmath.atan(x))
def angle(self): if (self.x > 0): angle = cmath.atan(self.y / self.x) elif (self.x < 0): angle = cmath.atan(self.y / self.x) + cmath.pi elif (self.x == 0 and self.y > 0): angle = 0.5 * cmath.pi elif (self.x == 0 and self.y < 0): angle = -0.5 * cmath.pi elif (self.x == 0 and self.y == 0): angle = 0 return angle
def form_factor(tau, phi_type): if phi_type == "scalar": if tau == 1.: # Return lim(tau --> 1.) return 1. else: return tau * ( 1. + (1. - tau) * cmath.atan(1. / cmath.sqrt(tau - 1.))**2) elif phi_type == "pseudoscalar": if tau == 1.: return (math.pi / 2.)**2 else: return tau * cmath.atan(1. / cmath.sqrt(tau - 1.))**2
def get_angle(top, bottom): dx = top[0] - bottom[0] dy = top[1] - bottom[1] if dx != 0: if dx < 0: return 270 + 180.0 / cmath.pi * cmath.atan(((float)(dy)) / dx) else: return 90 + 180.0 / cmath.pi * cmath.atan(((float)(dy)) / dx) else: if dx > 0: return 180 else: return 0
def atan2(y, x): if x > 0: return cmath.atan(y / x) elif x < 0: if y >= 0: return cmath.atan(y / x) + cmath.pi else: return cmath.atan(y / x) - cmath.pi else: if y > 0: return cmath.pi/2 elif y < 0: return -cmath.pi/2 else: return None
def test_complex_inverse_functions(): mp.dps = 15 iv.dps = 15 for (z1, z2) in random_complexes(30): # apparently cmath uses a different branch, so we # can't use it for comparison assert sinh(asinh(z1)).ae(z1) # assert acosh(z1).ae(cmath.acosh(z1)) assert atanh(z1).ae(cmath.atanh(z1)) assert atan(z1).ae(cmath.atan(z1)) # the reason we set a big eps here is that the cmath # functions are inaccurate assert asin(z1).ae(cmath.asin(z1), rel_eps=1e-12) assert acos(z1).ae(cmath.acos(z1), rel_eps=1e-12) one = mpf(1) for i in range(-9, 10, 3): for k in range(-9, 10, 3): a = 0.9 * j * 10**k + 0.8 * one * 10**i b = cos(acos(a)) assert b.ae(a) b = sin(asin(a)) assert b.ae(a) one = mpf(1) err = 2 * 10**-15 for i in range(-9, 9, 3): for k in range(-9, 9, 3): a = -0.9 * 10**k + j * 0.8 * one * 10**i b = cosh(acosh(a)) assert b.ae(a, err) b = sinh(asinh(a)) assert b.ae(a, err)
def pixelToMillimeterConversion(self, coordinate, RoeImage): fieldOfView = RoeImage.getFieldOfView() distance = RoeImage.getDistance() imageHeigth = RoeImage.getImage().heigth() imageWidth = RoeImage.getImage().width() # calculate length of diagonal of image in mm diagonalMillimeter = distance * math.tan( (fieldOfView / 2) * (math.pi / 180)) * 2 # calculate angle of diagonal theta = math.atan(imageHeigth / imageWidth) # calculate width of image in milimeter imageWidthMillimeter = math.cos(theta) * diagonalMillimeter # calculate heigth of image in millimeter imageHeigthInMillimeter = math.sin(theta) * diagonalMillimeter # calculate the size of a pixel in x directon in mm pixelSizeDirX = imageHeigthInMillimeter / imageHeigth # calculate the size of a pixel in y directon in mm pixelSizeDirY = imageWidthMillimeter / imageWidth xPositionMillimeter = coordinate.getxCoord() * pixelSizeDirY yPositionMillimeter = coordinate.getyCoord() * pixelSizeDirX millimeterCoordinate = Coordinate.Coordinate(xPositionMillimeter, yPositionMillimeter) RoeImage.addRoePositionMillimeter(millimeterCoordinate)
def angle(v): x = v[0] * 100 y = v[1] * 100 z = v[2] * 100 phi = math.atan(z / math.sqrt(x ** 2 + y ** 2)) theta = math.acos(x / math.sqrt(y ** 2 + x ** 2)) return (phi.real, theta.real)
def _phasor_argument(self, phasor): """Calculate the phasor argument. The phasor argument can be used to calculate the appropriate phase correction when transitioning between frequencies. """ return cmath.atan(phasor.imag / phasor.real).real
def test09_trig(): for i in range(-5, 5): for j in range(-5, 5): a = ek.sin(C(i, j)) b = C(cmath.sin(complex(i, j))) assert ek.allclose(a, b) a = ek.cos(C(i, j)) b = C(cmath.cos(complex(i, j))) assert ek.allclose(a, b) sa, ca = ek.sincos(C(i, j)) sb = C(cmath.sin(complex(i, j))) cb = C(cmath.cos(complex(i, j))) assert ek.allclose(sa, sb) assert ek.allclose(ca, cb) # Python appears to handle the branch cuts # differently from Enoki, C, and Mathematica.. a = ek.asin(C(i, j + 0.1)) b = C(cmath.asin(complex(i, j + 0.1))) assert ek.allclose(a, b) a = ek.acos(C(i, j + 0.1)) b = C(cmath.acos(complex(i, j + 0.1))) assert ek.allclose(a, b) if abs(j) != 1 or i != 0: a = ek.atan(C(i, j)) b = C(cmath.atan(complex(i, j))) assert ek.allclose(a, b, atol=1e-7)
def test_complex_inverse_functions(): mp.dps = 15 iv.dps = 15 for (z1, z2) in random_complexes(30): # apparently cmath uses a different branch, so we # can't use it for comparison assert sinh(asinh(z1)).ae(z1) # assert acosh(z1).ae(cmath.acosh(z1)) assert atanh(z1).ae(cmath.atanh(z1)) assert atan(z1).ae(cmath.atan(z1)) # the reason we set a big eps here is that the cmath # functions are inaccurate assert asin(z1).ae(cmath.asin(z1), rel_eps=1e-12) assert acos(z1).ae(cmath.acos(z1), rel_eps=1e-12) one = mpf(1) for i in range(-9, 10, 3): for k in range(-9, 10, 3): a = 0.9*j*10**k + 0.8*one*10**i b = cos(acos(a)) assert b.ae(a) b = sin(asin(a)) assert b.ae(a) one = mpf(1) err = 2*10**-15 for i in range(-9, 9, 3): for k in range(-9, 9, 3): a = -0.9*10**k + j*0.8*one*10**i b = cosh(acosh(a)) assert b.ae(a, err) b = sinh(asinh(a)) assert b.ae(a, err)
def get_theta(a, b, theta): dot = a[0] * b[0] + a[1] * b[1] + a[2] * b[2] cross = cmath.sqrt((a[1] * b[2] - a[2] * b[1]) * (a[1] * b[2] - a[2] * b[1]) + (a[2] * b[0] - a[0] * b[2]) * (a[2] * b[0] - a[0] * b[2]) + (a[0] * b[1] - a[1] * b[0]) * (a[0] * b[1] - a[1] * b[0])) if dot > 1: dot = 1 if dot < -1: dot = -1 cross = cross.real if cross > 1: cross = 1 if cross < -1: cross = -1 if dot == 0 and cross >= 0: theta[0] = cmath.pi / 2 elif dot == 0 and cross < 0: theta[0] = -cmath.pi / 2 else: theta[0] = cmath.atan(cross / dot).real
def check_intersect(r_a, d, tri): # all the stuff which is only surface-dependent (and not dependent on incoming direction) is # in the surface object tri. D = np.matlib.repmat(np.transpose([-d]), 1, tri.size).T pref = 1 / np.sum(D * tri.crossP, axis=1) corner = r_a - tri.P_0s t = pref * np.sum(tri.crossP * corner, axis=1) u = pref * np.sum(np.cross(tri.P_2s - tri.P_0s, D) * corner, axis=1) v = pref * np.sum(np.cross(D, tri.P_1s - tri.P_0s) * corner, axis=1) As = np.vstack((t, u, v)) which_intersect = (u + v <= 1) & (np.all(np.vstack((u, v)) >= -1e-10, axis=0)) & (t > 0) # get errors if set exactly to zero. if sum(which_intersect) > 0: t = t[which_intersect] P0 = tri.P_0s[which_intersect] P1 = tri.P_1s[which_intersect] P2 = tri.P_2s[which_intersect] ind = np.argmin(t) t = min(t) intersn = r_a + t * d N = np.cross(P1[ind] - P0[ind], P2[ind] - P0[ind]) N = N / np.linalg.norm(N) theta = atan(np.linalg.norm(np.cross(N, -d))/np.dot(N, -d)) # in radians, angle relative to plane return [intersn, theta, N] else: return False
def pixelToMillimeterConversion(self, coord, roe): fieldOfView = roe.getFieldOfView() distance = roe.getDistance() height, width, _ = roe.getImage().shape imageHeigth = height imageWidth = width # calculate length of diagonal of image in mm diagonalMillimeter = float(distance) * math.tan((fieldOfView / 2) * (math.pi / 180)) * 2 # calculate angle of diagonal theta = math.atan(imageHeigth / imageWidth) # calculate width of image in milimeter imageWidthMillimeter = math.cos(theta) * diagonalMillimeter # calculate heigth of image in millimeter imageHeigthInMillimeter = math.sin(theta) * diagonalMillimeter # calculate the size of a pixel in x directon in mm pixelSizeDirX = imageHeigthInMillimeter / imageHeigth # calculate the size of a pixel in y directon in mm pixelSizeDirY = imageWidthMillimeter / imageWidth xPositionMillimeter = coord.getxCoor() * pixelSizeDirX yPositionMillimeter = coord.getyCoor() * pixelSizeDirY millimeterCoordinate = coordinate(int(round(xPositionMillimeter.real, 2)), int(round(yPositionMillimeter.real, 2))) roe.addRoePositionMillimeter(millimeterCoordinate)
def robot3inv(x, y, z): x = 0.1 if x == 0 else x y = 0.1 if y == 0 else y z = 0.1 if z == 0 else z # geometrie du robot l1 = 16.0 l2 = 20.0 Cq2 = (x**2 + y**2 + z**2 - l1**2 - l2**2) / (2 * l1 * l2) q2 = -np.emath.arccos(Cq2) q1 = math.atan2(z, np.lib.scimath.sqrt(x**2 + y**2)) - cmath.atan( -l2 * np.lib.scimath.sqrt(1 - Cq2**2) / (l1 + l2 * Cq2)) q0 = -math.atan2(x, y) #passage en degre q2 = round((q2.real * 180 / math.pi)) # l_elbow_y q1 = -round(q1.real * 180 / math.pi) # l_shoulder_x q0 = round(q0.real * 180 / math.pi) # l_shoulder_y return q0, q1, q2
def PitchPhaseAng(self): """ Returns the phase angle of the pitching motion. Eq. 4.45, pg. 141 """ Pd = self.PitchDamp() return math.atan(math.sqrt(1 - Pd**2) / Pd)
def op_atan(x): """Returns the inverse tangent of this mathematical object.""" if isinstance(x, list): return [op_atan(a) for a in x] elif isinstance(x, complex): return cmath.atan(x) else: return math.atan(x)
def _CalcPitchAngle(self): """ Calculates the pitch angle """ d = self.D pitch = self.Pitch return (math.atan(pitch / (2 * self.RD * math.pi * d)).real) * RAD
def bformat(a, A, freq=[], s_pos=[]): #memory allocation output signals s_LF = np.zeros((np.size(freq)), dtype=np.complex_) s_LB = np.zeros((np.size(freq)), dtype=np.complex_) s_RB = np.zeros((np.size(freq)), dtype=np.complex_) s_RF = np.zeros((np.size(freq)), dtype=np.complex_) # capsule positions R = 0.0147 # radius of the tetrahedron in meters (according to Gerzon) tilt = ma.atan( 1 / ma.sqrt(2)) # tilt of the capsules in rad (according to Farrar) # spherical coordinates (r,teta,phi)=(radius,colatitude,azimuth) # in accordance with Faller and Farrar LFU = ([R, ma.pi / 2 - tilt, ma.pi / 4]) #left front up LBD = ([R, ma.pi / 2 + tilt, 3 * ma.pi / 4]) #left back down RBU = ([R, ma.pi / 2 - tilt, 5 * ma.pi / 4]) #right back up RFD = ([R, ma.pi / 2 + tilt, 7 * ma.pi / 4]) #right front down #distance of capsules to source d_LF = distance(*LFU, *s_pos) d_LB = distance(*LBD, *s_pos) d_RB = distance(*RBU, *s_pos) d_RF = distance(*RFD, *s_pos) #angle between capsule and source angLF = angle(*LFU, *s_pos) angLB = angle(*LBD, *s_pos) angRB = angle(*RBU, *s_pos) angRF = angle(*RFD, *s_pos) for ii in range(np.size(freq)): f = freq[ii] w = 2 * ma.pi * f c = 340 k = w / c #pressure at the capsules due to the source at s_pos p_LF = A * ma.exp(-1j * k * d_LF) p_LB = A * ma.exp(-1j * k * d_LB) p_RB = A * ma.exp(-1j * k * d_RB) p_RF = A * ma.exp(-1j * k * d_RF) #signals of the capsules s_LF[ii] = (a + a * ma.cos(angLF)) * p_LF s_LB[ii] = (a + a * ma.cos(angLB)) * p_LB s_RB[ii] = (a + a * ma.cos(angRB)) * p_RB s_RF[ii] = (a + a * ma.cos(angRF)) * p_RF #B-format signals W = s_LF + s_RB + s_RF + s_LB #omni X = s_LF - s_RB + s_RF - s_LB #f.o.e. forward (to positive x) Y = s_LF - s_RB - s_RF + s_LB #f.o.e. leftward (to positive y) Z = s_LF - s_LB + s_RB - s_RF #f.o.e. upward (to positive z) return W, X, Y, Z
def C_l(l, eta, z): F = coulombf(l, eta, z) G = coulombg(l, eta, z) P_l = 1/(F**2 + G**2) delta_l = -cmath.atan(F/G) ch = gamma(l +1 + j*eta) phi_l = cmath.phase(ch) return(sqrt(P_l*exp(j*(delta_l + phi_l))))
def acot(x): import math,cmath try: if deg_rad_var.get()==1: return math.atan(1/x) else: return math.degrees(math.atan(1/x)) except: return cmath.atan(1/x)
def B0(s, mq): if s==0.: return -2. if 4*mq**2/s == 1.: return 0. # to select the right branch of the complex arctangent, need to # interpret m^2 as m^2-i\epsilon iepsilon = 1e-8j return -2*sqrt(4*mq**2/s - 1) * atan(1/sqrt(4*(mq**2-iepsilon)/s - 1))
def get_phase_shift(fourier_output, sampled_frequency): signal_phase_shift = [] n = len(fourier_output) signal_phase_shift = [np.degrees(cmath.atan(x.imag / x.real).real) for x in fourier_output] x_values = _get_fourier_signal_xvals(sampled_frequency, n) return (x_values, signal_phase_shift)
def B0(s, mq): if s==0.: return -2. if 4*mq**2/s == 1.: return 0. # to select the right branch of the complex arctangent, need to # interpret m^2 as m^2-i\epsilon iepsilon = 1e-8j return -2*sqrt(4*(mq**2-iepsilon)/s - 1) * atan(1/sqrt(4*(mq**2-iepsilon)/s - 1))
def p_sine(t): '''e : SINE LP e RP | COSINE LP e RP | SECANT LP e RP | COSECANT LP e RP | TANGENT LP e RP | COTANGENT LP e RP | LOG LP e COMMA e RP | LN LP e RP | EXP POW LP e RP | ARCSINE LP e RP | ARCCOSINE LP e RP | ARCTANGENT LP e RP | SINEH LP e RP | COSINEH LP e RP | TANGENTH LP e RP | ARCSINEH LP e RP | ARCCOSINEH LP e RP | ARCTANGENTH LP e RP ''' if t[1] == 'sin': t[0] = cmath.sin(t[3]) elif t[1] == 'cos': t[0] = cmath.cos(t[3]) elif t[1] == 'sec': t[0] = 1/cmath.cos(t[3]) elif t[1] == 'cosec': t[0] = 1/cmath.sin(t[3]) elif t[1] == 'tan': t[0] = cmath.tan(t[3]) elif t[1] == 'cot': t[0] = 1/cmath.tan(t[3]) elif t[1] == 'log': t[0] = cmath.log(t[3], t[5]) elif t[1] == 'ln': t[0] = cmath.log(t[3], cmath.e) elif t[1] == 'e': t[0] = cmath.exp(t[4]) elif t[1] == 'asin': t[0] = cmath.asin(t[3]) elif t[1] == 'acos': t[0] = cmath.acos(t[3]) elif t[1] == 'atan': t[0] = cmath.atan(t[3]) elif t[1] == 'sinh': t[0] = cmath.sinh(t[3]) elif t[1] == 'cosh': t[0] = cmath.cosh(t[3]) elif t[1] == 'tanh': t[0] = cmath.tanh(t[3]) elif t[1] == 'asinh': t[0] = cmath.asinh(t[3]) elif t[1] == 'acosh': t[0] = cmath.acosh(t[3]) elif t[1] == 'atanh': t[0] = cmath.atanh(t[3])
def atan(*args, **kw): arg0 = args[0] if isinstance(arg0, (int, float, long)): return _math.atan(*args,**kw) elif isinstance(arg0, complex): return _cmath.atan(*args,**kw) elif isinstance(arg0, _sympy.Basic): return _sympy.atan(*args,**kw) else: return _numpy.atan(*args,**kw)
def update(val): #se ejecuta cada vez que movamos un slider. Llama a las dos anteriores y actualiza el gráfico. nrd = snr.val ncd = snc.val a=(cm.atan(nrd+ncd*1j).real*180/m.pi) plt.title("Angulo de polarizacion "+"%.2f grados" % a, loc='right') l.set_ydata(data1(nrd, ncd)) l2.set_ydata(dataR(nrd, ncd)) fig.canvas.draw_idle()
def atan(*args, **kw): arg0 = args[0] if isinstance(arg0, (int, float, long)): return _math.atan(*args,**kw) elif isinstance(arg0, complex): return _cmath.atan(*args,**kw) elif isinstance(arg0, _sympy.Basic): return _sympy.atan(*args,**kw) else: return _numpy.arctan(*args,**kw)
def ATAN(df, price='Close'): """ Arc Tangent """ atan_list = [] i = 0 while i < len(df[price]): atan = cmath.atan(df[price][i]).real atan_list.append(atan) i += 1 return atan_list
def create_link(self,exp_from,exp_to): dij=math.sqrt(self.accum_delta_x**2+self.accum_delta_y**2) th_ij=atan(self.accum_delta_y/self.accum_delta_x) l=Link() l.d=dij l.heading_rad=th_ij l.exp_from_id=exp_from l.exp_to_id=exp_to self.links.append(l) self.accum_delta_x=0 self.accum_delta_y=0
def asSpherical(xyz): # print('asSpherical\n:',np.shape(xyz)) # takes list xyz (single coord) x = xyz[0] y = xyz[1] z = xyz[2] r = vec_mag(xyz) theta = cmath.acos(z / r) # phi = np.arctan2(y,x) phi = cmath.atan(y / x) return [r, theta, phi]
def B0(s, mq): flavio.citations.register("Beneke:2001at") if s == 0.: return -2. if 4 * mq**2 / s == 1.: return 0. # to select the right branch of the complex arctangent, need to # interpret m^2 as m^2-i\epsilon iepsilon = 1e-8j return -2 * sqrt(4 * (mq**2 - iepsilon) / s - 1) * atan( 1 / sqrt(4 * (mq**2 - iepsilon) / s - 1))
def calc(self): ''' Calculates the dihedral of the strut from its y and z positions ''' zTip = self.parent.zTip.getValue() zRoot = self.parent.zRoot.getValue() yRoot = self.parent.yRoot.getValue() yTip = self.parent.yTip.getValue() dz = zRoot - zTip dy = yRoot - yTip return self.setValueCalc(atan(dz/dy)*180/pi)
def calc(self): """ Calculates the trailing edge sweep angle from leading edge angle, semispan and root and tip Chord """ cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() cTip = self.parent.cTip.getValue() b2 = self.parent.span.getValue() / 2.0 x1 = (tan(phiLE * rad) * b2 + cTip) - cRoot return self.setValueCalc(atan(x1 / b2) / rad)
def calc(self): ''' Calculates the dihedral of the strut from its y and z positions ''' zTip = self.parent.zTip.getValue() zRoot = self.parent.zRoot.getValue() yRoot = self.parent.yRoot.getValue() yTip = self.parent.yTip.getValue() dz = zRoot - zTip dy = yRoot - yTip return self.setValueCalc(atan(dz / dy) * 180 / pi)
def calc(self): ''' Calculates the trailing edge sweep angle from leading edge angle, semispan and root and tip Chord ''' cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() cTip = self.parent.cTip.getValue() b2 = self.parent.span.getValue() / 2. x1 = (tan(phiLE * rad) * b2 + cTip) - cRoot return self.setValueCalc(90. - atan(b2 / x1) / rad)
def oneArgFuncEval(function, value): # Evaluates functions that take a complex number input if function == "sin": return cmath.sin(value) elif function == "cos": return cmath.cos(value) elif function == "tan": return cmath.tan(value) elif function == "asin": return cmath.asin(value) elif function == "acos": return cmath.acos(value) elif function == "atan": return cmath.atan(value) elif function == "csc": return 1.0 / cmath.sin(value) elif function == "sec": return 1.0 / cmath.cos(value) elif function == "cot": return 1.0 / cmath.tan(value) elif function == "ln": return cmath.log(value) elif function == "sqr": return cmath.sqrt(value) elif function == "abs": return cmath.sqrt((value.real ** 2) + (value.imag ** 2)) elif function == "exp": return cmath.exp(value) if function == "sinh": return cmath.sinh(value) elif function == "cosh": return cmath.cosh(value) elif function == "tanh": return cmath.tanh(value) elif function == "asinh": return cmath.asinh(value) elif function == "acosh": return cmath.acosh(value) elif function == "atanh": return cmath.atanh(value) elif function == "ceil": return math.ceil(value.real) + complex(0, 1) * math.ceil(value.imag) elif function == "floor": return math.floor(value.real) + complex(0, 1) * math.floor(value.imag) elif function == "trunc": return math.trunc(value.real) + complex(0, 1) * math.trunc(value.imag) elif function == "fac": if value.imag == 0 and value < 0 and value.real == int(value.real): return "Error: The factorial function is not defined on the negative integers." return gamma(value + 1) elif function == "log": return cmath.log10(value)
def h(s, mq, mu): """Fermion loop function as defined e.g. in eq. (11) of hep-ph/0106067v2.""" if mq == 0.: return 8/27. + (4j*pi)/9. + (8 * log(mu))/9. - (4 * log(s))/9. if s == 0.: return -4/9. * (1 + log(mq**2/mu**2)) z = 4 * mq**2/s if z > 1: A = atan(1/sqrt(z-1)) else: A = log((1+sqrt(1-z))/sqrt(z)) - 1j*pi/2. return (-4/9. * log(mq**2/mu**2) + 8/27. + 4/9. * z -4/9. * (2 + z) * sqrt(abs(z - 1)) * A)
def atan(self,command_position,args): try: if type(self.stack[command_position+1])==complex: value=cmath.atan(self.stack[command_position+1]) else: value=math.atan(self.stack[command_position+1]) self.stack.pop(command_position+1) self.stack[command_position]=value return command_position except: self.statstrings.append("Bad arc tangent attempted, ignoring command") self.error=True self.stack.pop(command_position) return command_position
def calc(self): ''' Calculates the trailing edge sweep angle from leading edge angle, semispan and root and tip Chord ''' cRoot = self.parent.cRoot.getValue() phiLE = self.parent.phiLE.getValue() cTip = self.parent.cTip.getValue() b2 = self.parent.span.getValue() x1 = (tan(phiLE * rad) * b2 + cTip) - cRoot return self.setValueCalc(90. - atan(b2 / x1) / rad) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def atan(y): """Compute ArcTan using Newton method x=f(y); y=g(x) x0=f(y0); x0=x0 +(y-g(x0))/g'(x) >>> from pol import * >>> p=pol('.4+x+y') >>> print tan(atan(p)) 0.4 + x + y >>> print atan(tan(p)) 0.4 + x + y """ x0=pol(math.atan(y.zero())) for i in range(y.order): x0=x0 + (y-tan(x0))*cos(x0)**2 return x0
def atan(x): """ Return the arc tangent of x, in radians """ if isinstance(x,ADF): ad_funcs = list(map(to_auto_diff,[x])) x = ad_funcs[0].x ######################################## # Nominal value of the constructed ADF: f = atan(x) ######################################## variables = ad_funcs[0]._get_variables(ad_funcs) if not variables or isinstance(f, bool): return f ######################################## # Calculation of the derivatives with respect to the arguments # of f (ad_funcs): lc_wrt_args = [1/(x**2 + 1)] qc_wrt_args = [-2*x/(x**4 + 2*x**2 + 1)] cp_wrt_args = 0.0 ######################################## # Calculation of the derivative of f with respect to all the # variables (Variable) involved. lc_wrt_vars,qc_wrt_vars,cp_wrt_vars = _apply_chain_rule( ad_funcs,variables,lc_wrt_args,qc_wrt_args, cp_wrt_args) # The function now returns an ADF object: return ADF(f, lc_wrt_vars, qc_wrt_vars, cp_wrt_vars) else: # try: # pythonic: fails gracefully when x is not an array-like object # return [atan(xi) for xi in x] # except TypeError: if x.imag: return cmath.atan(x) else: return math.atan(x.real)
def calc(self): ''' Calculates the leading edge sweep from quarter sweep, aspect ratio and taper ratio :Source: Aircraft Design: A Conceptual Approach, D. P. Raymer, AIAA Education Series, 1992, Second Edition, p.48 ''' self.setDeviation(0.0335) # needs to be set by the calc method when called for later use (deviation depends on the calc method) aspectRatio = self.parent.aspectRatio.getValue() phi25 = self.parent.phi25.getValue() taperRatio = self.parent.taperRatio.getValue() return self.setValueCalc(atan(tan(phi25 * rad) + ((1 - taperRatio) / (aspectRatio * (1 + taperRatio)))) / rad) ################################################################################################### #EOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFEOFE# ###################################################################################################
def calc_articulation_angle(wheel_position, arc_center, go_forward): adjacent = wheel_position[0]-arc_center[0] # tangent = cmath.pi articulation_theta = 90 if not go_forward: if adjacent != 0: opposite = wheel_position[1]-arc_center[1] tangent = opposite/float(adjacent) articulation_theta = cmath.atan(tangent) articulation_theta = articulation_theta/cmath.pi*180 return articulation_theta.real
def calc(self): """ Calculates the 50% chord sweep from geometrical dimensions of a trapezoid wing """ span = self.parent.span.getValue() phiLE = self.parent.phiLE.getValue() cRoot = self.parent.cRoot.getValue() cTip = self.parent.cTip.getValue() span = span / 2.0 xRoot = cRoot * 0.5 xTip = cTip * 0.5 + tan(phiLE * rad) * span d = xTip - xRoot return self.setValueCalc(atan(d / span) / rad)
def robot3inv(x,y,z): x=0.1 if x==0 else x y=0.1 if y==0 else y z=0.1 if z==0 else z # geometrie du robot l1=16.0 l2=20.0 Cq2 = (x**2 + y**2 + z**2 - l1**2 - l2**2)/(2*l1*l2) q2=-np.emath.arccos(Cq2) q1=math.atan2(z,np.lib.scimath.sqrt(x**2 + y**2))-cmath.atan(-l2*np.lib.scimath.sqrt(1-Cq2**2)/(l1+l2*Cq2)) q0=-math.atan2(x,y) #passage en degre q2 = round((q2.real*180/math.pi)); # l_elbow_y q1 = -round(q1.real*180/math.pi); # l_shoulder_x q0 = round(q0.real*180/math.pi); # l_shoulder_y return q0,q1,q2
def calc(self): """ Calculates the volume of the cabin under the assumption of a constant cross section :Source: Productivity Metrics for Business and Regional Aircraft, Isikveren, A. T.,Goritschnig, G., Noel, M., SAE International, 2003, eq 3.2-3.4 """ # ======================================================================= # Imports # ======================================================================= hs = self.parent.zFloor.getValue() hcabin = self.parent.hcabin.getValue() wcabin = self.parent.dcabin.getValue() wfloor = self.parent.yFloor.getValue() lcabin = self.parent.lcabin.getValue() # ======================================================================= # Calculation # ======================================================================= sigma = atan(2.0 * hs / wfloor) vcabin = lcabin / 4.0 * (wcabin * (pi * hcabin - sigma * wcabin) + hs * (2 * wfloor - pi * wcabin)) return self.setValueCalc(vcabin)
def atan_usecase(x): return cmath.atan(x)
def acot(x): return pi/2.-atan(x)
print('Positive Complex infinity =', cmath.infj) print('NaN =', cmath.nan) print('NaN Complex =', cmath.nanj) # power and log functions c = 2 + 2j print('e^c =', cmath.exp(c)) print('log2(c) =', cmath.log(c, 2)) print('log10(c) =', cmath.log10(c)) print('sqrt(c) =', cmath.sqrt(c)) # trigonometric functions c = 2 + 2j print('arc sine =', cmath.asin(c)) print('arc cosine =', cmath.acos(c)) print('arc tangent =', cmath.atan(c)) print('sine =', cmath.sin(c)) print('cosine =', cmath.cos(c)) print('tangent =', cmath.tan(c)) # hyperbolic functions c = 2 + 2j print('inverse hyperbolic sine =', cmath.asinh(c)) print('inverse hyperbolic cosine =', cmath.acosh(c)) print('inverse hyperbolic tangent =', cmath.atanh(c)) print('hyperbolic sine =', cmath.sinh(c)) print('hyperbolic cosine =', cmath.cosh(c)) print('hyperbolic tangent =', cmath.tanh(c))
n = len(points) A = np.ones([n + 1, 3]) for i in range(n): A[i, 0] = points[i][0] A[i, 1] = points[i][1] maxx = np.max(A[:, 0]) maxy = np.max(A[:, 1]) x = np.linspace(-(maxx + 5), (maxx + 5), 200) y = m * x + c plt.figure() plt.plot(x, y) xl = plt.xlim([-(maxx + 5), (maxx + 5)]) yl = plt.ylim([-(maxy + 5), (maxy + 5)]) plt.hold("on") # plt.Line2D([0,0],xl); theta = -cm.atan(m) Tr = np.matrix([[1, 0, 0], [0, 1, 0], [0, -c, 1]]) Ro = np.matrix([[np.cos(theta), np.sin(theta), 0], [-np.sin(theta), np.cos(theta), 0], [0, 0, 1]]) Re = np.matrix([[1.0, 0, 0], [0, -1.0, 0], [0, 0, 1.0]]) Roi = lg.inv(Ro) Tri = lg.inv(Tr) T = Tr * Ro * Re * Roi * Tri A_n = A * T A[n, 0] = A[0, 0] A[n, 1] = A[0, 1] A_n[n, 0] = A_n[0, 0] A_n[n, 1] = A_n[0, 1] plt.hold("on") plt.plot(A[:, 0], A[:, 1]) plt.hold("on") plt.plot(A_n[:, 0], A_n[:, 1])
def test_atan(self): self.assertAlmostEqual(complex(1.44831, 0.158997), cmath.atan(complex(3, 4)))
def rpn_calc(input, angle_mode = 0): global stack single_arg_funcs = ['exp','sqrt','sin','asin','cos','acos','tan','atan', 'sinh','asinh','cosh','acosh','tanh', 'atanh','!', 'polar'] num, arg, option = parse(input) #print(num, arg, option) #print('\n') if arg == None and (num != None or num != 'Error'): config.stack.append(num) history.append('Entered number: ' + str(num) ) return config.stack # Simple arithmatic----------------------------------------------------------------------- if option == None and num != None: if arg not in single_arg_funcs: last = config.stack.pop() if arg == '+': try: result = Decimal(last) + Decimal(num) hist = str(last) + '+' + str(num) + '=' + str(result) except TypeError: result = last + num hist = str(last) + '+' + str(num) + '=' + str(result) if arg == '-': try: result = Decimal(last) - Decimal(num) hist = str(last) + '-' + str(num) + '=' + str(result) except TypeError: result = last - num hist = str(last) + '-' + str(num) + '=' + str(result) if arg == '*': try: result = Decimal(last) * Decimal(num) hist = str(last) + '*' + str(num) + '=' + str(result) except TypeError: result = last * num hist = str(last) + '*' + str(num) + '=' + str(result) if arg == '/': try: result = Decimal(last) / Decimal(num) hist = str(last) + '/' + str(num) + '=' + str(result) except TypeError: result = last / num hist = str(last) + '/' + str(num) + '=' + str(result) if arg == '**': try: result = pow(Decimal(last), Decimal(num) ) hist = str(last) + '**' + str(num) + '=' + str(result) except TypeError: result = last ** num hist = str(last) + '**' + str(num) + '=' + str(result) if arg == 'rt': try: result = root(Decimal(last), Decimal(num) ) hist = str(last) + 'raised to 1 over ' + str(num) + '=' + str(result) except TypeError: result = root(last + num) hist = str(last) + 'raised to 1 over ' + str(num) + '=' + str(result) if arg == '%': try: result = Decimal(last) % Decimal(num) hist = str(last) + '%' + str(num) + '=' + str(result) except TypeError: result = last % num hist = str(last) + '%' + str(num) + '=' + str(result) if arg == '!': try: result = Decimal(math.factorial(num)) hist = str(num) + '!' + '=' + str(result) except TypeError: result = math.factorial(num) hist = str(num) + '!' + '=' + str(result) if arg == 'exp': try: result = math.exp(Decimal(num)) hist = str(num) + 'exp' + '=' + str(result) except ValueError: result = cmath.exp(Decimal(num)) hist = str(num) + 'exp' + '=' + str(result) except TypeError: result = cmath.exp(num) hist = str(num) + 'exp' + '=' + str(result) if arg == 'sqrt': try: result = math.sqrt(Decimal(num)) hist = str(num) + 'sqrt' + '=' + str(result) except ValueError: result = cmath.sqrt(Decimal(num)) hist = str(num) + 'sqrt' + '=' + str(result) except TypeError: result = cmath.sqrt(num) hist = str(num) + 'sqrt' + '=' + str(result) if arg == 'log': try: result = math.log10(Decimal(num)) hist = str(num) + 'log10' + '=' + str(result) except ValueError: result = cmath.log10(Decimal(num)) hist = str(num) + 'log10' + '=' + str(result) except TypeError: result = cmath.log10(num) hist = str(num) + 'log10' + '=' + str(result) #================================= if arg == 'ln': try: result = math.log(Decimal(num)) hist = str(num) + 'ln' + '=' + str(result) except ValueError: result = cmath.log(Decimal(num)) hist = str(num) + 'ln' + '=' + str(result) except TypeError: result = cmath.log(num) hist = str(num) + 'ln' + '=' + str(result) #--------TRIG-------------------------------- if arg == 'sin': if angle_mode == 1: try: result = math.sin(Decimal(num)) hist = 'sin' + str(num) + '=' + str(result) except TypeError: result = cmath.sin(num) hist = 'sin' + str(num) + '=' + str(result) elif angle_mode == 0: try: result = math.sin(math.radians(Decimal(num))) hist = 'sin' + str(num) + '=' + str(result) except TypeError: result = cmath.sin(num) hist = 'sin' + str(num) + '=' + str(result) if arg == 'cos': if angle_mode == 1: try: result = math.cos(Decimal(num)) hist = 'cos' + str(num) + '=' + str(result) except TypeError: result = cmath.cos(num) hist = 'cos' + str(num) + '=' + str(result) elif angle_mode == 0: try: result = math.cos(math.radians(Decimal(num))) hist = 'cos' + str(num) + '=' + str(result) except TypeError: result = cmath.cos(num) hist = 'cos' + str(num) + '=' + str(result) if arg == 'tan': if angle_mode == 1: try: result = math.tan(Decimal(num)) hist = 'tan' + str(num) + '=' + str(result) except TypeError: result = cmath.tan(num) hist = 'tan' + str(num) + '=' + str(result) elif angle_mode == 0: try: result = math.tan(math.radians(Decimal(num))) hist = 'tan' + str(num) + '=' + str(result) except TypeError: result = cmath.tan(num) hist = 'tan' + str(num) + '=' + str(result) if arg == 'asin': if angle_mode == 1: try: result = math.asin(Decimal(num)) hist = 'asin' + str(num) + '=' + str(result) except TypeError: result = cmath.asin(num) hist = 'asin' + str(num) + '=' + str(result) elif angle_mode == 0: try: result = math.asin(math.radians(Decimal(num))) hist = 'asin' + str(num) + '=' + str(result) except TypeError: result = cmath.asin(num) hist = 'asin' + str(num) + '=' + str(result) if arg == 'acos': if angle_mode == 1: try: result = math.acos(Decimal(num)) hist = 'acos' + str(num) + '=' + str(result) except TypeError: result = cmath.acos(num) hist = 'acos' + str(num) + '=' + str(result) elif angle_mode == 0: try: result = math.acos(math.radians(Decimal(num))) hist = 'acos' + str(num) + '=' + str(result) except TypeError: result = cmath.acos(num) hist = 'acos' + str(num) + '=' + str(result) if arg == 'atan': if angle_mode == 1: try: result = math.atan(Decimal(num)) hist = 'atan' + str(num) + '=' + str(result) except TypeError: result = cmath.atan(num) hist = 'atan' + str(num) + '=' + str(result) elif angle_mode == 0: try: result = math.atan(math.radians(Decimal(num))) hist = 'atan' + str(num) + '=' + str(result) except TypeError: result = cmath.atan(num) hist = 'atan' + str(num) + '=' + str(result) if arg == 'sinh': try: result = math.sinh(Decimal(num)) hist = 'sinh' + str(num) + '=' + str(result) except TypeError: result = cmath.sinh(num) hist = 'sinh' + str(num) + '=' + str(result) if arg == 'cosh': try: result = math.cosh(Decimal(num)) hist = 'cosh' + str(num) + '=' + str(result) except TypeError: result = cmath.cosh(num) hist = 'cosh' + str(num) + '=' + str(result) if arg == 'tanh': try: result = math.tanh(Decimal(num)) hist = 'tanh' + str(num) + '=' + str(result) except TypeError: result = cmath.tanh(num) hist = 'tanh' + str(num) + '=' + str(result) if arg == 'asinh': try: result = math.asinh(Decimal(num)) hist = 'asinh' + str(num) + '=' + str(result) except TypeError: result = cmath.asinh(num) hist = 'asinh' + str(num) + '=' + str(result) if arg == 'acosh': try: result = math.acosh(Decimal(num)) hist = 'acosh' + str(num) + '=' + str(result) except TypeError: result = cmath.acosh(num) hist = 'acosh' + str(num) + '=' + str(result) if arg == 'atanh': try: result = math.atanh(Decimal(num)) hist = 'atanh' + str(num) + '=' + str(result) except TypeError: result = cmath.atanh(num) hist = 'atanh' + str(num) + '=' + str(result) if arg == 'rect': #continue here.... try: result = rect(last, num) hist = 'Convert ' + str(last) + ',' + str(num) + ' to rectangular coords.' except TypeError: result = 'Error' hist = 'Error in attempted conversion to rectangular coords. No result.' if arg == 'polar': try: result = polar(num) hist = 'Convert ' + str(num) + ' to polar coords.' except TypeError: result = 'Error' hist = 'Error in attempted conversion to polar coords. No result.' config.stack.append(result) history.append(hist) return config.stack #======================================================================================================================= #----Only argument passed----------------------------------------------------------------------------------------------- #======================================================================================================================= elif option == None and num == None: last = config.stack.pop() if arg not in single_arg_funcs: try: n_minus1 = config.stack.pop() except IndexError: try: config.stack.append(Decimal(last)) except TypeError: config.stack.append(last) except TypeError: config.stack.append(last) except Exception as e: return 'Error' if arg == '+': try: result = Decimal(n_minus1) + Decimal(last) hist = str(n_minus1) + '+' + str(last) + '=' + str(result) except TypeError: result = n_minus1 + last hist = str(n_minus1) + '+' + str(last) + '=' + str(result) if arg == '-': try: result = Decimal(n_minus1) - Decimal(last) hist = str(n_minus1) + '-' + str(last) + '=' + str(result) except TypeError: result = n_minus1 - last hist = str(n_minus1) + '-' + str(last) + '=' + str(result) if arg == '*': try: result = Decimal(n_minus1) * Decimal(last) hist = str(n_minus1) + '*' + str(last) + '=' + str(result) except TypeError: result = n_minus1 * last hist = str(n_minus1) + '*' + str(last) + '=' + str(result) if arg == '/': try: result = Decimal(n_minus1) / Decimal(last) hist = str(n_minus1) + '/' + str(last) + '=' + str(result) except TypeError: result = n_minus1 / last hist = str(n_minus1) + '/' + str(last) + '=' + str(result) if arg == '!': try: result = Decimal(math.factorial(last)) hist = str(last) + '!' '=' + str(result) except TypeError: result = math.factorial(last) hist = str(last) + '!' '=' + str(result) except OverflowError: config.stack.append(last) hist = str('Factorial overflow error, no result.') return 'Error' if arg == '**': try: result = pow(Decimal(last), Decimal(last)) hist = str(n_minus1) + '**' + str(last) + '=' + str(result) except TypeError: result = last ** last hist = str(n_minus1) + '**' + str(last) + '=' + str(result) if arg == 'log': try: result = math.log10(Decimal(last)) hist = str(last) +'log10' + '=' + str(result) except ValueError: result = cmath.log10(Decimal(last)) hist = str(last) +'log10' + '=' + str(result) except TypeError: result = cmath.log10(last) hist = str(last) +'log10' + '=' + str(result) if arg == 'ln': try: result = math.log(Decimal(last)) hist = str(last) +'ln' + '=' + str(result) except ValueError: result = cmath.log(Decimal(last)) hist = str(last) +'ln' + '=' + str(result) except TypeError: result = cmath.log(last) hist = str(last) +'ln' + '=' + str(result) if arg == 'rt': try: result = root(Decimal(last), Decimal(n_minus1)) hist = str(n_minus1) + 'root' + str(last) + '=' + str(result) except TypeError: result = root(last), (n_minus1) hist = str(n_minus1) + 'root' + str(last) + '=' + str(result) if arg == 'exp': try: result = math.exp(Decimal(last)) hist = str(last) +'exp' + '=' + str(result) except TypeError: result = cmath.exp(last) hist = str(last) +'exp' + '=' + str(result) if arg == 'sqrt': try: result = math.sqrt(Decimal(last)) hist = 'Square root of ' + str(last) + '=' + str(result) except ValueError: result = cmath.sqrt(Decimal(last)) hist = 'Square root of ' + str(last) + '=' + str(result) except TypeError: result = cmath.sqrt(last) hist = 'Square root of ' + str(last) + '=' + str(result) #----------Trig---------------------------------------- #--------TRIG-------------------------------- if arg == 'sin': if angle_mode == 1: try: result = math.sin(Decimal(last)) hist = 'sin' + str(last) + '=' + str(result) except TypeError: result = cmath.sin(last) hist = 'sin' + str(last) + '=' + str(result) elif angle_mode == 0: try: result = math.sin(math.radians(Decimal(last))) hist = 'sin' + str(last) + '=' + str(result) except TypeError: result = cmath.sin(last) hist = 'sin' + str(last) + '=' + str(result) if arg == 'cos': if angle_mode == 1: try: result = math.cos(Decimal(last)) hist = 'cos' + str(last) + '=' + str(result) except TypeError: result = cmath.cos(last) hist = 'cos' + str(last) + '=' + str(result) elif angle_mode == 0: try: result = math.cos(math.radians(Decimal(last))) hist = 'cos' + str(last) + '=' + str(result) except TypeError: result = cmath.cos(last) hist = 'cos' + str(last) + '=' + str(result) if arg == 'tan': if angle_mode == 1: try: result = math.tan(Decimal(last)) hist = 'tan' + str(last) + '=' + str(result) except TypeError: result = cmath.tan(last) hist = 'tan' + str(last) + '=' + str(result) elif angle_mode == 0: try: result = math.tan(math.radians(Decimal(last))) hist = 'tan' + str(last) + '=' + str(result) except TypeError: result = cmath.tan(last) hist = 'tan' + str(last) + '=' + str(result) if arg == 'asin': if angle_mode == 1: try: result = math.asin(Decimal(last)) hist = 'asin' + str(last) + '=' + str(result) except TypeError: result = cmath.asin(last) hist = 'asin' + str(last) + '=' + str(result) elif angle_mode == 0: try: result = math.asin(math.radians(Decimal(last))) hist = 'asin' + str(last) + '=' + str(result) except TypeError: result = cmath.asin(last) hist = 'asin' + str(last) + '=' + str(result) if arg == 'acos': if angle_mode == 1: try: result = math.acos(Decimal(last)) hist = 'acos' + str(last) + '=' + str(result) except TypeError: result = cmath.acos(last) hist = 'acos' + str(last) + '=' + str(result) elif angle_mode == 0: try: result = math.acos(math.radians(Decimal(last))) hist = 'acos' + str(last) + '=' + str(result) except TypeError: result = cmath.acos(last) hist = 'acos' + str(last) + '=' + str(result) if arg == 'atan': if angle_mode == 1: try: result = math.atan(Decimal(last)) hist = 'atan' + str(last) + '=' + str(result) except TypeError: result = cmath.atan(last) hist = 'atan' + str(last) + '=' + str(result) elif angle_mode == 0: try: result = math.atan(math.radians(Decimal(last))) hist = 'atan' + str(last) + '=' + str(result) except TypeError: result = cmath.atan(last) hist = 'atan' + str(last) + '=' + str(result) if arg == 'sinh': try: result = math.sinh(Decimal(last)) hist = 'sinh' + str(last) + '=' + str(result) except TypeError: result = math.sinh(last) hist = 'sinh' + str(last) + '=' + str(result) if arg == 'cosh': try: result = math.cosh(Decimal(last)) hist = 'cosh' + str(last) + '=' + str(result) except TypeError: result = math.cosh(last) hist = 'cosh' + str(last) + '=' + str(result) if arg == 'tanh': try: result = math.tanh(Decimal(last)) hist = 'tanh' + str(last) + '=' + str(result) except TypeError: result = math.tanh(last) hist = 'tanh' + str(last) + '=' + str(result) if arg == 'asinh': try: result = math.asinh(Decimal(last)) hist = 'asinh' + str(last) + '=' + str(result) except TypeError: result = math.asinh(last) hist = 'asinh' + str(last) + '=' + str(result) if arg == 'acosh': try: result = math.acosh(Decimal(last)) hist = 'acosh' + str(last) + '=' + str(result) except TypeError: result = math.acosh(last) hist = 'acosh' + str(last) + '=' + str(result) if arg == 'atanh': try: result = math.atanh(Decimal(last)) hist = 'atanh' + str(last) + '=' + str(result) except TypeError: result = math.atanh(last) hist = 'atanh' + str(last) + '=' + str(result) if arg == 'rect': #continue here.... try: result = rect(n_minus1, last) hist = 'Convert ' + str(n_minus1) + ',' + str(last) + ' to rectangular coords.' except TypeError: result = 'Error' hist = 'Error in attempted conversion to rectangular coords. No result.' if arg == 'polar': try: result = polar(last) hist = 'Convert complex value ' + str(last) + ' to rectangular coords.' except TypeError: result = 'Error' hist = 'Error in attempted conversion to polar coords. No result.' config.stack.append(result) history.append(hist) return config.stack
'ceil': lambda x: ceil(x), 'point': lambda x: x/(10 ** floor(1+log(x)/log(10))) } complex_functions = {'sin': lambda x: cmath.sin(x), 'cos': lambda x: cmath.cos(x), 'tan': lambda x: cmath.tan(x), 'csc': lambda x: 1/cmath.sin(x), 'sec': lambda x: 1/cmath.cos(x), 'cot': lambda x: 1/cmath.tan(x), 'ln': lambda x: cmath.log(x), 'log': lambda x: cmath.log(x)/cmath.log(10), 'fact': lambda x: factorial(int(x)), 'asin': lambda x: cmath.asin(x), 'acos': lambda x: cmath.acos(x), 'atan': lambda x: cmath.atan(x), 'acsc': lambda x: cmath.asin(1/x), 'asec': lambda x: cmath.acos(1/x), 'acot': lambda x: cmath.atan(1/x), 'sinh': lambda x: cmath.sinh(x), 'cosh': lambda x: cmath.cosh(x), 'tanh': lambda x: cmath.tanh(x), 'csch': lambda x: 1/cmath.sinh(x), 'sech': lambda x: 1/cmath.cosh(x), 'coth': lambda x: 1/cmath.tanh(x), 'asinh': lambda x: cmath.asinh(x), 'acosh': lambda x: cmath.acosh(x), 'atanh': lambda x: cmath.atanh(x), 'acsch': lambda x: cmath.asinh(1/x), 'asech': lambda x: cmath.acosh(1/x), 'acoth': lambda x: cmath.atanh(1/x)
def atan(a, b): result = a**2 + b**2 return cmath.atan(result) + 1.6j
import cmath ab = input() bc = input() angle = cmath.atan(float(ab)/bc)*180/cmath.pi print str(int(round(angle.real))) + '°'
def testAtanSign(self): for z in complex_zeros: self.assertComplexIdentical(cmath.atan(z), z)
import cmath z = complex(input()) AB = int(input()) BC = int(input()) A = complex(0, AB) B = complex(0, 0) C = complex(BC, 0) print(phase(B + C + A)) MBC = cmath.atan(BC/AC) print(MBC)
def __new__(cls, argument): if isinstance(argument, (RealValue, Zero)): return FloatValue(math.atan(float(argument))) if isinstance(argument, (ComplexValue)): return ComplexValue(cmath.atan(complex(argument))) return MathFunction.__new__(cls)