当前位置:网站首页>牛顿迭代法(解非线性方程)
牛顿迭代法(解非线性方程)
2022-07-05 08:46:00 【行止AC】
原理
对于已知的方程f(x),当f’(x)=n,化为f(x)-n=0;
题目
#include<bits/stdc++.h>
#define ll long long
#define PI 3.141592653589793
#define E 2.718281828459045
#define HalF (l + r)>>1
#define lsn rt<<1
#define rsn rt<<1|1
#define Lson lsn, l, mid
#define Rson rsn, mid+1, r
#define QL Lson, ql, qr
#define QR Rson, ql, qr
#define myself rt, l, r
#define mset(a,b) memset(a,b,sizeof(a))
#define mcpy(a,b) memset(a,b,sizeof(a))
#define FOR( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define FO( i , n ) for ( int i = 0 ; i < n ; ++ i )
#define lowbit(a) ((a)&-(a))
#define PII pair<ll ,ll >
#define ft first
#define sd second
#define endl "\n"
typedef unsigned long long ull;
const ll mod=10007;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll Max=1e5+10;
using namespace std;
ll t,n,m,l,k;
ll ans;
/*queue<ll> q; stack<ll> s; //升序队列 priority_queue <int,vector<int>,greater<int> > q; //降序队列 priority_queue <int,vector<int>,less<int> >q;*/
double solve(double w)
{
double w1=w;
for(ll i=1;i<=100;i++)
{
w1=w1-(w1*w1*w1-w)/(3*w1*w1);
}
return w1;
}
int main()
{
ios::sync_with_stdio(false);
double n;
cin>>n;
cout<<fixed<< setprecision(6)<<solve(n)<<endl;
return 0;
}
边栏推荐
- Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
- Configuration and startup of kubedm series-02-kubelet
- 猜谜语啦(2)
- Adaboost使用
- Guess riddles (9)
- Latex improve
- Golang foundation -- map, array and slice store different types of data
- Run menu analysis
- 轮子1:QCustomPlot初始化模板
- Halcon shape_ trans
猜你喜欢
Yolov4 target detection backbone
Halcon Chinese character recognition
Programming implementation of ROS learning 5-client node
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
TF coordinate transformation of common components of ros-9 ROS
Guess riddles (11)
猜谜语啦(6)
Wechat H5 official account to get openid climbing account
Business modeling | process of software model
Guess riddles (142)
随机推荐
Typescript hands-on tutorial, easy to understand
ORACLE进阶(三)数据字典详解
C# LINQ源码分析之Count
[daiy4] copy of JZ35 complex linked list
我从技术到产品经理的几点体会
Guess riddles (5)
Guess riddles (6)
[daiy4] jz32 print binary tree from top to bottom
[牛客网刷题 Day4] JZ32 从上往下打印二叉树
ECMAScript6介绍及环境搭建
File server migration scheme of a company
Halcon color recognition_ fuses. hdev:classify fuses by color
Business modeling of software model | stakeholders
Guess riddles (8)
Business modeling of software model | vision
Solutions of ordinary differential equations (2) examples
Ros-10 roslaunch summary
Business modeling of software model | object modeling
OpenFeign
GEO数据库中搜索数据