Skip to content

Instantly share code, notes, and snippets.

@onionmk2
Created October 28, 2017 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save onionmk2/7b2c1aed0c8e0c5db97d315e94603c95 to your computer and use it in GitHub Desktop.
Save onionmk2/7b2c1aed0c8e0c5db97d315e94603c95 to your computer and use it in GitHub Desktop.
void Main()
{
Func<float, float> fx = x =>
{
return x * x - 612;
};
Func<float, float> primeFx = x =>
{
return 2 * x;
};
Func<float, float> diff = (x) => {
return x - fx(x) / primeFx(x);
};
var initialGuess = 10;
var temp = diff(initialGuess);
temp.Dump();
for (int i = 1; i < 6; i++)
{
temp = diff(temp);
temp.Dump();
}
}
@onionmk2
Copy link
Author

result

35.6
26.39551
24.79064
24.73869
24.73863
24.73863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment