当前位置:网站首页>牛顿迭代法(解非线性方程)
牛顿迭代法(解非线性方程)
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;
}
边栏推荐
- Illustration of eight classic pointer written test questions
- golang 基础 —— golang 向 mysql 插入的时间数据和本地时间不一致
- asp. Net (c)
- Array, date, string object method
- 猜谜语啦(2)
- LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
- Guess riddles (3)
- ORACLE进阶(三)数据字典详解
- Illustrated network: what is gateway load balancing protocol GLBP?
- Ros-10 roslaunch summary
猜你喜欢

Business modeling of software model | object modeling

图解八道经典指针笔试题

Business modeling of software model | overview

Pytorch entry record

TF coordinate transformation of common components of ros-9 ROS

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

Programming implementation of ROS learning 6 -service node

It cold knowledge (updating ing~)

How to manage the performance of R & D team?

Halcon clolor_ pieces. Hedv: classifier_ Color recognition
随机推荐
Programming implementation of subscriber node of ROS learning 3 subscriber
[daiy4] jz32 print binary tree from top to bottom
Halcon: check of blob analysis_ Blister capsule detection
TF coordinate transformation of common components of ros-9 ROS
容易混淆的基本概念 成员变量 局部变量 全局变量
[牛客网刷题 Day4] JZ35 复杂链表的复制
Basic number theory - factors
深度学习模型与湿实验的结合,有望用于代谢通量分析
Hello everyone, welcome to my CSDN blog!
Ecmascript6 introduction and environment construction
LLVM之父Chris Lattner:为什么我们要重建AI基础设施软件
Pytorch entry record
Confusing basic concepts member variables local variables global variables
Redis实现高性能的全文搜索引擎---RediSearch
12. Dynamic link library, DLL
Basic number theory - fast power
Programming implementation of ROS learning 2 publisher node
Install the CPU version of tensorflow+cuda+cudnn (ultra detailed)
猜谜语啦(9)
Halcon snap, get the area and position of coins
