Poll: How are you?
You do not have permission to vote in this poll.
Good.
50.00%
7 50.00%
Whatevah.
14.29%
2 14.29%
Bad.
7.14%
1 7.14%
Shut up and give me iPhone.
28.57%
4 28.57%
Total 14 vote(s) 100%
* You voted for this item. [Show Results]

Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Test
#6
Rainbow 
MyCode?
Hmm, cool.
How about that.

Works
damn
nice.

Hi, I'm a font that everyone hates :V


C
o
l
b
o
t
Gold


Remove all formatting button


Pokemon


Angel



Quote:Not every quote on the internet is true. ~ Abraham Lincoln


Wait, isn't that what Einstein said?


  • one

  • two
  • three
  1. hyh
  2. heh
  3. hah
PHP Code:
echo 2+

Code:
# -- coding: utf-8 --

def calcPolynomial(x, k, a):
   y = 0
   t = x**k
   for i in range(k+1):
       y += a[k-i] * t
       if x != 0:
           t /= x
   return y

def main():
   k = int(raw_input("Podaj najwyższą potęgę wielomianu\n> "))
   print ""
   a = [] # wspolczynniki
   for i in range(k + 1):
       a.insert(-1, float(raw_input("Podaj współczynnik dla potęgi "+str(k-i)+"\n> ")))
   
   print "\nPodaj dziedzinę"
   n = int(raw_input("n = "))
   x_1 = int(raw_input("x_1 = "))
   x_n = int(raw_input("x_n = "))
   
   print "\nObliczanie dziedziny...\n"
   
   x = []
   dx = (x_n - x_1) / (n - 1.0)
   x.append(x_1)
   for i in range(n):
       x.append(x[-1] + dx)
       print "x["+str(i + 1)+"] = "+str(x[i])
   
   print "\nObliczanie wartości...\n"
   
   y = []
   for i in range(n):
       y.append(calcPolynomial(x[i], k, a))
       print "y["+str(i+1)+"] = "+str(y[i])
       
   print "\nWyświetlenie wyników...\n"
   
   print 13 * " " + "x;" + 13 * " " + "y"
   for i in range(n):
       print ("=%12.6f ; =%12.6f" % (x[i], y[i])).replace('.', ',')
   
   print "\nObliczanie ekstremów...\n"
   
   extrema = [0] * (n-2)
   index_extrema = 0
   if y[1] < y[0]:
       czy_rosnie = False
   else:
       czy_rosnie = True
   for i in range(1, (n - 1)):
       if (czy_rosnie and y[i+1] < y[i] < y[i-1]) or (not czy_rosnie and y[i+1] > y[i] > y[i-1]):
           extrema[index_extrema] = i - 1
           index_extrema += 1
           czy_rosnie = not czy_rosnie # negacja
   for i in range(index_extrema):
       print "extremum_"+str(i), "= (", x_1 + extrema[i] * dx,",", y[extrema[i]], ")"

if __name__ == "__main__":
   main()
[Image: XvN5CTW.png] [Image: UYXyyMS.png]


Messages In This Thread
Test - by Simbax - 01-04-2015, 03:24 PM
RE: Test - by Simbax - 01-04-2015, 03:32 PM
RE: Test - by Simbax - 01-04-2015, 03:36 PM
RE: Test - by Simbax - 01-04-2015, 03:38 PM
RE: Test - by tomangelo - 01-04-2015, 03:39 PM
RE: Test - by Simbax - 01-04-2015, 03:48 PM
RE: Test - by krzys_h - 01-04-2015, 08:04 PM
RE: Test - by Simbax - 01-04-2015, 09:50 PM
RE: Test - by krzys_h - 01-04-2015, 11:00 PM
RE: Test - by Simbax - 04-07-2016, 05:10 PM
RE: Test - by Simbax - 09-12-2016, 07:15 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)