Metodos numericos programacion c#

Derivacion. namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i, imax=0, n; double e

Views 90 Downloads 3 File size 142KB

Report DMCA / Copyright

DOWNLOAD FILE

Recommend stories

Citation preview

Derivacion. namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i, imax=0, n; double error, y, x, h, emax; n = 30; x = 0.5; h = 1; emax = 0; for (i = 1; i emax) { emax= error; imax=i; }

} Console.WriteLine("imax{0} emax{1}",imax,emax); Console.ReadLine();}

static double f(double x) { return Math.Sin(x); } static double df(double x) { return Math.Abs(Math.Cos(x)); } } }

Integracion Suma de inferiores y superiores namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; double h,suma,sumainferior,sumasuperior,x; int n=50; double a=0, b=.8; h=(b-a)/n; suma=0; for(i=n;i>=1;i--) {

x=a + i*h; suma+= funcion(x); Console.WriteLine(i); } sumainferior= suma*h; sumasuperior= sumainferior+h*(funcion(a)-funcion(b)); Console.WriteLine("sumainferior{0}, sumasuperior{1}",sumainferior,sumasuperior); Console.ReadLine();

} static double funcion(double x) { return /*return (.2 + 25 * x - 200 * Math.Pow(x, 2) + 675 * Math.Pow(x, 3) - 900 * Math.Pow(x, 4) + 400 * Math.Pow(x, 5));*/ /*return Math.Exp(-Math.Pow(x,2));*/ } } }

Regla del trapecio namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int i; double h, suma, x; int n = 60; double a = 0, b = 1; h = (b - a) / n; suma = .5 * (funcion(a) - funcion(b)); for (i = 1; i