(*******************************  euxina  *)

Needs["Splines`"]

euxina[1]={{8.489,1.8865},{12.262,1.8865},{16.035,2.8297},{19.808,3.7729},{23.581,2.8297},{27.354,2.8297},{27.354,8.4891},{31.127,12.2620},{34.899,12.2620},{38.672,16.0349},{42.445,21.6943},{46.218,23.5807},{49.991,24.5239},{53.764,25.4672},{57.537,32.0698},{61.310,37.7291},{65.083,41.5020},{68.856,46.2182},{72.629,49.9911},{76.401,53.7640},{80.174,55.6505},{83.947,58.4802},{87.720,60.3666},{91.493,63.1963},{95.266,63.1963},{99.039,65.0828},{102.812,66.0260},{106.585,66.9692},{110.358,66.9692},{114.131,66.9692},{117.904,66.9692},{121.676,66.9692},{125.449,66.9692},{129.222,65.0828},{132.995,64.1395},{136.768,61.3098},{140.541,59.4234},{144.314,56.5937},{148.087,52.8208},{151.860,47.1614},{155.633,42.4453},{159.406,40.5588},{163.178,41.5020},{166.951,44.3317},{170.724,44.3317},{174.497,47.1614},{178.270,51.8776},{182.043,54.7072},{185.816,57.5369},{189.589,58.4802},{193.362,59.4234},{197.135,61.3098},{200.908,61.3098},{204.681,61.3098},{208.453,61.3098},{212.226,61.3098},{215.999,61.3098},{219.772,61.3098},{223.545,61.3098},{227.318,61.3098},{231.091,59.4234},{234.864,58.4802},{238.637,59.4234},{242.410,59.4234},{246.183,59.4234},{249.956,60.3666},{253.728,60.3666},{257.501,60.3666},{261.274,60.3666},{265.047,59.4234},{268.820,59.4234},{272.593,58.4802},{276.366,56.5937},{280.139,55.6505},{283.912,52.8208},{287.685,52.8208},{291.458,51.8776},{295.230,51.8776},{299.003,52.8208},{302.776,53.7640},{306.549,53.7640},{310.322,54.7072},{314.095,53.7640},{317.868,53.7640},{321.641,53.7640},{325.414,54.7072},{329.187,56.5937},{332.960,56.5937}}
euxina[2]={{0.943,24.5239},{4.716,24.5239},{8.489,25.4672},{12.262,27.3536},{16.035,28.2969},{19.808,28.2969},{23.581,28.2969},{27.354,29.2401},{31.127,26.4104},{34.899,24.5239},{38.672,31.1265},{42.445,42.4453},{46.218,47.1614},{49.991,50.9343},{53.764,53.7640},{57.537,56.5937},{61.310,57.5369},{65.083,58.4802},{68.856,58.4802},{72.629,59.4234},{76.401,60.3666},{80.174,62.2531},{83.947,61.3098},{87.720,63.1963},{91.493,63.1963},{95.266,63.1963},{99.039,63.1963},{102.812,63.1963},{106.585,61.3098},{110.358,61.3098},{114.131,59.4234},{117.904,57.5369},{121.676,56.5937},{125.449,51.8776},{129.222,49.0479},{132.995,47.1614},{136.768,55.6505},{140.541,59.4234},{144.314,63.1963},{148.087,66.0260},{151.860,67.9124},{155.633,69.7989},{159.406,70.7421},{163.178,72.6286},{166.951,72.6286},{170.724,72.6286},{174.497,73.5718},{178.270,73.5718},{182.043,72.6286},{185.816,71.6854},{189.589,70.7421},{193.362,68.8557},{197.135,67.9124},{200.908,65.0828},{204.681,63.1963},{208.453,61.3098},{212.226,58.4802},{215.999,56.5937},{219.772,50.9343},{223.545,47.1614},{227.318,37.7291},{231.091,27.3536},{234.864,33.9562},{238.637,37.7291},{242.410,40.5588},{246.183,42.4453},{249.956,44.3317},{253.728,45.2750},{257.501,46.2182},{261.274,46.2182},{265.047,46.2182}}
euxina[3]={{0.943,44.3317},{4.716,41.5020},{8.489,39.6156},{12.262,41.5020},{16.035,46.2182},{19.808,50.9343},{23.581,52.8208},{27.354,55.6505},{31.127,56.5937},{34.899,57.5369},{38.672,58.4802},{42.445,59.4234},{46.218,59.4234},{49.991,59.4234},{53.764,59.4234},{57.537,58.4802},{61.310,58.4802},{65.083,59.4234},{68.856,58.4802},{72.629,58.4802},{76.401,57.5369},{80.174,55.6505},{83.947,54.7072},{87.720,53.7640},{91.493,53.7640},{95.266,53.7640},{99.039,51.8776},{102.812,49.9911},{106.585,48.1046},{110.358,45.2750},{114.131,42.4453},{117.904,37.7291},{121.676,34.8994},{125.449,34.8994},{129.222,36.7859},{132.995,39.6156},{136.768,42.4453},{140.541,43.3885},{144.314,46.2182},{148.087,48.1046},{151.860,49.0479},{155.633,49.9911},{159.406,51.8776},{163.178,51.8776},{166.951,51.8776},{170.724,49.9911},{174.497,49.9911},{178.270,49.0479},{182.043,48.1046},{185.816,48.1046},{189.589,46.2182},{193.362,46.2182},{197.135,46.2182},{200.908,44.3317},{204.681,44.3317},{208.453,43.3885},{212.226,42.4453},{215.999,39.6156},{219.772,36.7859},{223.545,33.9562},{227.318,30.1833},{231.091,29.2401},{234.864,20.7510},{238.637,14.1484},{242.410,16.0349},{246.183,16.9781},{249.956,19.8078},{253.728,25.4672},{257.501,27.3536},{261.274,28.2969},{265.047,29.2401}}
euxina[4]={{16.035,1.8865},{19.808,1.8865},{23.581,10.3755},{27.354,17.9213},{31.127,22.6375},{34.899,25.4672},{38.672,29.2401},{42.445,33.0130},{46.218,34.8994},{49.991,36.7859},{53.764,37.7291},{57.537,40.5588},{61.310,41.5020},{65.083,44.3317},{68.856,46.2182},{72.629,45.2750},{76.401,47.1614},{80.174,48.1046},{83.947,48.1046},{87.720,49.0479},{91.493,49.9911},{95.266,49.9911},{99.039,49.9911},{102.812,49.0479},{106.585,48.1046},{110.358,46.2182},{114.131,45.2750},{117.904,44.3317},{121.676,42.4453},{125.449,41.5020},{129.222,42.4453},{132.995,46.2182},{136.768,48.1046},{140.541,50.9343},{144.314,51.8776},{148.087,56.5937},{151.860,60.3666},{155.633,61.3098},{159.406,66.0260},{163.178,66.9692},{166.951,68.8557},{170.724,70.7421},{174.497,72.6286},{178.270,74.5150},{182.043,74.5150},{185.816,74.5150},{189.589,75.4583},{193.362,75.4583},{197.135,75.4583},{200.908,76.4015},{204.681,74.5150},{208.453,72.6286},{212.226,71.6854},{215.999,69.7989},{219.772,66.9692},{223.545,65.0828},{227.318,62.2531},{231.091,61.3098},{234.864,57.5369},{238.637,54.7072},{242.410,52.8208},{246.183,51.8776},{249.956,49.0479},{253.728,44.3317},{257.501,46.2182}}

(*Poner aqui la familia*)
var=euxina;
(* el número de curvas estudiadas/semillas de la familia*)
m=4;
For[j=1,j≤m,j++,
puntos=var[j];
(* pru es el spline cubico
d es el vector que contiene la información de pru 
n es el número de trozos del spline, es decir, el número de puntos menos 1
*)
pru=SplineFit[puntos,Cubic];
d=InputForm[pru];
n=IntegerPart[d[[1,2,2]]];
spli=ParametricPlot[pru[t],{t,0,n},PlotRange->All, DisplayFunction->Identity];
(* Con los coeficientes se calculan los polinomios cúbicos que dan el spline. Habrá n polinomios para la primera coordenada (X) y otros tantos para la segunda
*)
For[i=0,i<n,i++,
SX[i,t_]=d[[1,4,i+1,1,1]]+d[[1,4,i+1,1,2]]*(t-i)+d[[1,4,i+1,1,3]]*(t-i)^2+d[[1,4,i+1,1,4]]*(t-i)^3];
For[i=0,i<n,i++,SY[i,t_]=d[[1,4,i+1,2,1]]+d[[1,4,i+1,2,2]]*(t-i)+d[[1,4,i+1,2,3]]*(t-i)^2+d[[1,4,i+1,2,4]]*(t-i)^3];
(* Derivada primera y segunda de cada trozo del spline
*)
For[i=0,i<n,i++,DX[i,t_]=d[[1,4,i+1,1,2]]+2*d[[1,4,i+1,1,3]]*(t-i)+3*d[[1,4,i+1,1,4]]*(t-i)^2];
For[i=0,i<n,i++,DY[i,t_]=d[[1,4,i+1,2,2]]+2*d[[1,4,i+1,2,3]]*(t-i)+3*d[[1,4,i+1,2,4]]*(t-i)^2];
For[i=0,i<n,i++,DDX[i,t_]=2*d[[1,4,i+1,1,3]]+6*d[[1,4,i+1,1,4]]*(t-i)];
For[i=0,i<n,i++,DDY[i,t_]=2*d[[1,4,i+1,2,3]]+6*d[[1,4,i+1,2,4]]*(t-i)];
(*Cálculo de la curvatura a trozos
*)
For[i=0,i<n,i++,cur[i,t_]=(DX[i,t]DDY[i,t]-DDX[i,t]DY[i,t])/((DX[i,t])^2+(DY[i,t])^2)^(3/2)];
(* Dibujos de los trozos de curvatura 
*)
For[i=0,i<n,i++,dib[i]=Plot[cur[i,t],{t,i,i+1},DisplayFunction->Identity]];
pp=dib[0];
For[i=1,i<n,i++,pp=Show[pp,dib[i],PlotRange->All]];
(* bez es el spline de Bezier
b es el vector que contiene la información de bez
nb es el número de trozos del spline, es decir, el número de puntos menos 1 (Como nb=n, no se define nuevo)
*)
bez=SplineFit[puntos,Bezier];
b=InputForm[bez];
(*Calculo de las funciones de Bezier para la coordenada X y la Y; la curva es la imagen del intervalo[0,1]*)
For[i=1,i≤n+1,i++,BX[t_]=bez[[4,1,1]]/.#1->t];
For[i=1,i≤n+1,i++,BY[t_]=bez[[4,1,2]]/.#1->t];
dibez[j]=ParametricPlot[{BX[t],BY[t]},{t,0,1},PlotRange->All,DisplayFunction->Identity];
curbe[j,t_]=1000*(BX'[t]BY''[t]-BX''[t]BY'[t])/((BX'[t])^2+(BY'[t])^2)^(3/2);
aa=0.1;
bb=0.9;
cur[j]=Abs[NMinValue[{curbe[j,t],aa<t<bb},t]];
vmed[j]=Abs[NIntegrate[curbe[j,t],{t,aa,bb}]];
vals[j]=Reap[soln=y[x]/. First[NDSolve[{y'[x]==Evaluate[D[curbe[j,x],x]],y[0]==(curbe[j,x]/. x->0)},y[x],{x,aa,bb},Method->{"EventLocator","Event"->y'[x],"EventAction":>Sow[{x,y[x]}]}]]][[2,1]];
Print[ var,"-",j,":"];Print["Máximos y mínimos locales "];
Print[vals[j]];
z=vals[j];
max[j]=Max[Table[z[[k,2]],{k,1,Length[z]}]];
min[j]=Min[Table[z[[k,2]],{k,1,Length[z]}]];dibcurbe[j]=Plot[curbe[j,x],{x,0,1},Epilog->{PointSize[Medium],Red,Point[z]}];
Print[dibez[j]];
Print[dibcurbe[j]];
Print[Plot[{curbe[j,t],vmed[j]},{t,0,1},Axes->True,DisplayFunction->Identity,PlotStyle->{RGBColor[0,1,0],{Dotted,Dashed}}]];
Print[ "Máximo valor de la curvatura",max[j]];
Print[ "Mínimo valor de la curvatura",min[j]];Print[ "Máximo valor de la curvatura (en valor absoluto)con otro cálculo",cur[j]];
Print["______________________________________________________"];];
Print["Curvaturas de cada ", var ,":  ", Table[cur[r],{r,1,4}]];
Print["Valores medios de curvatura de cada ", var ," en [0,1]:  ", Table[vmed[j],{j,1,4}]];

Show[Table[dibcurbe[j],{j,1,6}]]

Table[NMinValue[{curbe[j,t],0.25<t<0.75},t],{j,1,6}]

dibcurbe[j],{j,1,6}

Table[dibcurbe[j],{j,1,6}]

curbe[j,t_]
dibcurbe[j]

Plot[curbe[1,x],{x,0,1},Epilog->{PointSize[Medium],Red,Point[vals[1]]}]

dibcurbe[j]=Plot[curbe[j,x],{x,0,1},Epilog->{PointSize[Medium],Red,Point[z]}]

dibcurbe2[1]

Print[dibez[1]];

f=vals[1]

Max[vals[1]]

Max[Table[f[[k,2]],{k,1,Length[f]}]]
Min[Table[f[[k,2]],{k,1,Length[f]}]]

List