Welcome, guest | Sign In | My Account | Store | Cart

C. Maclaurin. A Scottish mathematician gained his master degree at age 17, and his major mathematics' work arise from his special knowledge in Newton's ideas and the formulation of Newton's methods.

However, C. Maclaurin also contributed to the astronomy science and helped to improve maps and invented some mechanical devices .

My mathematics python's programs is a set of Maclaurin's series to compute some of the most important functions in calculus.

Though, the computation of an infinite sum which give the value of a function in terms of the derivatives evaluated at a special case where x0 = 0,in contrast with Taylor series.

There are several ways of finding Maclaurin’s series, and I used the multiplication and the division to develop my own maclaurin’s series for cos(2x) and cos²(x).

Cos(2x) = 2cos²(x) - 1 and cos²(x) = (cos(2x)+1)/2

However, integration and differentiation could also be used to find Maclaurin’s series.

Python, 52 lines
 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
#On the name of ALLAH and may the blessing and peace of Allah 
#be upon the Messenger of Allah Mohamed Salla Allahu Aliahi Wassalam.
#Author : Fouad Teniou
#Date : 03/008/10
#version :2.6

"""
maclaurin_cos_2x is a function to compute cos(x) using maclaurin series
and the interval of convergence is -inf < x < +inf 
cos(2x) = 1- 2^2*x^2/2! + 2^4*x^4/4! - 2^6*x^6/6! ...........
"""

from math import *

def maclaurin_cos_2x(value,k):
    """
    Compute maclaurin's series approximation for cos(2x).
    """
    
    global first_value
    first_value = 0.0
    
    #attempt to Approximate cos(2x) for a given value
    try:
        for item in xrange(4,k,4):
            next_value = (2**item)*(value*pi/180)**item/factorial(item)
            first_value += next_value
            
        for item in xrange(2,k,4):
            next_value = -1*(2**item)*(value*pi/180)**item/factorial(item)
            first_value += next_value
             
        return first_value +1

    #Raise TypeError if input is not a number
    except TypeError:
        print 'Please enter an integer or a float value'

if __name__ == "__main__":
    
    maclaurin_cos_2x_1 = maclaurin_cos_2x(60,100)
    print maclaurin_cos_2x_1
    maclaurin_cos_2x_2 = maclaurin_cos_2x(45,100)
    print maclaurin_cos_2x_2
    maclaurin_cos_2x_3 = maclaurin_cos_2x(30,100)
    print maclaurin_cos_2x_3

 ######################################################################FT python "C:\
#urine series\M
#-0.5
#0.0
#0.5
 

1 comment

Fouad Teniou (author) 11 years, 2 months ago  # | flag

My profile,poems, photos,and design's links

https://acrobat.com/#d=aEjxtq78QkGKUxa*UprkZQ