Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Taylor Series and Lewis Carrol Divisibility test in python 3.5 without using math module.
Index -> Programming, Python -> Python Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ylcc23




PostPosted: Thu Jun 23, 2016 5:37 pm   Post subject: Taylor Series and Lewis Carrol Divisibility test in python 3.5 without using math module.

Like the title says, I need to find Taylor series as well as program the divisibility test without using the math module in Python 3.5. I'd do the math on a piece of paper but I was actually never taught either one of these things in school so I honestly have absolutely no clue how to the hell do them on paper. I have a fair amount of it done, but I need some help finishing it.

For Taylor Series: In computing the value of e^x/sin x/cos x, your program should continue to add terms of the power series until it reaches a term whose absolute value is less than 10^-15 times the absolute vale of the sum of the previous terms.

For Lewis Carrol divisibility test:

As long as the number has more than one digit, shorten it by deleting the units digit and subtracting this digit from the resulting number.
The original number is divisible by 11 if and only if the final number is equal to zero

code:
x = float(input("Please input a real number: "))
def factorial(n):
     res = 1
     for i in range(1, n+1):
          res *= i
     return res
def question1():
     ex = 1 + x
     for n in range(2,15):
         ex += (x**n)/factorial(n)
     print(ex)
question1()

def question2():
     cosx = 2 + x
     for n in range(2, 15):
          cosx += (x**n)/factorial(n)
     print(cosx)
question2()

#def question3():
         #sinx =
         #for n in range(2, 15):
              #sinx
         #print("Sin " + str(x) + " = " + str(sinx))
#question3()

#def question4():

#question4()
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, Python -> Python Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: