-
Notifications
You must be signed in to change notification settings - Fork 5
/
polinomios.py
88 lines (66 loc) · 1.96 KB
/
polinomios.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 18 17:41:14 2019
INSTITUTO FEDERAL DE EDUCAÇÃO, CIÊNCIA E TECNOLOGIA DO PÁRA - IFPA ANANINDEUA
@author:
Prof. Dr. Denis C. L. Costa
Discentes:
Heictor Alves de Oliveira Costa
Lucas Pompeu Neves
Grupo de Pesquisa:
Gradiente de Modelagem Matemática e
Simulação Computacional - GM²SC
Assunto:
Operações Polinomiais em Python
Nome do sript: polinomios
"""
# Importanto da Bilbioteca numpy
import numpy as np
# Dado o Polinômio encontrar as suas raízes: P1 = x² - 5x + 6
# Coeficientes do polinômio P1: coef
coef = (1, -5, 6)
# Comando para contruir o polinômio: np.poly1d
P1 = np.poly1d(coef)
# Apresentar o polinômio P1
print('P1 =')
print(P1)
# Determinando a raízes de P1
Zeros_P1 = np.roots(P1)
print('Raízes = ', Zeros_P1)
# Cálculo do valor numérico de P1 para x = 2.5: P1(x)
P1x = P1(2.5)
print('P1x=',P1(2.5))
# A linha de comando a seguir serve para pausar o programa
input("Pressione <enter> para continuar")
print('')
# Contruindo um Pominômio a partir das suas raízes: (-2 e 5)
# Raízes de P2
P2 = np.poly1d([-2, 5], True)
print('P2 =')
print(P2)
input("Pressione <enter> para continuar")
print('')
# Adição e Subtração de Polinômios
P3 = P1 + P2
print('P3 = P1 + P2:')
print(P3)
input("Pressione <enter> para continuar")
print('')
P4 = P1 - P2
print('P4 = P1 - P2:')
print(P4)
input("Pressione <enter> para continuar")
print('')
# Multiplicação e Divisão de Polinômios
P5 = P1*P2
print('P5 = P1*P2 :')
print(P5)
input("Pressione <enter> para continuar")
print('')
P6 = P1/P2
print('P6 = P1 / P2:')
print('Quociente e resto -->',P6)
input("Pressione <enter> para continuar")
print('=== Fim do Programa polinomios ===')
print('')
print('Acione Ctrl + l para limpar a área de trabalho')