Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApp1 {
- public delegate double delDoubleDouble(double a);
- class Program {
- static void Main(string[] args) {
- Console.WriteLine(metodoNewton(1, 0.001, function, derivada));
- double a = 1, b = 0;
- int i;
- for (i = 0; i < 10; i++) {
- a = metodoNewton(a, 0.001, function, derivada);
- Console.WriteLine(a);
- }
- Console.WriteLine();
- Console.WriteLine(a);
- Console.ReadKey();
- }
- static double function(double x) {
- return x * x -4;
- }
- static double derivada(double x) {
- return 2 * x ;
- }
- static double metodoNewton(double ponto, double erro, delDoubleDouble funct, delDoubleDouble derivada) {
- return ponto - (funct(ponto) / derivada(ponto));
- }
- static double secant(double x2, delDoubleDouble fx) {
- double x0 = 0d, x1 = 0d;
- for (int i = 0; i < 1000; i++) {
- x2 = x1 - (x1 - x0) / (fx(x1) - fx(x0));
- }
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement