(*******************************  confertiflora  *)

Needs["Splines`"]

confertiflora[1]={{0.714,2.857},{3.571,4.286},{6.428,5.000},{9.285,6.428},{12.142,7.143},{14.999,10.000},{17.856,12.142},{20.713,14.285},{23.570,15.714},{26.427,18.571},{29.284,20.713},{32.141,22.856},{34.998,25.713},{37.855,28.570},{40.712,31.427},{43.569,33.570},{46.426,37.855},{49.283,41.427},{52.140,43.569},{54.998,45.712},{57.855,48.569},{60.712,51.426},{63.569,54.283},{66.426,57.140},{69.283,59.283},{72.140,61.426},{72.140,109.995},{72.140,127.851},{74.997,64.283},{74.997,98.567},{74.997,134.994},{77.854,65.711},{77.854,89.282},{77.854,139.279},{80.711,68.568},{80.711,76.425},{80.711,142.851},{83.568,144.993},{86.425,147.136},{89.282,149.279},{92.139,151.422},{94.996,152.136},{97.853,153.564},{100.710,153.564},{103.567,154.279},{106.424,153.564},{109.281,153.564},{112.138,153.564},{114.995,152.850},{117.852,152.136},{120.709,152.136},{123.566,149.993},{126.423,148.565},{129.280,145.708},{132.137,143.565},{134.994,139.279},{137.851,136.422},{140.708,134.280},{143.565,129.994},{146.422,127.137},{149.279,124.280},{152.136,121.423},{154.993,117.852},{157.850,115.709},{160.707,110.709},{163.564,107.138},{166.421,103.567},{169.278,99.995},{172.135,97.138},{174.992,92.853},{177.849,90.710},{180.706,89.996},{183.563,86.425},{186.420,81.425},{189.277,80.711},{192.134,81.425},{194.991,84.282},{197.848,85.710},{200.705,87.853},{203.562,89.282},{206.419,90.710},{209.276,90.710},{212.133,90.710},{214.990,90.710},{217.847,91.424},{220.704,90.710},{223.561,90.710},{226.418,89.996},{229.275,89.282},{232.132,87.139},{234.989,86.425},{237.846,86.425},{240.703,86.425},{243.560,86.425},{246.417,87.853},{249.274,89.282},{252.131,90.710},{254.988,92.139},{257.845,92.139},{260.702,93.567},{263.559,95.710},{266.417,96.424},{269.273,98.567},{272.131,99.995},{274.988,101.424},{277.845,104.281},{280.702,105.709},{283.559,108.567},{286.416,111.424},{289.273,115.709},{292.130,142.851},{294.987,159.278},{297.844,165.707},{300.701,171.421},{303.558,174.278},{306.415,176.421},{309.272,178.563},{312.129,179.992},{314.986,180.706},{317.843,180.706},{320.700,181.420},{323.557,182.135},{326.414,182.135},{329.271,182.135},{332.128,182.135},{334.985,182.135},{337.842,180.706},{340.699,180.706},{343.556,179.278},{346.413,177.135},{349.270,175.706},{352.127,172.849},{354.984,170.707},{357.841,165.707},{360.698,162.135},{363.555,157.850},{366.412,151.422},{369.269,148.565},{372.126,144.279},{374.983,137.851},{377.840,128.566},{380.697,124.280},{383.554,122.137},{386.411,119.280},{389.268,114.281},{392.125,113.566},{394.982,113.566},{397.839,114.281},{400.696,114.995},{403.553,114.995},{406.410,114.995},{409.267,114.995},{412.124,114.281},{414.981,114.281},{417.838,113.566},{420.695,114.281},{423.552,114.281},{426.409,113.566},{429.266,113.566},{432.123,114.995},{434.980,114.995},{437.837,114.995},{440.694,116.423}}
confertiflora[2]={{0.379,36.3542},{1.893,37.1116},{3.408,37.4903},{4.923,37.8690},{6.438,38.6264},{7.952,39.0051},{9.467,39.7625},{10.982,40.5198},{12.497,40.8985},{14.012,42.0346},{15.526,42.7920},{17.041,43.9281},{18.556,45.8215},{20.071,52.2592},{21.585,63.2412},{23.100,76.4954},{24.615,78.7675},{26.130,80.6610},{27.644,82.9331},{29.159,85.5840},{30.674,87.0987},{32.189,87.8561},{33.703,88.6135},{35.218,89.3709},{36.733,90.1282},{38.248,90.5069},{39.762,90.5069},{41.277,89.7495},{42.792,90.1282},{44.307,89.7495},{45.822,88.6135},{47.336,88.2348},{48.851,87.8561},{50.366,87.0987},{51.881,86.3413},{53.395,85.2053},{54.910,82.5544},{56.425,80.6610},{57.940,76.8741},{59.454,71.9511},{60.969,68.9216},{62.484,65.8921},{63.999,58.6970},{65.513,54.1527},{67.028,47.3363},{68.543,42.4133},{70.058,40.1411},{71.572,39.0051},{73.087,37.8690},{74.602,37.4903},{76.117,37.1116},{77.631,36.7329},{79.146,35.9756},{80.661,35.9756},{82.176,35.9756},{83.691,35.2182},{85.205,34.4608},{86.720,34.4608},{88.235,34.4608},{89.750,33.3247},{91.264,32.9460},{92.779,32.9460},{94.294,32.5673},{95.809,32.1887},{97.323,32.9460},{98.838,32.1887},{100.353,32.1887},{101.868,32.1887},{103.382,31.8100},{104.897,31.8100},{106.412,31.4313},{107.927,31.4313},{109.441,31.4313},{110.956,31.0526},{112.471,31.4313},{113.986,31.4313},{115.500,31.8100},{117.015,32.5673},{118.530,32.9460},{120.045,33.7034},{121.560,33.7034},{123.074,34.4608},{124.589,35.2182},{126.104,35.5969},{127.619,37.1116},{129.133,38.6264},{130.648,41.2772},{132.163,43.9281},{133.678,46.5789},{135.192,51.1232},{136.707,54.1527},{138.222,58.3183},{139.737,61.7265},{141.251,63.9986},{142.766,69.3003},{144.281,71.1937},{145.796,71.9511},{147.310,72.3298},{148.825,72.7085},{150.340,73.0872},{151.855,73.8446},{153.369,73.8446},{154.884,74.6019},{156.399,74.6019},{157.914,74.6019},{159.429,74.6019},{160.943,74.6019},{162.458,74.6019},{163.973,73.8446},{165.488,72.7085},{167.002,71.9511},{168.517,71.5724},{170.032,70.4364},{171.547,67.4068},{173.061,64.3773},{174.576,57.5609},{174.576,62.1052},{176.091,48.8510},{177.606,43.5494},{179.120,40.1411},{180.635,34.0821},{182.150,26.1296},{183.665,24.2362},{185.179,23.4788},{186.694,22.3427},{188.209,21.9640},{189.724,21.5853},{191.238,21.5853},{192.753,21.5853},{194.268,21.5853},{195.783,21.5853}}
confertiflora[3]={{0.714,42.141},{3.571,42.855},{6.428,43.569},{9.285,44.998},{12.142,46.426},{14.999,47.141},{17.856,48.569},{20.713,49.998},{23.570,51.426},{26.427,52.140},{29.284,54.283},{32.141,55.712},{34.998,58.569},{37.855,59.283},{40.712,59.997},{43.569,62.140},{46.426,65.711},{49.283,67.854},{52.140,72.140},{54.998,77.139},{57.855,83.568},{60.712,92.139},{60.712,99.281},{63.569,119.995},{66.426,132.137},{69.283,141.422},{72.140,145.708},{74.997,147.850},{77.854,149.279},{80.711,149.993},{83.568,151.422},{86.425,152.136},{89.282,151.422},{92.139,150.707},{94.996,150.707},{97.853,149.279},{100.710,149.279},{103.567,149.279},{106.424,147.850},{109.281,147.136},{112.138,146.422},{114.995,144.279},{117.852,140.708},{120.709,136.422},{123.566,129.994},{126.423,118.566},{129.280,114.995},{132.137,104.281},{134.994,90.710},{137.851,84.282},{140.708,76.425},{143.565,72.854},{146.422,68.568},{149.279,65.711},{152.136,64.283},{154.993,62.140},{157.850,59.997},{160.707,58.569},{163.564,57.140},{166.421,54.998},{169.278,52.855},{172.135,52.140},{174.992,51.426},{177.849,49.283},{180.706,49.283},{183.563,50.712},{186.420,50.712},{189.277,51.426},{192.134,52.140},{194.991,52.140},{197.848,52.140},{200.705,52.855},{203.562,53.569},{206.419,53.569},{209.276,53.569},{212.133,54.283},{214.990,54.998},{217.847,54.998},{220.704,56.426},{223.561,56.426},{226.418,57.855},{229.275,57.855},{232.132,57.855},{234.989,59.283},{237.846,59.283},{240.703,59.997},{243.560,60.712},{246.417,60.712},{249.274,60.712},{252.131,62.140},{254.988,62.140},{257.845,63.569},{260.702,63.569},{263.559,68.568},{266.417,78.568},{269.273,90.710},{272.131,99.281},{274.988,109.995},{277.845,127.851},{280.702,132.137},{283.559,137.137},{286.416,139.994},{289.273,142.136},{292.130,143.565},{294.987,143.565},{297.844,144.993},{300.701,144.993},{303.558,144.993},{306.415,145.708},{309.272,146.422},{312.129,147.850},{314.986,148.565},{317.843,148.565},{320.700,147.850},{323.557,147.136},{326.414,145.708},{329.271,143.565},{332.128,141.422},{334.985,138.565},{337.842,135.708},{340.699,114.281},{340.699,129.994},{343.556,102.138},{346.413,84.996},{349.270,66.426},{349.270,77.854},{352.127,56.426},{354.984,29.999},{357.841,24.285},{360.698,19.999},{363.555,18.571},{366.412,17.856},{369.269,17.142},{372.126,14.285},{374.983,12.857},{377.840,12.142},{380.697,12.857},{383.554,12.857},{386.411,11.428}}
confertiflora[4]={{0.714,10.714},{3.571,10.714},{6.428,10.000},{9.285,9.285},{12.142,7.143},{14.999,7.143},{17.856,7.857},{20.713,10.000},{23.570,10.714},{26.427,12.857},{29.284,15.714},{32.141,19.285},{34.998,22.142},{37.855,24.999},{40.712,29.284},{43.569,34.284},{46.426,38.570},{49.283,48.569},{52.140,57.140},{52.140,71.425},{52.140,84.996},{54.998,97.853},{54.998,107.138},{57.855,119.995},{57.855,133.565},{60.712,139.279},{63.569,140.708},{66.426,142.136},{69.283,144.279},{72.140,144.993},{74.997,147.136},{77.854,147.850},{80.711,149.279},{83.568,149.279},{86.425,147.850},{89.282,147.850},{92.139,146.422},{94.996,144.993},{97.853,144.993},{100.710,143.565},{103.567,140.708},{106.424,134.280},{109.281,125.709},{112.138,117.852},{114.995,111.424},{117.852,104.281},{120.709,97.138},{123.566,89.996},{126.423,84.282},{129.280,77.854},{132.137,72.854},{134.994,67.140},{137.851,57.140},{140.708,53.569},{143.565,52.855},{146.422,49.998},{149.279,49.283},{152.136,48.569},{154.993,49.998},{157.850,50.712},{160.707,49.998},{163.564,51.426},{166.421,52.140},{169.278,52.855},{172.135,53.569},{174.992,54.998},{177.849,56.426},{180.706,56.426},{183.563,56.426},{186.420,56.426},{189.277,56.426},{192.134,54.998},{194.991,54.283},{197.848,53.569},{200.705,52.855},{203.562,52.140},{206.419,51.426},{209.276,49.283},{212.133,47.855},{214.990,45.712},{217.847,44.284},{220.704,43.569},{223.561,43.569},{226.418,44.284},{229.275,45.712},{232.132,49.998},{234.989,52.140},{237.846,54.283},{240.703,57.855},{243.560,59.283},{246.417,63.569},{249.274,66.426},{252.131,67.854},{254.988,69.997},{257.845,72.854},{260.702,77.139},{263.559,79.996},{266.417,79.282},{269.273,81.425},{272.131,88.567},{274.988,92.853},{277.845,94.996},{280.702,95.710},{283.559,94.996},{286.416,96.424},{289.273,96.424},{292.130,97.853},{294.987,105.709},{297.844,114.995},{300.701,116.423},{303.558,122.137},{306.415,132.851},{309.272,136.422},{312.129,140.708},{314.986,144.993},{317.843,151.422},{320.700,159.278},{320.700,174.278},{323.557,179.992},{326.414,181.420},{329.271,184.277},{332.128,185.706},{334.985,186.420},{337.842,186.420},{340.699,187.849},{343.556,187.849},{346.413,187.849},{349.270,186.420},{352.127,186.420},{354.984,184.992},{357.841,183.563},{360.698,182.849},{363.555,182.135},{366.412,179.992},{369.269,177.135},{372.126,172.135},{374.983,114.995},{374.983,127.851},{374.983,140.708},{374.983,154.993},{377.840,105.709},{380.697,98.567},{383.554,97.138},{386.411,94.281},{389.268,92.853},{392.125,88.567},{394.982,86.425},{397.839,83.568},{400.696,79.996},{403.553,77.854},{406.410,76.425},{409.267,76.425},{412.124,74.997},{414.981,77.139},{417.838,80.711},{420.695,82.853}}

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