clear;clc;close all;

syms t s(t);
sp = diff(s,t);
g = [28.972*cos(t)+50.06 14.463*cos(t) + 10.567; 14.463*cos(t) + 10.567 10.567];
v = [sp;1];
L = sqrt(v.'*g*v);
L1 = diff(L,sp);
L2 = diff(L1,t);
L2eqn = L2 == 0
conditions = [s(0) == 0, s(2*pi) == 0];
% sJeff = dsolve(L2eqn, conditions)

% spJeff = diff(sJeff,t);
% vJeff = [spJeff;1];
% LJeff = sqrt(vJeff.'*g*vJeff);
% lengthJeff = int(LJeff, t, 0, 2*pi)
% lengthJeffNum = double(lengthJeff)

syms C1;

spJeff1C1 = -(257541226*cos(t) + 104755509*cos(t)^2 - 2641750*C1^2 - 3615750*C1^2*cos(t) + 5*10^(1/2)*C1*((486082*cos(t) - 209178369*cos(t)^2 + 417322531)*(- 250*C1^2 + 7243*cos(t) + 12515))^(1/2) + 132246005)/(4*(181292290*cos(t) + 52461049*cos(t)^2 - 3128750*C1^2 - 1810750*C1^2*cos(t) + 156625225));
spJeff1C10 = subs(spJeff1C1,t,0);
sol1 = solve(spJeff1C10 == 0, C1);
spJeff1 = subs(spJeff1C1,C1,sol1)
% spJeff1 = -((456167505967*cos(t))/10567 + 104755509*cos(t)^2 - (2503*10^(1/2)*105670^(1/2)*((7243*cos(t) - 24379220/10567)*(486082*cos(t) - 209178369*cos(t)^2 + 417322531))^(1/2))/21134 - 24379220)/((3125116495020*cos(t))/10567 + 209844196*cos(t)^2 - 1220423753200/10567)
double(subs(spJeff1,t,pi))

spJeff2C1= (26116916*cos(t) - (6529229000*C1^2)/7243 + (5*10^(1/2)*C1*(486082*cos(t) - 209178369*cos(t)^2 + 417322531)^(1/2)*(- 250*C1^2 + 7243*cos(t) + 12515)^(1/2))/4 + 326853203740/7243)/((7243*cos(t) + 12515)*(- 250*C1^2 + 7243*cos(t) + 12515)) - 14463/28972;
spJeff2C10 = subs(spJeff2C1,t,0);
sol2 = solve(spJeff2C10 == 0, C1);
spJeff21 = subs(spJeff2C1,C1,sol2(1))
% spJeff21 = (26116916*cos(t) + (32646145*39204623044804527168658515907973956254212911^(1/2))/22970030288698110640128 + (5*10^(1/2)*(219330705335071048167851/3171342025224093696000 - 39204623044804527168658515907973956254212911^(1/2)/634268405044818739200)^(1/2)*(486082*cos(t) - 209178369*cos(t)^2 + 417322531)^(1/2)*(7243*cos(t) + (5*39204623044804527168658515907973956254212911^(1/2))/12685368100896374784 - 60573323552352917746091/12685368100896374784)^(1/2))/4 - 1581988403057622483687205415215/91880121154792442560512)/((7243*cos(t) + 12515)*(7243*cos(t) + (5*39204623044804527168658515907973956254212911^(1/2))/12685368100896374784 - 60573323552352917746091/12685368100896374784)) - 14463/28972
double(subs(spJeff21,t,pi))

spJeff22 = subs(spJeff2C1,C1,sol2(2))
% spJeff22 = ((32646145*39204623044804527168658515907973956254212911^(1/2))/22970030288698110640128 - 26116916*cos(t) + (5*10^(1/2)*(39204623044804527168658515907973956254212911^(1/2)/634268405044818739200 + 219330705335071048167851/3171342025224093696000)^(1/2)*(486082*cos(t) - 209178369*cos(t)^2 + 417322531)^(1/2)*(7243*cos(t) - (5*39204623044804527168658515907973956254212911^(1/2))/12685368100896374784 - 60573323552352917746091/12685368100896374784)^(1/2))/4 + 1581988403057622483687205415215/91880121154792442560512)/((7243*cos(t) + 12515)*((5*39204623044804527168658515907973956254212911^(1/2))/12685368100896374784 - 7243*cos(t) + 60573323552352917746091/12685368100896374784)) - 14463/28972
double(subs(spJeff22,t,pi))

spJeff3 = ((209178369*cos(t)^2 - 486082*cos(t) - 417322531)^(1/2)/4 + 3964635209671277/1099511627776)/(7243*cos(t) + 12515) - 14463/28972
double(subs(spJeff3,t,pi))

spJeff4 = -(14463*cos(t) + (209178369*cos(t)^2 - 486082*cos(t) - 417322531)^(1/2) + 10567)/(28972*cos(t) + 50060)
double(subs(spJeff4,t,pi))

v0 = [0;1];
L0 = sqrt(v0.'*g*v0);
length0 = double(int(L0,t,0,2*pi))