def cot(column): i = 0 column= mt.convert_num_col(column) result = list() while i < len(column): result.insert(i+1,(math.cos(column[i])/math.sen(column[i]))) i+=1 return result
def computePotentialVerticalParticle(theta): """ Computes the interaction potential between two IPCs, one vertical in the origin, the second in (2sigma, 0, 0) and rotated from vertical by an angle theta). Returns the potential, and the interaction volumes BB and BS (SS would be zero) """ rP1P2 = sqrt((HSdiameter + ecc * sen(theta))**2 + (ecc * (1 - cos(theta)))**2) rP1B2 = sqrt(ecc * 2 + HSdiameter**2) rP1Q2 = sqrt((HSdiameter - ecc * sen(theta))**2 + (ecc * (1 + cos(theta)))**2) rB1P2 = sqrt((HSdiameter + ecc * sen(theta))**2 + (ecc * cos(theta))**2) rB1B2 = HSdiameter rB1Q2 = sqrt((HSdiameter - ecc * sen(theta))**2 + (ecc * cos(theta))**2) rQ1P2 = sqrt((HSdiameter + ecc * sen(theta))**2 + (ecc * (1 + cos(theta)))**2) rQ1B2 = sqrt(ecc * 2 + HSdiameter**2) rQ1Q2 = sqrt((HSdiameter - ecc * sen(theta))**2 + (ecc * (1 - cos(theta)))**2) wBB = computeOmega(bigRadius, bigRadius, rB1B2) wBS = computeOmega(bigRadius, patchRadius, rB1Q2) V = (eBB * (computeOmega(bigRadius, bigRadius, rB1B2)) + eBS * (computeOmega(patchRadius, bigRadius, rP1B2) + computeOmega(bigRadius, patchRadius, rB1P2) + computeOmega(bigRadius, patchRadius, rB1Q2) + computeOmega(patchRadius, bigRadius, rQ1B2)) + eSS * (computeOmega(patchRadius, patchRadius, rP1P2) + computeOmega(patchRadius, patchRadius, rP1Q2) + computeOmega(patchRadius, patchRadius, rQ1P2) + computeOmega(patchRadius, patchRadius, rQ1Q2))) return V, wBB, wBS
def computePotentialVerticalParticle(theta): rP1P2 = sqrt((HSdiameter + ecc1 * sen(theta))**2 + (ecc1 * (1 - cos(theta)))**2) rP1B2 = sqrt(ecc1 * 2 + HSdiameter**2) rP1Q2 = sqrt((HSdiameter - ecc2 * sen(theta))**2 + (ecc1 + ecc2 * cos(theta))**2) rB1P2 = sqrt((HSdiameter + ecc1 * sen(theta))**2 + (ecc1 * cos(theta))**2) rB1B2 = HSdiameter rB1Q2 = sqrt((HSdiameter - ecc2 * sen(theta))**2 + (ecc2 * cos(theta))**2) rQ1P2 = sqrt((HSdiameter + ecc1 * sen(theta))**2 + (ecc2 + ecc1 * cos(theta))**2) rQ1B2 = sqrt(ecc2 * 2 + HSdiameter**2) rQ1Q2 = sqrt((HSdiameter - ecc2 * sen(theta))**2 + (ecc2 * (1 - cos(theta)))**2) wBB = computeOmega(bigRadius, bigRadius, rB1B2) wBs1 = computeOmega(bigRadius, patch1radius, rB1P2) wBs2 = computeOmega(bigRadius, patch2radius, rB1Q2) V = (eBB * computeOmega(bigRadius, bigRadius, rB1B2) + eBs1 * (computeOmega(patch1radius, bigRadius, rP1B2) + computeOmega(bigRadius, patch1radius, rB1P2)) + eBs2 * (computeOmega(bigRadius, patch2radius, rB1Q2) + computeOmega(patch2radius, bigRadius, rQ1B2)) + es1s1 * computeOmega(patch1radius, patch1radius, rP1P2) + es1s2 * (computeOmega(patch1radius, patch2radius, rP1Q2) + computeOmega(patch2radius, patch1radius, rQ1P2)) + es2s2 * computeOmega(patch2radius, patch2radius, rQ1Q2)) return V, wBB, wBs1, wBs2
def computePotentialHorizontalParticle_Q1left(theta): rP1P2 = sqrt((HSdiameter + ecc1 * (sen(theta) - 1))**2 + (ecc1 * cos(theta))**2) rP1B2 = HSdiameter - ecc1 rP1Q2 = sqrt((HSdiameter - ecc1 - ecc2 * sen(theta))**2 + (ecc2 * cos(theta))**2) rB1P2 = sqrt((HSdiameter + ecc1 * sen(theta))**2 + (ecc1 * cos(theta))**2) rB1B2 = HSdiameter rB1Q2 = sqrt((HSdiameter - ecc2 * sen(theta))**2 + (ecc2 * cos(theta))**2) rQ1P2 = sqrt((HSdiameter + ecc2 + ecc1 * sen(theta))**2 + (ecc1 * cos(theta))**2) rQ1B2 = HSdiameter + ecc2 rQ1Q2 = sqrt((HSdiameter + ecc2 * (1 - sen(theta)))**2 + (ecc2 * cos(theta))**2) ws1s1 = computeOmega(patch1radius, patch1radius, rP1P2) ws1s2 = computeOmega(patch1radius, patch2radius, rP1Q2) V = (eBB * computeOmega(bigRadius, bigRadius, rB1B2) + eBs1 * (computeOmega(patch1radius, bigRadius, rP1B2) + computeOmega(bigRadius, patch1radius, rB1P2)) + eBs2 * (computeOmega(bigRadius, patch2radius, rB1Q2) + computeOmega(patch2radius, bigRadius, rQ1B2)) + es1s1 * computeOmega(patch1radius, patch1radius, rP1P2) + es1s2 * (computeOmega(patch1radius, patch2radius, rP1Q2) + computeOmega(patch2radius, patch1radius, rQ1P2)) + es2s2 * computeOmega(patch2radius, patch2radius, rQ1Q2)) return V, ws1s1, ws1s2
def modelo(argumentos): res = 0 if argumentos[0].isnumeric(): if argumentos[1].isnumeric(): if suma(argumentos[2]): return float(argumentos[0]) + float(argumentos[1]) if resta(argumentos[2]): return float(argumentos[0]) - float(argumentos[1]) if multplicacion(argumentos[2]): return float(argumentos[0]) * float(argumentos[1]) if division(argumentos[2]): return float(argumentos[0]) / float(argumentos[1]) if exponente(argumentos[2]): return float(argumentos[0])**float(argumentos[1]) else: if suma(argumentos[1]): return float(argumentos[0]) + float(argumentos[2]) if resta(argumentos[1]): return float(argumentos[0]) - float(argumentos[2]) if multiplicacion(argumentos[1]): return float(argumentos[0]) * float(argumentos[2]) if division(argumentos[1]): return float(argumentos[0]) / float(argumentos[2]) if exponente(argumentos[1]): return float(argumentos[0])**float(argumentos[2]) else: op = argumentos[0] if suma(op): return float(argumentos[1]) + float(argumentos[2]) if resta(op): return float(argumentos[1]) - float(argumentos[2]) if multiplicacion(op): return float(argumentos[1]) * float(argumentos[2]) if division(op): return float(argumentos[1]) / float(argumentos[2]) if exponente(op): return float(argumentos[1])**float(argumentos[2]) if raiz(op): return m.sqrt(float(argumentos[1])) if seno(op): return m.sin(float(argumentos[1]) * (m.pi / 180)) if coseno(op): return m.cos(float(argumentos[-1]) * (m.pi / 180)) if tangente(op): return m.tan(float(argumentos[1]) * (m.pi / 180)) if secante(op): return 1 / (m.cos(float(argumentos[1]) * (m.pi / 180))) if cosecante(op): return 1 / (m.sen(float(argumentos[1]) * (m.pi / 180))) if cotangente(op): return 1 / (m.tan(float(argumentos[1]) * (m.pi / 180)))
# Program: Algoritmo151_se61.py # Author: Ramon R. Valeriano # Description: # Developed: 26/03/2020 - 11:56 # Updated: import math angle = float(input("Enter with the angle: ")) radians = math.radians(angle) pi = math.pi if(((radians>(pi/2))and(radians<=pi))or((radians>((3*pi)/2))and(radians<=(2*pi))): seno = math.sen(radians) print(seno) else: cos = math.cos(radians) print(cos)
def _probe_locations(probe, k, n): return [(probe[0]+k*(math.cos(360/i)), probe[1]+k*(math.sen(360/i))) for i in range(1, n, 360/n)]
def f(node): "A função objetiva que será optimizada." x, y = node return abs(x * sen(y * pi / 4) + y * sen(x * pi / 4))
import math if (num != 0): real = False while (not real): angulo_grad = input("\nIntroduzca el ángulo en grados: ") real = validar_real(angulo_grad) if (not real): print("Eso no es un ángulo.") else: angulo_grad = float(angulo_grad) angulo_rad = math.radians(angulo_grad) if (num == 1): solucion = math.sin(angulo_rad) elif (num == 2): solucion = math.cos(angulo_rad) elif (num == 3): solucion = math.tan(angulo_rad) elif (num == 4): solucion = 1 / (math.tan(angulo_rad)) elif (num == 5): solucion = 1 / (math.cos(angulo_rad)) elif (num == 6): solucion = 1 / (math.sen(angulo_rad)) print("La solución es", str(solucion) + ".") input("\nPulse intro para cerrar el programa.")
valor_inicial = int(raw_input()) valor_final = int(raw_input()) delta = int(raw_input()) import math valor = valor_final / delta valores = [i * delta for i in range(valor + 1)] print valores x = math.sen(valores) y = math.cos(valores) print "-------------------" print "%15f |%i %6.3f %6.3f |" % (i, x, y) print "-------------------"