############################################################################
## CALCULUS - BIOINFORMATICS, 2018-19 T3
## Authors: Toni Guillamon, Alex Haro
## Sources: http://firsttimeprogrammer.blogspot.com.es/2017/08/taylor-series-with-python-and-sympy.html
############################################################################

#######################################################
#INFOS:
#http://www.sympy.org/en/index.html
#SymPy is a Python library for symbolic mathematics (computer algebra system).
###############
#http://ggplot.yhathq.com/
#ggplot is a plotting system for Python based on R's ggplot2 and the Grammar of Graphics. It is built for making profressional looking, plots quickly with minimal code.
#######################################################

import sympy as sy
import numpy as np
from sympy.functions import ln

x = sy.Symbol('x')
x0=0.5
h=0.001
func=ln(1+x)

#Second derivative (numerical)
(np.log(1+x0+h)-2*np.log(1+x0)+np.log(1+x0-h))/h**2
# or, alternatively (although numerically different):
#(func.subs(x,x0+h)-2*func.subs(x,x0)+func.subs(x,x0-h))/h**2

#Using symbolic derivatives:
func.diff(x,2)
func.diff(x,2).subs(x, x0)
