Ejemplo n.º 1
0
def f_x(pol_terimler, pol_num, ln_terimler, ln_num, trig_terimler, trig_num, value):

    y = 0

    for i in range(pol_num):

        y += pol_terimler[i][0]*pow(value,pol_terimler[i][1])

    for i in range(ln_num):
        print "in fx polinom",ln_terimler[i][0],"*ln",ln_terimler[i][1],"*",value
        y += ln_terimler[i][0]*mt.log(ln_terimler[i][1]*value)
        print "i degeri = ",i


    for i in range(trig_num):
        temp = 0

        if trig_terimler[i][1] == "sin":
            temp = trig_terimler[i][0]*mt.sin(trig_terimler[i][2] * value * mt.pi/180)

        elif trig_terimler[i][1] == "cos":
            temp = trig_terimler[i][0] * mt.cos(trig_terimler[i][2] * value * mt.pi/180)

        elif trig_terimler[i][1] == "tan":
            temp = trig_terimler[i][0] * mt.tan(trig_terimler[i][2] * value * mt.pi/180)

        else:
            temp = trig_terimler[i][0] * mt.cot(trig_terimler[i][2] * value * mt.pi/180)

        y += temp

    return y
Ejemplo n.º 2
0
def func_for_findroot_sce_dgfet0(invlambda1, tOX0, epsOX, epsS):
    """
    Function to find invlambda1 (Eq.(8) in the Ref.[1])
    Normalized with thickness of channel tSi (tOX0=tOX/tSi)
    """
    lhs = epsS * math.tan(math.pi * tOX0 * invlambdad1n)
    rhs = epsOX * math.cot(math.pi / 2 * invlambda1)
    return (lhs - rhs)
Ejemplo n.º 3
0
Archivo: real.py Proyecto: bzhan/holpy
 def rec(t):
     if t.is_number():
         return t.dest_number()
     elif t.is_comb('of_nat', 1):
         return nat.nat_eval(t.arg)
     elif t.is_comb('of_int', 1):
         return integer.int_eval(t.arg)
     elif t.is_plus():
         return rec(t.arg1) + rec(t.arg)
     elif t.is_minus():
         return rec(t.arg1) - rec(t.arg)
     elif t.is_uminus():
         return -rec(t.arg)
     elif t.is_times():
         return rec(t.arg1) * rec(t.arg)
     elif t.is_divides():
         denom = rec(t.arg)
         if denom == 0:
             raise ConvException('real_approx_eval: divide by zero')
         else:
             return rec(t.arg1) / denom
     elif t.is_real_inverse():
         denom = rec(t.arg)
         if denom == 0:
             raise ConvException('real_approx_eval: divide by zero')
         else:
             return 1 / denom
     elif t.is_nat_power():
         return rec(t.arg1)**nat.nat_eval(t.arg)
     elif t.is_real_power():
         x, p = rec(t.arg1), rec(t.arg)
         return x**p
     elif t.is_comb() and t.head == sqrt:
         return math.sqrt(rec(t.arg))
     elif t == pi:
         return math.pi
     elif t.is_comb() and t.head == sin:
         return math.sin(rec(t.arg))
     elif t.is_comb() and t.head == cos:
         return math.cos(rec(t.arg))
     elif t.is_comb() and t.head == tan:
         return math.tan(rec(t.arg))
     elif t.is_comb() and t.head == cot:
         return math.cot(rec(t.arg))
     elif t.is_comb() and t.head == sec:
         return math.sec(rec(t.arg))
     elif t.is_comb() and t.head == csc:
         return math.csc(rec(t.arg))
     elif t.is_comb() and t.head == atn:
         return math.atan(rec(t.arg))
     elif t.is_comb() and t.head == log:
         return math.log(rec(t.arg))
     elif t.is_comb() and t.head == exp:
         return math.exp(rec(t.arg))
     elif t.is_comb() and t.head == hol_abs:
         return abs(rec(t.arg))
     else:
         raise NotImplementedError
Ejemplo n.º 4
0
def cot():
    try:
        val = math.cot(eval(equation.get()))
    except ValueError or ZeroDivisionError or SyntaxError or NameError:
        equation.delete(0, END)
        equation.insert(0, 'Invalid Input')
        err = messagebox.showwarning(title='Invalid Input',
                                     message='Please Input valid Syntax')
        if err == 'ok':
            equation.delete(0, END)
    else:
        equation.delete(0, END)
        equation.insert(0, val)
Ejemplo n.º 5
0
def cot1(x):
    l=query.split("cot")
    c=[]
    for k in l:
        n=''
        for i in k:
            try:
                if int(i) in range(10):
                    n=n+i
            except:
                pass
        c.append(n)
    q=math.cot(int(c[1]))    
    return q
Ejemplo n.º 6
0
def button_equal():
    if flag == "addition":
        second_number = e.get()
        e.delete(0, END)
        e.insert(0, f_num + float(second_number))
    if flag == "subtraction":
        second_number = e.get()
        e.delete(0, END)
        e.insert(0, f_num - float(second_number))
    if flag == "multiplication":
        second_number = e.get()
        e.delete(0, END)
        e.insert(0, f_num * float(second_number))
    if flag == "division":
        second_number = e.get()
        e.delete(0, END)
        e.insert(0, f_num / float(second_number))
    if flag == "square root":
        e.insert(0, math.sqrt(f_num))
    if flag == "factorial":
        e.insert(0, math.factorial(f_num))
    if flag == "ln":
        e.insert(0, math.log(f_num))
    if flag == "x^3":
        e.insert(0, f_num ** 3)
    if flag == "sin":
        e.insert(0, math.sin(f_num))
    if flag == "e^x":
        e.insert(0, math.exp(f_num))
    if flag == "cos":
        e.insert(0, math.cos(f_num))
    if flag == "tan":
        e.insert(0, math.tan(f_num))
    if flag == "x^y":
        second_number = e.get()
        e.delete(0, END)
        e.insert(0, f_num ** float(second_number))
    if flag == "cot":
        e.insert(0, math.cot(f_num))
    if flag == "sinh":
        e.insert(0, math.sinh(f_num))
    if flag == "cosh":
        e.insert(0, math.cosh(f_num))
    if flag == "tanh":
        e.insert(0, math.tanh(f_num))
    if flag == "pi^x":
        e.insert(0, math.pi ** f_num)
    if flag == "arctan":
        e.insert(0, math.atan(f_num))
Ejemplo n.º 7
0
 def p_expresssion_unop(t):
     '''expression : LOG expression | TRIGO expression'''
     if 'log' in t[1].lower():
         t[0] = math.log(t[2])
     if 'sin' in t[1].lower():
         t[0] = math.sin(math.radians(t[2]))
     if 'cos' in t[1].lower():
         t[0] = math.cos(math.radians(t[2]))
     if 'tan' in t[1].lower():
         t[0] = math.tan(math.radians(t[2]))
     if 'cosec' in t[1].lower():
         t[0] = math.cosec(math.radians(t[2]))
     if 'cot' in t[1].lower():
         t[0] = math.cot(math.radians(t[2]))
     if 'sec' in t[1].lower():
         t[0] = math.sec(math.radians(t[2]))
Ejemplo n.º 8
0
def eval_f_x(pol_terimler, pol_num, ln_terimler, ln_num, trig_terimler,
             trig_num, value):
    y = 0

    for i in range(pol_num):
        # print "iter val=",i
        # print "polinomda x = ", value
        # print "polinomda degeri = ", pol_terimler[i][0] * pow(value, pol_terimler[i][1])
        # print "polinomda katsayi = ", pol_terimler[i][0]

        y += pol_terimler[i][0] * pow(value, pol_terimler[i][1])

    for i in range(ln_num):
        print "in fx polinom", ln_terimler[i][0], "*ln", ln_terimler[i][
            1], "*", value
        y += ln_terimler[i][0] * mt.log(ln_terimler[i][1] * value)
        # print "i degeri = ", i

    for i in range(trig_num):
        temp = 0
        # print "i degeri = ", i
        # print "y degeri = ", y
        if trig_terimler[i][1] == "sin":
            temp = trig_terimler[i][0] * mt.sin(
                trig_terimler[i][2] * value * mt.pi / 180)
            print "in sin temp_val = ", temp

        elif trig_terimler[i][1] == "cos":
            temp = trig_terimler[i][0] * mt.cos(
                trig_terimler[i][2] * value * mt.pi / 180)
            print "in cos temp_val = ", temp

        elif trig_terimler[i][1] == "tan":
            temp = trig_terimler[i][0] * mt.tan(
                trig_terimler[i][2] * value * mt.pi / 180)

        else:
            temp = trig_terimler[i][0] * mt.cot(
                trig_terimler[i][2] * value * mt.pi / 180)

        y += temp

    return y
def rocket_roll(env,tick,alpha):
    vo = 0 #initial velocity
    vPrev = vo #set velocity to initial velocity, used for keeping track of previous velocity
    v = vPrev #set velocity
    acc = 5.25 #150 m/s^2 acceleration
    g=9.81 #gravity
    dt = tick #time step

    #stuff for simulating the roll of the rocket
    F=4 #number of canards
    A=11.64*(10**-2) #surface area of one canard in meters
    r=82*(10**-3) #canard distance from the Z axis
    I=.08594 #moment of inertia about the Z axis
    
    S=A*alpha #Planform area of the canard
        
    #Constants for coefficient of lift
    Kp=2.45
    Kv=3.21
    #This is the coefficient of lift in subsonic speeds
    Cl = (Kp*(math.cos(alpha)**2)*math.sin(alpha))+(Kv*math.cos(alpha)*(math.sin(alpha)**2))
        
    #for calculating air density as a function of altitude
    lapserate=.0065 #K/m
    Tempo=288.15 #Temperature at launch site in Kelvins
    Temp=Tempo #for holding temp
    initial_altitude = 0 #probably not right at sea level but we can fix this later
    prev_altitude = initial_altitude #keep track of previous altitude
    altitude=prev_altitude
    #altitude=prev_altitude+v*dt #altitude update
    #Temp=Tempo-lapserate*altitude #temp at altitude

    #air density as a function of altitude
    p=po*(1-((lapserate*altitude)/(Tempo)))**((g*Molarmass)/(R*lapserate))
        
    #lift force of the canard
    L=.5*Cl*p*(v**2)*S
        
    #This is the coefficent of lift in supersonic speeds
    #M=v/332.529 #mach number (velocity/velocity of sound)
    #Beta = math.sqrt(M**2-1) #constant for coefficient of lift
    #m = Beta * math.cot(math.pi/3) #constant for coefficient of lift
    #Cl2 = 2*math.pi*(m/Beta*1.079)
    
    #angular acceleration of the rocket
    #thetadotdot=(F*L*r)/I
    thetadotdot=0
    #env will be the simulation environment
    #tick will represent the time at which something occurs
    while True:
        vPrev=v #keep track of previous velocity
        prev_altitude=altitude #keep track of previous altitude
        track_velocity.append(v) #store velocity
        track_time.append(round(env.now,3)) #store time
        track_altitude.append(round(altitude,3)) #store altitude
        track_thetadotdot.append(round(thetadotdot,3)) #store thetadotdot
        track_temp.append(round(Temp,3)) #store temp
        track_airdensity.append(round(p,3)) #store air density
        track_lift.append(round(L,3)) #store canard lift force
        print 'Time = {:3.2f} minutes'.format(env.now) #show the time
        if(env.now == 0.01):
            print 'Rocket launch occured'
            v=vPrev+acc*dt
            M=v/332.529 #mach number update
            altitude=prev_altitude+v*dt #altitude update
            Temp=Tempo-lapserate*altitude #temp update
            p=po*((1-((lapserate*altitude)/(Tempo)))**((g*Molarmass)/(R*lapserate))) #air density update
            L=.5*Cl*p*(v**2)*S #lift force update
            thetadotdot=(F*L*r)/I #angular acceleration update
            print 'Velocity is {:3.2f} m/s'.format(v)
            print 'Mach {:3.2f}'.format(M)
            print 'Altitude is {:3.2f} m'.format(altitude)
            print 'Temp is {:3.2f} K'.format(Temp)
            print 'Air density {:3.2f} kg/m^3'.format(p)
            print 'Lift force {:3.2f} N'.format(L)
            print 'Angular acc {:3.2f} rad/s^2'.format(thetadotdot)
        elif(env.now > 0.01):
            v=vPrev+acc*dt
            M=v/332.529 #mach number update
            altitude=prev_altitude+v*dt #altitude update
            Temp=Tempo-lapserate*altitude #temp update
            p=po*((1-((lapserate*altitude)/(Tempo)))**((g*Molarmass)/(R*lapserate))) #air density update

            #velocity is over supersonic speed            
            if(v==(peakv-5)):
                Beta = math.sqrt(M**2-1) #constant for coefficient of lift
                m = Beta * math.cot(math.pi/3) #constant for coefficient of lift
                Cl = 2*math.pi*(m/Beta*1.079) #coeff of lift at supersonic speeds            
                L=.5*Cl*p*(v**2)*S #lift force update
                thetadotdot=(F*L*r)/I #angular acceleration update
            else:
                L=.5*Cl*p*(v**2)*S #lift force update
                thetadotdot=(F*L*r)/I #angular acceleration update
            print 'Velocity is {:3.2f} m/s'.format(v)
            print 'Mach {:3.2f}'.format(M)
            print 'Altitude is {:3.2f} m'.format(altitude)
            print 'Temp is {:3.2f} K'.format(Temp)
            print 'Air density {:3.2f} kg/m^3'.format(p)
            print 'Lift force {:3.2f} N'.format(L)
            print 'Angular acc {:3.2f} rad/s^2'.format(thetadotdot)
        else:
            print 'Rocket awaiting launch'
        yield env.timeout(tick) #yield the event that occurs at tick
Ejemplo n.º 10
0
    def calculate_th(self):

        self.angle = ((self.sm.aveSpeed * self.timeInt) /
                      (math.sqrt(self.a2 +
                                 (self.l * math.cot(self.wheelAngle)))))
Ejemplo n.º 11
0
import math as n
log = n.log10(100)
print(log)
log1 = n.log10(100.12)
print(log1)
#i=int(input('Enter the value of angle')
i = 0
cos = n.cos(i)
print("the value of cos(0)  ", cos)
sine = n.sin(i)
print('the value of sine(0)', sine)
tan = n.tan(i)
print('the value of tan (0)', tan)
cot = n.cot(i)
print('the value of cot (0)', cot)
sec = n.sec(i)
print('the value of sec (0)', sec)
Ejemplo n.º 12
0
 def cot(self):
     self.current = float(self.current)
     self.current = float(math.cot((self.current)))
     text_box.delete(0, END)
     text_box.insert(0, self.current)
     self.new_num = True
Ejemplo n.º 13
0
 elif op == '*':
     a = int(input("please enter first number:"))
     b = int(input("please enter second number:"))
     result = a * b
 elif op == '!':
     a = int(input("please enter number:"))
     result = f'result of {a}!: {math.factorial(a)}'
 elif op == 'sin':
     a = int(input("please enter number:"))
     result = math.sin(a)
 elif op == 'tan':
     a = int(input("please enter number:"))
     result = math.tan(a)
 elif op == 'cot':
     a = int(input("please enter number:"))
     result = math.cot(a)
 elif op == 'sqrt':
     a = int(input("please enter number:"))
     result = math.sqrt(a)
 elif op == 'power':
     a = int(input("please enter number:"))
     b = int(input("please enter number:"))
     result = math.pow(a, b)
 elif op == 'log':
     a = int(input("please enter fixed number:"))
     b = input("please enter base number:default(2)")
     if not b:
         result = math.log2(a)
     else:
         result = math.log(a, int(b))
 elif op == '/':
Ejemplo n.º 14
0
		elif (oper == '**'):
			print ('  The answer is: ', float(num1)**float(num2))
			pie = True
			quit()
		elif (oper == 'sqrt'):
			print ('  The answer is: ', math.sqrt(float(num1)))
			pie = True
			quit()
		elif (oper == 'sin'):
			print ('  The answer is: ', math.sin(float(num1)))
			pie = True
			quit()
		elif (oper == 'cos'):
			print ('  The answer is: ', math.cos(float(num1)))
			pie = True
			quit()
		elif (oper == 'tan'):
			print ('  The answer is: ', math.tan(float(num1)))
			pie = True
			quit()
		elif (oper == 'cot'):
			print ('  The answer is: ', math.cot(float(num1)))
			pie = True
			quit()
		else:
			print ('Type in a valid operation!')
			pie = False



Ejemplo n.º 15
0
                            opration = input("请输入你要运算的符号:")

                            #定义一个参数,用来存储计算结果
                            result = 0
                            #对输入的运算符号进行判断
                            if (opration in opra2) or (opration in opra1):
                                #当运算符号位于科学运算时
                                if opration in opra2:
                                    if opration == "sin":
                                        result = math.sin(math.radians(num1))
                                    elif opration == 'cos':
                                        result = math.cos(math.radians(num1))
                                    elif opration == 'tan':
                                        result = math.tan(math.radians(num1))
                                    elif opration == 'cot':
                                        result = math.cot(math.radians(num1))
                                #当运算位于科学运算时

                                else:
                                    num2 = int(input("请输入你需要的第二个数值:"))

                                    #str(num2).append(user)
                                    if opration == '+':
                                        result = num1 + num2
                                    elif opration == '-':
                                        result = num1 - num2
                                    elif opration == '*':
                                        result = num1 * num2
                                    elif opration == '/':
                                        result = num1 / num2
                                    elif opration == '//':
Ejemplo n.º 16
0
     del z[i - 2]
     break
 elif z[i] == "sin":
     z[i] = math.sin(z[i - 1])
     del z[i - 1]
     break
 elif z[i] == "tg":
     z[i] = math.tan(z[i - 1])
     del z[i - 1]
     break
 elif z[i] == "cos":
     z[i] = math.cos(z[i - 1])
     del z[i - 1]
     break
 elif z[i] == "ctg":
     z[i] = math.cot(z[i - 1])
     z[i] = 1 / z[i]
     del z[i - 1]
     break
 elif z[i] == "asin":
     z[i] = math.asin(z[i - 1])
     del z[i - 1]
     break
 elif z[i] == "atg":
     z[i] = math.atan(z[i - 1])
     del z[i - 1]
     break
 elif z[i] == "acos":
     z[i] = math.acos(z[i - 1])
     del z[i - 1]
     break
Ejemplo n.º 17
0
 def calculate_th(self):
 
     self.angle = ((self.sm.aveSpeed * self.timeInt)/(math.sqrt(self.a2 + (self.l * math.cot(self.wheelAngle)))))
		def cot(self):
			self.result = False
			self.current = math.cot(math.radians(float(textDisplay.get())))
			self.display(self.current)
Ejemplo n.º 19
0
def cot_val(r):
	p = m.cot(r)
	return p
Ejemplo n.º 20
0
def cotd(x): return math.cot(x * DEGRAD)
def asind(x): return math.asin(x) * RADEG
Ejemplo n.º 21
0
	if opra=='sin':
		#将弧度转换为角度
		num1=math.radians(num1)
		result=math.sin(num1)
	elif opra=='cos':
#将弧度转换为角度
		num1=math.radians(num1)
		result=math.cos(num1)
	elif opra=='tan':
		#将弧度转换为角度
		num1=math.radians(num1)
		result=math.tan(num1)
	elif opra=='cot':
		#将弧度转换为角度
		num1=math.radians(num1)
		result=math.cot(num1)

	else:
		num2=input("请输入第二个数值:")
		#剔除空格
		num2=num2.strip()
		
		#对第二个数值判断
		if num2.isdigit():
			num2=int(num2)
			#对输入的运算符进行判断
			if opra=='+':
				result=num1+num2
			elif opra=='-':
				result=num1-num2
			elif opra=='*':
Ejemplo n.º 22
0
async def find_cot(event):
    input_str = float(event.pattern_match.group(1))
    output = math.cot(input_str)
    await event.edit(f"**Value of Cot {input_str}\n==>>**`{output}`")
Ejemplo n.º 23
0
 def cot(self, exp):
     if self.rad:
         return round(math.cot(exp), self.round_digit)
     else:
         return round(math.cot(math.radians(exp)), self.round_digit)
Ejemplo n.º 24
0
 def calculate(self, val):
     return self.coefficient * ((math.cot(val))**self.power)
Ejemplo n.º 25
0
import math
math.ceil(4.1)
math.exp(3)
math.fabs(-10) #return float 10.0
math.log(100,10)    #log(x[,base])
math.e #constant
math.log(math.e)
math.log10(100)
math.modf(1.23)
math.sqrt(2)
#triangle functions
x = math.pi
math.sin(x)
math.cos(x)
math.tan(x)
math.cot(x)
math.acos(x)
math.asin(x)
math.atan(x)
math.atan2(x,y)
hypot(x,y)
math.degrees(math.pi/2)
math.radians(x)

# random functions
import random as rdm
list =[1, 2, 3, 554,6464,45,4]
rdm.choice(list)
rdm.randrange(50,100,1) #randrange([start,] stop [,step])
'''
rdm.seed([x])