CellPrint[TextCell[Quiet[cdf =Manipulate[SuFunc[u, ff],Style[proposito,Bold,10],Spacer[{100,3}],
 (*Inicio contadores *)
 {{u,1,"n = "},1,5,1,ControlType->RadioButtonBar},
{{ff,x^4,"f(x) = "},ControlType->InputField},
{{puntoA,0,"a = "},ControlType->InputField},
{{puntoB,1,"b = "},ControlType->InputField},
Button["Calcular",pos =u; If[u==1, u=2, u=1];u=pos;  SuFunc[Dynamic@u, ff]] ,
{{math,0,"Calcular con Mathematica "},{0,1},ControlType->Checkbox},
{{darerror,0,"Dar error Aprox. "},{0,1},ControlType->Checkbox}

(* Fin contadores *)
,Alignment->Center,Deployed->True,AppearanceElements->"ResetButton",LocalizeVariables->True,ContinuousAction->False,FrameLabel->{{None,None},{Column[{,Row[{Style["Autores: Juan Félix Ávila Herrera y Enrique Vílchez Quesada",Bold,10,RGBColor[0,0,0.5]]}],Row[{Style["Escuela de Informática | Universidad Nacional de Costa Rica",Bold,10,RGBColor[0.5,0.1,0]]}]},Center],Style["Aproximación numérica de integrales definidas usando las fórmulas cerradas de Newton-Cotes.", Bold,14, RGBColor[0,0.33,0.33]]}},
Initialization:>( 
ClearAll["Global`*"];
escriba[lista_]:=Style[Row@lista,Black];
integre = ToString[TraditionalForm@Defer[(∫_a^b)f[x]\[DifferentialD]x]];
 
formulas={{(1/2) (-a+b) (f[a]+f[b]),(1/12) (((a-b))^3) f''[ξ],"(Regla del trapecio)\n"},{-(1/6) (a-b) (f[a]+f[b]+4 f[((a+b)/2)]),(((((a-b))^5) Derivative[4][f][ξ])/2880),"(Regla de Simpson)\n"},{-(1/8) (a-b) (f[a]+f[b]+3 (f[(1/3) (2 a+b)]+f[(1/3) (a+2 b)])),(((((a-b))^5) Derivative[4][f][ξ])/6480),"(Regla de 3/8 Simpson)\n"},{-(1/90) (a-b) (7 f[a]+7 f[b]+12 f[((a+b)/2)]+32 (f[(1/4) (3 a+b)]+f[(1/4) (a+3 b)])),(((((a-b))^7) Derivative[6][f][ξ])/1935360),"(Regla de Boole)\n"},{-(1/288) (a-b) (19 f[a]+50 f[((3 a)/5)+((2 b)/5)]+50 f[((2 a)/5)+((3 b)/5)]+19 f[b]+75 (f[(1/5) (4 a+b)]+f[(1/5) (a+4 b)])),((11 (((a-b))^7) Derivative[6][f][ξ])/37800000),""}};

Clear[f];

(*($PreRead=(#/. s_String/;StringMatchQ[s,NumberString]&&Precision@ToExpression@s==MachinePrecision:>s<>"`12."&));*)
proposito ="Propósito: Usando n puntos integrar el polinomio de Lagrange para aproximar " <>integre;(*TraditionalForm@Defer[(∫_a^b)f[x]\[DifferentialD]x] ;*)

SuFunc[k_, ff_]:=Module[{aux, resp, pt, coef, error, max, val},
resp[x_] := If[val =x; val==Round[val], x,escriba@{x," ≈ ",ToString[Sign[x] AccountingForm[Abs@N@x]]}];
(*resp[x_] := N@x;*)


Clear[f, g];
g[t_] = ff/.x->t;
aux =N@formulas[[u]][[1]]/.{a-> puntoA,b-> puntoB, h->hache, f->g   };
If[darerror==1, error =formulas[[u]][[2]]/.{a-> puntoA,b-> puntoB, h->hache, f->g };
error=Simplify[error];];

max =N@Quiet[ Maximize[Abs[error], puntoA≤ξ≤ puntoB, ξ]];
 
(*aux = ToString@ TraditionalForm[ (∫_a^b)f[x]\[DifferentialD]x ]<>"≈ "<>*)
aux =  {"Fórmula usada:\n" , 
  formulas[[u]][[3]] , integre ,
  "≈", TraditionalForm@formulas[[u]][[1]],"\n",integre ,  "≈" ,  
   ToString[Sign[aux] AccountingForm[Abs@aux]] } ;
If[math==1, aux = Join[aux, { 
   "\nUsando Mathematica: " ,  integre ,  " = " ,  resp[(∫_puntoA^puntoB)g[x]\[DifferentialD]x]}  ]];
If[darerror==1, aux = Join[aux, {"\nNota. Error usando Aprox =",TraditionalForm[error], "\n|Error Aprox.| ≤" , TraditionalForm@max[[1]]}]];
escriba@aux
 
];
SuFunc[1]
)]],"Text"]]

CloudDeploy[cdf,Permissions->"Public"]