当前位置:网站首页>Calculation method notes for personal use
Calculation method notes for personal use
2022-06-12 04:57:00 【wyx_ buaa】
This semester, we opened a course on computing methods and artificial intelligence algorithms , It's actually numerical analysis , So prepare to record the following learned contents .
computing method
- 1. Solution of nonlinear equations
(1) Dichotomy , Newton method , Newton's iteration , Newton went down the mountain
The first method is dichotomy , Dichotomy is easier to understand , That is to say, multiple half division operations are performed on an interval with different signs at one end of the function , Take the midpoint , Then the next interval is determined according to the function value of the midpoint , Continuously , Finally, the tolerance requirements are met , Or the maximum number of iterations .
The characteristic of dichotomy is that it has low requirements for functions , You just need the function to be continuous , Unlike Newton's method mentioned later, it requires both the function and its first derivative . However, one of the obvious disadvantages of dichotomy is that its convergence speed is very slow , So it is generally used to find the initial value . The exact value can be solved by other methods .
#include<stdio.h>
#include<math.h>
int i=0; int n=0;
double eps=1e-6;
double f(double x){
return exp(x)-2; }
double root[50000];
double erfen(double down,double up)
{
double middle=(down+up)/2;
if(i==100)
{
printf("%lf",middle);
return middle;
}
if(f(down)*f(up)<0)
{
if(f(middle)*f(down)<0)
{
i++;
n++;
root[n]=middle;
return erfen(down,middle);
}
else if(f(up)*f(middle)<0)
{
i++;
n++;
root[n]=middle;
return erfen(middle,up);
}
else if(f(middle)<1e-6)
{
printf("%.18lf",middle);
return middle;
}
}
}
int main(){
FILE*fp;
fp=fopen("out.txt","w");
int a,b;
int p=0;
int y;
scanf("%d%d",&a,&b);
erfen(a,b);
int j=0;
for(j=0;j<i;j++){
fprintf(fp,"%.18lf ",root[j]);
p++;
if(p==5)
{
p=0;
fprintf(fp,"\n");
}
}
return 0;
}
Dichotomy is certainly not enough to meet the demand, so we introduced the fixed-point method
The fixed-point method is like generating a sequence of numbers , The latter term of the sequence is always the function value of the former term as an independent variable
If this sequence converges , Then the function must have zero .
The way to do this is , Let the objective function be equal to 0 Add... To both sides of the equation x, So we have a fixed point equation , Then make x by an+1, Order on the other side f(an); So a sequence of numbers is generated , Then you can iterate continuously .
The following is the core idea
while(fabs(xk-xk+1)<e)
{
xk=xk+1;
xk+1=f(xk);
}
The next chapter is Newton's method and Newton's downhill method .
边栏推荐
- Accumulated temperature spatial distribution data, temperature distribution data, sunshine data, rainfall distribution, solar radiation data, surface runoff data, land use data, NPP data, NDVI data
- cellular automaton
- Gao Xiang slam14 notes on three Lie groups and Lie algebra
- Ray. Tune visual adjustment super parameter tensorflow 2.0
- AI and logistics Patent
- Sentinel-2 data introduction and download
- [backtracking based on bit operation] queen n problem 2
- Google reinforcement learning framework seed RL environment deployment
- Report on the current market situation and future development trend of adhesive industry for radar and ultrasonic sensors in the world and China 2022 ~ 2028
- SQL injection upload one sentence Trojan horse (turn)
猜你喜欢

Interview must ask: summary of ten classic sorting algorithms

Big manufacturers compete to join rust, performance and safety are the key, and the 2021 rust developer survey report is announced

2022 self study materials for Zhejiang computer level III network and security technology examination (1) (updated on 2.28)

InnoDB data storage structure – MySQL

JWT學習與使用

Soil type, soil texture, soil nutrient and change data, soil organic matter, soil pH, soil nitrogen, phosphorus and potassium

Spatial distribution data of national multi-year average precipitation 1951-2021, temperature distribution data, evapotranspiration data, evaporation data, solar radiation data, sunshine data and wind

Drive safety coding & troubleshooting guide

JWT learning and use

Operation of simulated examination platform for theoretical question bank of G2 utility boiler stoker in 2022
随机推荐
How Bi makes SaaS products have a "sense of security" and "sensitivity" (Part I)
Big manufacturers compete to join rust, performance and safety are the key, and the 2021 rust developer survey report is announced
How to deploy PostgreSQL as a docker container
[GIS tutorial] land use transfer matrix
Gavin teacher's perception of transformer live class - rasa dialogue robot project practice in the field of education agency mode and core component source code analysis under the microservice of educ
Force/release learning arrangement in IC Verification (5) research on the influence of reg type signals
Google reinforcement learning framework seed RL environment deployment
Memory protection
PostgreSQL age XID maintenance prevents the database from being read-only
Based on Visual Studio code Net Maui cross platform mobile application development
2022 examination questions and online simulation examination for safety management personnel of hazardous chemical business units
How to quickly reference uview UL in uniapp, and introduce and use uviewui in uni app
2022 examination questions and simulation examination for crane driver (limited to bridge crane)
cellular automaton
1006 next spread
Drive safety coding & troubleshooting guide
Spatial distribution data of national multi-year average precipitation 1951-2021, temperature distribution data, evapotranspiration data, evaporation data, solar radiation data, sunshine data and wind
Token based authentication
File contains (regardless of suffix) Apache log remote file contains PHP encapsulated pseudo protocol:
Layer sublayer assigns values to the page elements of the parent layer to achieve the effect of transferring values to the page of the parent layer