Advertisement
Guest User

c#

a guest
Mar 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp1 {
  8. public delegate double delDoubleDouble(double a);
  9. class Program {
  10.  
  11. static void Main(string[] args) {
  12. Console.WriteLine(metodoNewton(1, 0.001, function, derivada));
  13. double a = 1, b = 0;
  14. int i;
  15. for (i = 0; i < 10; i++) {
  16. a = metodoNewton(a, 0.001, function, derivada);
  17. Console.WriteLine(a);
  18.  
  19. }
  20.  
  21. Console.WriteLine();
  22. Console.WriteLine(a);
  23. Console.ReadKey();
  24. }
  25.  
  26. static double function(double x) {
  27. return x * x -4;
  28. }
  29. static double derivada(double x) {
  30. return 2 * x ;
  31. }
  32.  
  33. static double metodoNewton(double ponto, double erro, delDoubleDouble funct, delDoubleDouble derivada) {
  34. return ponto - (funct(ponto) / derivada(ponto));
  35.  
  36. }
  37. static double secant(double x2, delDoubleDouble fx) {
  38. double x0 = 0d, x1 = 0d;
  39. for (int i = 0; i < 1000; i++) {
  40. x2 = x1 - (x1 - x0) / (fx(x1) - fx(x0));
  41. }
  42. return 0;
  43. }
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement