#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 12 15:46:47 2024

@author: sam
"""

import numpy as np
import matplotlib.pyplot as plt
import math

x = np.linspace(-np.pi/2,3*np.pi/2) #generate x values
x0 = (np.pi)/3 #define x0
h = 1e-12 #step in h

'''define functions'''
def T(n):
    T = 0
    for k in range(n+1):
        if k%4==0:
            df = np.sqrt(3)/2
        elif k%4==1:
            df = 1/2
        elif k%4==2:
            df = -np.sqrt(3)/2
        elif k%4==3:
            df = -1/2
        T += (1/math.factorial(k))*df*((x-x0)**k)
    return T



plt.plot(T(15))