Chapter 10: Stokes-Cartan Theorem




In [2]:
import numpy as np
import pandas as pd
import math as m
import matplotlib
import statistics as stats
import scipy.stats as scistats
import matplotlib.pyplot as plt
import matplotlib.colors as color
import os
import sys
import math
import netCDF4 as nc
import statsmodels.api as sm
import shapely
import statistics
import warnings
warnings.filterwarnings("ignore")

from sympy import symbols, diff
from scipy.optimize import fsolve
from matplotlib import cm as cm1
from scipy import optimize as opt
from pandas import read_table
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.patches import Polygon
from scipy.ndimage import gaussian_filter
from sklearn.linear_model import LinearRegression
In [3]:
# Style Dictionary to standarize plotting scheme 
# between different python scripts 
styledict = {'xtick.labelsize':21,
             'xtick.major.size':9,
             'xtick.major.width':1,
             'ytick.labelsize':21,
             'ytick.major.size':9,
             'ytick.major.width':1,
             'legend.framealpha':0.0,
             'legend.fontsize':15,
             'axes.labelsize':22,
             'axes.titlesize':22,
             'axes.linewidth':2,
             'figure.figsize':(12,8),
             'savefig.format':'jpg'}
plt.rcParams.update(**styledict)

Example of computing the area of an ellipse by a planimeter¶

In [7]:
n = 1000
a = 4
b = 2
t = np.linspace(0, 2*np.pi, n+1)
x = a*np.cos(t)
y = b*np.sin(t)
s = np.zeros(n)

for i in range(n):
    s[i] = -y[i]*x[i+1] + x[i]*y[i+1]
    
A = 0.5*sum(s)
print(A)
# area of an ellipse according to formula: pi ab
print(np.pi*a*b)
25.132575862235456
25.132741228718345

Compute the area of an ellipse by a planimeter with u = (0,x)¶

In [8]:
n = 1000
a = 4
b = 2
t = np.linspace(0, 2*np.pi, n+1)
x = a*np.cos(t)
y = b*np.sin(t)
s = np.zeros(n)

for i in range(n):
    s[i] = x[i]*(y[i+1]-y[i])

A = sum(s)
A
Out[8]:
25.1325758622358