Step 1: Learn what you need to learn, even if you don’t understand it. Here comes the most boring math formula
In numerical analysis, Lagrange interpolation is a polynomial interpolation method named after the French mathematician Joseph Lagrange in the 18th century. In many practical problems, functions are used to represent some internal connections or laws, and many functions can only be understood through experiments and observations.
For example, if we observe a physical quantity in practice and obtain corresponding observation values at several different places, the Lagrange interpolation method can find a polynomial that takes the observed value at each observation point. Such a polynomial is called a Lagrange (interpolation) polynomial.
Mathematically speaking, the Lagrange interpolation method can give a polynomial function that passes through a number of known points on a two-dimensional plane. The Lagrange interpolation method was first discovered by the British mathematician Edward Waring in 1779, and was rediscovered by Leonhard Euler shortly afterwards (1783). In 1795, Lagrange published this interpolation method in his book "A Course in Elementary Mathematics for Normal Schools", and his name has been associated with this method ever since.
Step 2: Construct the Lagrange interpolation algorithm function and implement it in C/C++
//Predefine the number of interpolation nodes to 1000, and determine the number of interpolation nodes according to the number num input by the console const int N=1000; // Lagrange interpolation algorithm float lglr(float x[], float y[],int n,float t){float yResult=0.0; //LValue[N] stores the general term of the interpolation basis function solved each time float LValue[N]; //Loop variables k, mint k, m; //Up and down multiplications in the interpolation basis function temp1, temp2 float temp1, temp2; for(k=0;k Step 3: Test the linear interpolation effect
1. Input 3 points of the oblique line to the written algorithm to predict other points in this interval. It is found that the predicted linear value is very good and the linearity is full.
2. Also input 3 points of the sine curve to the written algorithm to predict other points in this interval. It is found that the predicted sine curve is not ideal and the correlation is very poor.
3. Increase the number of points of the sine curve input to the written algorithm to 10 points to predict other points in this interval. It is found that the predicted sine curve has met the requirements and the correlation is very good.
4. The following is an image drawn using matlab, which is an image of the comparison of 3 linear points, sine 3, 5, 10 and the original value.
Step 4: Transplant to the microcontroller and use the serial port output to test the interpolation effect. The effect is OK!
Step 4: Advanced perfection, a little unwilling, using Qt to build an interface and do some visualization.
You can say the effect is good. The Qt interface code is on gitee. If you are interested, please come and improve it together. https://gitee.com/lumengcode/my-qt/tree/master/MathTool/MathTool
Interpolation off-topic:
Regarding the interpolation algorithm: Newton interpolation, cubic spline interpolation, etc. can be further improved. They are all very interesting!
END
Previous article:Some must-read knowledge points for zero-based learning of microcontrollers
Next article:An example of communication between applet and microcontroller (TCP/IP)
Recommended ReadingLatest update time:2024-11-16 11:25
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Help~How can I make the PCB package of this component according to the picture?
- Using R329 for offline face detection
- Please explain the cause of the error
- [TI star product limited time purchase] + teach you how to quickly get started with AWR6843
- [NXP Rapid IoT Review] Hello Buttons
- micropython update: 2020.2
- TI's latest generation ACF Controller UCC28782 helps miniaturize adapters
- The difference between high frequency capacitors and ceramic capacitors
- Today's broadcast starts at 10:00: Introduction to Littelfuse's SiC MOSFET and Schottky diode products and related applications
- [Me and Arty 2] AT32 transplant threadX and its awesome component GUIX