当前位置:网站首页>牛顿迭代法(解非线性方程)
牛顿迭代法(解非线性方程)
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;
}
边栏推荐
- Add discount recharge and discount shadow ticket plug-ins to the resource realization applet
- The combination of deep learning model and wet experiment is expected to be used for metabolic flux analysis
- Characteristic Engineering
- Golang foundation - the time data inserted by golang into MySQL is inconsistent with the local time
- location search 属性获取登录用户名
- Halcon Chinese character recognition
- Numpy pit: after the addition of dimension (n, 1) and dimension (n,) array, the dimension becomes (n, n)
- LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
- Ros- learn basic knowledge of 0 ROS - nodes, running ROS nodes, topics, services, etc
- 【日常训练】1200. 最小绝对差
猜你喜欢

资源变现小程序添加折扣充值和折扣影票插件

Business modeling | process of software model

Digital analog 1: linear programming

Pytorch entry record

Count of C # LINQ source code analysis

Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)

猜谜语啦(3)

Explore the authentication mechanism of StarUML

Shift operation of complement

Run菜单解析
随机推荐
[牛客网刷题 Day4] JZ55 二叉树的深度
ORACLE进阶(三)数据字典详解
kubeadm系列-01-preflight究竟有多少check
Halcon shape_ trans
12、动态链接库,dll
location search 属性获取登录用户名
Reasons for the insecurity of C language standard function scanf
287. Looking for repeats - fast and slow pointer
Guess riddles (2)
One dimensional vector transpose point multiplication np dot
Halcon blob analysis (ball.hdev)
C语言标准函数scanf不安全的原因
Pytorch entry record
Halcon clolor_ pieces. Hedv: classifier_ Color recognition
我从技术到产品经理的几点体会
Latex improve
golang 基础 —— golang 向 mysql 插入的时间数据和本地时间不一致
【日常訓練--騰訊精選50】557. 反轉字符串中的單詞 III
Explore the authentication mechanism of StarUML
The first week of summer vacation
