[Help] Reinserting value for an equation in a while loop

Hello, I'm (very) new to C# and I'm tasked with learning the language on my own ASAP for a high level college course that I bypassed the programming prerequisites for. I'm working on coding Newtons Method, and while I think I have the general gist of how to write the code for how to find the root, I've found myself stuck. I've looked at many examples online, but our homework is set up so that we can't just copy examples. Here is the code that I have so far. Any help is appreciated, please comment if I'm not being specific enough. { using System;

public class MainClass { public static void Main() { double root = 0; double TOL = Math.Pow (10, -8);

 double fx = Math.Pow (Math.E, root) + Math.Sin (root) - 4; double fp = Math.Pow (Math.E, root) + Math.Cos; double result = fx - (fx / fp); //int stepcount = 0; Console.WriteLine( "Guess Value = {0}", root ); Console.WriteLine( "Result Value = {0}", result ); while (Math.Abs(result) >= TOL) { double fx = Math.Pow (Math.E, root) + Math.Sin (root) - 4; double fp = Math.Pow (Math.E, root) + Math.Cos; double result = fx - (fx/fp) return ; } Console.WriteLine("The root of {0} is at approximately {1}", fx, result); } 

}

by DoomJazz via /r/csharp

Leave a Reply