1

i'm trying to make a polinomial calculator in which i can insert the largest coefficient, problem is, the xizes variable, that would be the image of the function is coming as multiple arrays, therefore the function graphic (using matplotlib) is coming like this (this is a third degree polynomial(x³+x²+x¹+x^0)): https://i.sstatic.net/2NGz6.jpg

is there a way to sum up the elements of each array? that would solve the problem

Here's the code:

expoente = int(input("insira o grau do polinomio (numero inteiro): "))
expoente = expoente+1
intervalo_1 = float(input("insira o intervalo desejado \n(ponto inicial): "))
intervalo_2 = float(input("(ponto final): " ))
expoentes = range(0, expoente)
expoentes = [item*1 for item in expoentes]


quantidade = (intervalo_2 - intervalo_1)*500
x = np.linspace(intervalo_1,intervalo_2,num=quantidade,endpoint=False)
xizes = [item**expoentes for item in x]
plt.plot(x,xizes, label="Grafico do polinomio")
plt.xlim([intervalo_1,intervalo_2])
plt.show()
1
  • alright, if i choose a third degree polinomial and ask it to print the xizes variable i receive many arrays like these: <[1. , 0.738, 0.544644, 0.40194727]> , these arrays are x values for every term of the polinomial, (1=x^0 0.738=x¹ 0.544644=x² 0.40194727= x³) Commented May 3, 2017 at 22:52

1 Answer 1

1

nevermind, already figured it out, if it will help somebody later i added the folowing line to sum it

xizes = np.sum(xizes,axis=1)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.