见代码:注释也很明了
/*
牛顿迭代法求方程的一个零点
设f2(x)为f(x)的导数
任取x,方程的零点即为x=x-f(x)/f2(x)
循环几百次就可以得出一个零点。
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
double f(double x)
{
return x*x
见代码:注释也很明了
/*
牛顿迭代法求方程的一个零点
设f2(x)为f(x)的导数
任取x,方程的零点即为x=x-f(x)/f2(x)
循环几百次就可以得出一个零点。
*/
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
double f(double x)
{
return x*x