(*******************************  manisadjani  *)

Needs["Splines`"]

manisadjani[1]={{0.321,34.6154},{1.603,35.5769},{2.885,35.5769},{4.167,35.8974},{5.449,36.8590},{6.731,36.8590},{8.013,37.5000},{9.295,38.1410},{10.577,38.4615},{11.859,38.7821},{13.141,38.7821},{14.423,39.4231},{15.705,41.3462},{16.987,45.1923},{18.269,47.4359},{19.551,50.9615},{20.833,53.2051},{22.115,56.0897},{22.115,58.6538},{23.397,60.5769},{24.679,62.1795},{25.962,63.7821},{27.244,65.3846},{28.526,66.3462},{29.808,66.9872},{31.090,67.9487},{32.372,68.2692},{33.654,69.2308},{34.936,69.8718},{36.218,70.1923},{37.500,69.8718},{38.782,70.1923},{40.064,70.1923},{41.346,70.1923},{42.628,70.1923},{43.910,69.5513},{45.192,69.8718},{46.474,69.8718},{47.756,69.2308},{49.038,68.2692},{50.321,68.2692},{51.603,67.3077},{52.885,66.3462},{54.167,66.0256},{55.449,64.7436},{56.731,64.4231},{58.013,62.8205},{59.295,60.8974},{60.577,59.9359},{61.859,58.0128},{63.141,57.0513},{64.423,55.7692},{65.705,54.1667},{66.987,52.8846},{68.269,51.2821},{69.551,49.6795},{70.833,47.7564},{72.115,46.4744},{73.397,44.8718},{74.679,44.5513},{75.962,43.9103},{77.244,42.9487},{78.526,42.9487},{79.808,43.5897},{81.090,43.9103},{82.372,43.9103},{83.654,44.2308},{84.936,44.5513},{86.218,44.5513},{87.500,44.8718},{88.782,45.1923},{90.064,45.1923},{91.346,45.1923},{92.628,45.1923},{93.910,45.1923},{95.192,45.5128},{96.474,45.8333},{97.756,47.1154},{99.038,47.4359},{100.321,48.7179},{101.603,49.6795},{102.885,50.6410},{104.167,51.2821},{105.449,52.5641},{106.731,54.1667},{108.013,55.7692},{109.295,56.4103},{110.577,57.6923},{111.859,58.9744},{113.141,59.9359},{114.423,61.2179},{115.705,62.8205},{116.987,63.7821},{118.269,64.4231},{119.551,65.0641},{120.833,65.0641},{122.115,65.3846},{123.397,65.7051},{124.679,66.3462},{125.962,67.3077},{127.244,66.9872},{128.526,66.9872},{129.808,66.9872},{131.090,66.3462},{132.372,66.3462},{133.654,66.0256},{134.936,65.7051},{136.218,65.7051},{137.500,64.4231},{138.782,63.7821},{140.064,63.4615},{141.346,62.1795},{142.628,61.8590},{143.910,60.2564},{145.192,58.6538},{146.474,56.7308},{147.756,55.1282},{149.038,53.5256},{150.321,50.3205},{151.603,48.3974},{152.885,46.7949},{154.167,44.2308},{155.449,42.6282},{156.731,40.3846},{158.013,38.7821},{159.295,37.1795},{160.577,36.8590},{161.859,34.6154},{163.141,33.6538},{164.423,33.3333},{165.705,33.6538},{166.987,33.6538},{168.269,33.0128},{169.551,33.6538},{170.833,33.3333},{172.115,33.9744},{173.397,34.9359},{174.679,35.8974}}
manisadjani[2]={{0.321,15.7051},{1.603,15.0641},{2.885,14.1026},{4.167,13.7821},{5.449,13.7821},{6.731,13.7821},{8.013,14.1026},{9.295,14.7436},{10.577,14.4231},{11.859,14.4231},{13.141,15.0641},{14.423,15.3846},{15.705,16.3462},{16.987,17.3077},{18.269,17.9487},{19.551,18.5897},{20.833,19.8718},{22.115,21.7949},{23.397,24.0385},{24.679,25.0000},{25.962,26.2821},{27.244,27.5641},{28.526,28.5256},{29.808,29.1667},{31.090,30.1282},{32.372,30.7692},{33.654,31.4103},{34.936,32.6923},{36.218,33.6538},{37.500,34.9359},{38.782,34.9359},{40.064,35.8974},{41.346,36.2179},{42.628,36.5385},{43.910,36.8590},{45.192,37.1795},{46.474,37.8205},{47.756,38.1410},{49.038,38.1410},{50.321,38.1410},{51.603,38.1410},{52.885,38.1410},{54.167,38.1410},{55.449,38.1410},{56.731,38.1410},{58.013,38.1410},{59.295,38.1410},{60.577,38.1410},{61.859,37.5000},{63.141,37.5000},{64.423,37.8205},{65.705,37.5000},{66.987,36.5385},{68.269,35.8974},{69.551,35.2564},{70.833,34.6154},{72.115,33.0128},{73.397,32.0513},{74.679,31.4103},{75.962,30.4487},{77.244,29.8077},{78.526,28.2051},{79.808,27.5641},{81.090,26.9231},{82.372,25.6410},{83.654,24.6795},{84.936,22.4359},{86.218,21.1538},{87.500,19.2308},{88.782,17.3077},{90.064,16.3462},{91.346,16.3462},{92.628,16.0256},{93.910,16.0256},{95.192,16.0256},{96.474,15.7051},{97.756,15.7051},{99.038,15.7051},{100.321,15.7051},{101.603,16.3462},{102.885,16.3462},{104.167,16.9872},{105.449,16.9872},{106.731,17.3077},{108.013,18.2692},{109.295,18.5897},{110.577,19.2308},{111.859,19.8718},{113.141,20.8333},{114.423,22.1154},{115.705,22.4359},{116.987,23.7179},{118.269,24.3590},{119.551,25.3205},{120.833,25.3205},{122.115,26.2821},{123.397,27.8846},{124.679,28.2051},{125.962,29.4872},{127.244,30.4487},{128.526,32.0513},{129.808,33.3333},{131.090,34.6154},{132.372,35.2564},{133.654,35.5769},{134.936,35.5769},{136.218,35.5769},{137.500,35.5769},{138.782,35.5769},{140.064,36.2179},{141.346,36.2179},{142.628,37.1795},{143.910,37.5000},{145.192,37.5000},{146.474,38.1410},{147.756,37.8205},{149.038,37.8205},{150.321,37.8205},{151.603,37.5000},{152.885,37.5000},{154.167,37.5000},{155.449,37.5000},{156.731,37.1795},{158.013,36.8590},{159.295,36.8590},{160.577,35.2564},{161.859,35.2564},{163.141,34.9359},{164.423,34.6154},{165.705,33.9744},{166.987,32.6923},{168.269,33.0128},{169.551,32.6923},{170.833,30.7692},{172.115,29.4872},{173.397,28.2051},{174.679,26.9231},{175.962,25.0000},{177.244,23.3974},{178.526,21.7949},{179.808,20.1923},{181.090,19.8718},{182.372,18.5897},{183.654,18.2692},{184.936,17.6282},{186.218,17.3077},{187.500,16.3462},{188.782,16.0256},{190.064,14.7436},{191.346,14.4231},{192.628,14.1026},{193.910,14.1026},{195.192,14.4231},{196.474,14.4231},{197.756,14.7436},{199.038,15.0641},{200.321,15.0641},{201.603,15.7051},{202.885,16.0256},{204.167,16.3462},{205.449,16.3462},{206.731,17.3077}}
manisadjani[3]={{0.321,7.6923},{1.603,8.0128},{2.885,8.6538},{4.167,9.2949},{5.449,9.2949},{6.731,9.9359},{8.013,11.2179},{9.295,12.8205},{10.577,16.3462},{11.859,19.2308},{13.141,24.0385},{14.423,24.6795},{15.705,25.9615},{16.987,26.9231},{18.269,28.5256},{19.551,28.2051},{20.833,29.4872},{22.115,28.5256},{23.397,29.4872},{24.679,29.8077},{25.962,29.1667},{27.244,29.1667},{28.526,29.1667},{29.808,29.8077},{31.090,29.8077},{32.372,30.1282},{33.654,30.4487},{34.936,29.1667},{36.218,28.5256},{37.500,28.5256},{38.782,28.5256},{40.064,28.5256},{41.346,28.2051},{42.628,27.2436},{43.910,27.5641},{45.192,27.8846},{46.474,27.5641},{47.756,27.8846},{49.038,27.8846},{50.321,27.8846},{51.603,27.5641},{52.885,27.2436},{54.167,26.9231},{55.449,26.9231},{56.731,27.2436},{58.013,26.2821},{59.295,25.9615},{60.577,26.6026},{61.859,26.6026},{63.141,25.9615},{64.423,25.6410},{65.705,24.6795},{66.987,24.6795},{68.269,24.6795},{69.551,24.0385},{70.833,24.6795},{72.115,22.7564},{73.397,22.4359},{74.679,21.4744},{75.962,20.5128},{77.244,19.2308},{78.526,18.2692},{79.808,16.9872},{81.090,16.0256},{82.372,14.7436},{83.654,14.1026},{84.936,13.4615},{86.218,13.1410},{87.500,12.1795},{88.782,11.2179},{90.064,11.2179},{91.346,10.5769},{92.628,11.2179},{93.910,11.2179},{95.192,11.8590},{96.474,11.8590},{97.756,12.8205},{99.038,14.4231},{100.321,16.0256},{101.603,17.3077},{102.885,20.8333},{104.167,21.7949},{105.449,23.0769},{106.731,23.7179},{108.013,24.0385},{109.295,24.6795},{110.577,25.0000},{111.859,25.3205},{113.141,25.0000},{114.423,25.3205},{115.705,25.9615},{116.987,25.9615},{118.269,25.9615},{119.551,26.2821},{120.833,26.6026},{122.115,26.2821},{123.397,25.3205},{124.679,25.6410},{125.962,25.0000},{127.244,25.6410},{128.526,25.6410},{129.808,24.6795},{131.090,24.6795},{132.372,25.0000},{133.654,25.3205},{134.936,24.6795},{136.218,25.3205},{137.500,25.6410},{138.782,25.3205},{140.064,25.3205},{141.346,26.2821},{142.628,26.6026},{143.910,26.6026},{145.192,26.6026},{146.474,26.2821},{147.756,26.9231},{149.038,26.9231},{150.321,26.6026},{151.603,26.6026},{152.885,26.2821},{154.167,25.3205},{155.449,25.3205},{156.731,24.6795},{158.013,24.0385},{159.295,22.7564},{160.577,21.1538},{161.859,19.8718},{163.141,18.9103},{164.423,17.3077},{165.705,15.3846},{166.987,13.4615},{168.269,12.5000},{169.551,11.5385},{170.833,10.5769},{172.115,10.2564},{173.397,9.9359},{174.679,10.5769},{175.962,11.2179},{177.244,11.2179},{178.526,11.8590},{179.808,11.8590},{181.090,12.8205},{182.372,13.7821},{183.654,14.7436},{184.936,15.7051},{186.218,15.7051},{187.500,16.0256},{188.782,16.3462}}
manisadjani[4]={{0.321,18.9103},{1.603,18.2692},{2.885,17.9487},{4.167,18.2692},{5.449,17.9487},{6.731,16.6667},{8.013,16.3462},{9.295,17.6282},{10.577,16.6667},{11.859,17.3077},{13.141,17.6282},{14.423,17.6282},{15.705,19.5513},{16.987,19.5513},{18.269,21.1538},{19.551,21.4744},{20.833,23.7179},{22.115,24.0385},{23.397,24.3590},{24.679,25.3205},{25.962,25.0000},{27.244,27.5641},{28.526,28.8462},{29.808,29.4872},{31.090,31.0897},{32.372,31.7308},{33.654,33.3333},{34.936,34.2949},{36.218,36.2179},{37.500,38.4615},{38.782,38.7821},{40.064,40.0641},{41.346,40.7051},{42.628,41.9872},{43.910,44.5513},{45.192,46.1538},{46.474,47.7564},{47.756,49.0385},{49.038,50.9615},{50.321,53.2051},{51.603,54.8077},{52.885,56.0897},{54.167,57.3718},{55.449,58.0128},{56.731,59.9359},{58.013,61.2179},{59.295,60.5769},{60.577,62.1795},{61.859,62.5000},{63.141,62.8205},{64.423,63.4615},{65.705,63.4615},{66.987,63.7821},{68.269,64.4231},{69.551,64.7436},{70.833,65.0641},{72.115,65.3846},{73.397,66.9872},{74.679,66.9872},{75.962,67.6282},{77.244,67.9487},{78.526,68.2692},{79.808,69.2308},{81.090,69.5513},{82.372,70.1923},{83.654,69.8718},{84.936,69.8718},{86.218,70.1923},{87.500,69.5513},{88.782,69.5513},{90.064,69.5513},{91.346,70.1923},{92.628,71.4744},{93.910,70.8333},{95.192,70.8333},{96.474,70.8333},{97.756,72.1154},{99.038,73.3974},{100.321,72.4359},{101.603,72.1154},{102.885,72.1154},{104.167,72.7564},{105.449,72.7564},{106.731,70.1923},{108.013,70.5128},{109.295,71.1538},{110.577,72.4359},{111.859,72.1154},{113.141,70.8333},{114.423,70.5128},{115.705,66.9872},{115.705,69.5513},{116.987,65.7051},{118.269,65.0641},{119.551,63.1410},{120.833,63.1410},{122.115,63.7821},{123.397,63.1410},{124.679,62.5000},{125.962,61.5385},{127.244,59.9359},{128.526,58.9744},{129.808,57.6923},{131.090,57.3718},{132.372,58.3333},{133.654,58.3333},{134.936,57.6923},{136.218,55.1282},{137.500,52.5641},{138.782,49.3590},{140.064,48.0769},{141.346,47.4359},{142.628,43.5897},{142.628,45.8333},{143.910,42.6282},{145.192,41.0256},{146.474,40.7051},{147.756,40.0641},{149.038,39.7436},{150.321,40.0641},{151.603,40.7051},{152.885,40.3846},{154.167,39.4231},{155.449,40.7051},{156.731,40.7051},{158.013,41.3462},{159.295,41.9872},{160.577,42.9487},{161.859,44.5513},{163.141,45.1923},{164.423,47.1154},{165.705,48.3974},{166.987,49.0385},{168.269,50.0000},{169.551,50.3205},{170.833,51.2821},{172.115,52.2436},{173.397,52.8846},{174.679,54.1667},{175.962,54.4872},{177.244,56.7308},{178.526,58.3333},{179.808,58.6538},{181.090,59.2949},{182.372,59.6154},{183.654,60.8974},{184.936,61.8590},{186.218,62.1795},{187.500,63.1410},{188.782,63.1410},{190.064,64.1026},{191.346,64.1026},{192.628,64.7436},{193.910,65.7051},{195.192,65.3846},{196.474,66.0256},{197.756,65.3846},{199.038,66.3462},{200.321,67.6282},{201.603,66.9872},{202.885,67.6282},{204.167,67.3077},{205.449,66.9872},{206.731,67.6282},{208.013,67.6282},{209.295,67.6282},{210.577,67.3077},{211.859,66.9872},{213.141,66.9872},{214.423,67.6282},{215.705,67.6282},{216.987,67.3077},{218.269,66.9872},{219.551,66.6667},{220.833,66.0256},{222.115,65.7051},{223.397,64.7436},{224.679,64.4231},{225.962,64.4231},{227.244,64.1026},{228.526,63.4615},{229.808,62.5000},{231.090,61.5385},{232.372,61.2179},{233.654,61.2179},{234.936,60.5769},{236.218,60.2564},{237.500,59.2949},{238.782,59.9359},{240.064,58.6538},{241.346,57.3718},{242.628,57.3718},{243.910,56.0897},{245.192,54.4872},{246.474,53.8462},{247.756,53.2051},{249.038,50.9615},{250.321,50.0000},{251.603,47.7564},{252.885,46.4744},{254.167,45.1923},{255.449,41.9872},{255.449,43.9103},{256.731,38.1410},{258.013,37.5000},{259.295,34.9359},{260.577,31.4103},{261.859,30.1282},{263.141,28.8462},{264.423,28.2051},{265.705,26.9231},{266.987,25.0000},{268.269,24.3590},{269.551,21.7949},{270.833,22.1154},{272.115,22.7564},{273.397,23.0769},{274.679,23.3974},{275.962,22.7564},{277.244,22.7564},{278.526,23.3974},{279.808,23.7179},{281.090,24.0385},{282.372,24.3590}}

(*Poner aqui la familia*)
var=manisadjani;
(* 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