Gold Price Fluctuation Forecasting Based on Newton and Lagrange Polynomial Interpolation

Gold is a highly valuable commodity and an investment opportunity for many people. However, there are often signiﬁcant ﬂuctuations in gold prices that affect investment decisions. Various mathematical forecasting methods have been developed to anticipate gold price ﬂuctuations. This study uses historical daily data of gold prices during January-May 2023. The method used in this study is the Newton and Lagrange polynomial interpolation method with several orders to analyze data and forecast gold price ﬂuctuations. The purpose of this study is to compare the performance and accuracy of the order levels of the Newton and Lagrange polynomial interpolation forecasting models. In this study, the test data points and orders are selected so that a range is formed that matches the amount of data available. The test orders used in this study include orders 2, 3, 5, 6, and 10. This study found that the 2 nd order polynomial interpolation method is more effective and accurate in forecasting gold price ﬂuctuations compared to the higher orders tested. This is indicated by the results of the calculation of MAE, RMSE, and MAPE values in 2 nd order polynomial interpolation which are smaller than in 3 rd , 5 th , 6 th , and 10 th order polynomial interpolation. This suggests that a polynomial of 2 nd order has been able to model and forecast gold price ﬂuctuations well. However, it is important to remember that these conclusions are based on the data and methods used in this study. Variability in forecasting results can occur depending on the quality of the data, the time period used, and the interpolation method applied, among others. Therefore, further research and wider testing needs to be conducted to validate these conclusions.


A. INTRODUCTION
Gold is one of the most popular investment instruments in the world, due to its stable value and ability to last for long periods of time.However, gold prices often experience significant fluctuations, which can affect investor's investment decisions (Radhamani et al., 2022;Tripurana et al., 2022;Haris, 2020).The gold price is the market price of the precious metal gold, which is often used as an investment tool and a reserve of value (Haris, 2020).Gold price fluctuations are price changes that occur in a certain period of time, which can be influenced by various factors.One of the influencing factors is the monetary policy of the central bank, such as interest rates and inflation (ul Sami and Junero, 2017).When interest rates and inflation are low, the value of the currency becomes stronger and gold prices tend to decrease, and vice versa.Another influencing factor is market demand and supply.If the market demand for gold increases, the price tends to rise due to the limited supply of gold, and vice versa.In addition, geopolitical and security factors can also affect gold price fluctuations (Nugroho, 2018;Rakhmawati and Nurhalim, 2021).Political or security crises can cause global uncertainty and tension, thereby increasing market demand for gold as a reserve of value.
Gold price fluctuations can affect investment and trading decisions in global financial markets (Sravani et al., 2021).Therefore, forecasting gold price fluctuations is important to make the right investment decisions and minimize the risk of loss (Hendrian et al., 2021).To help forecast gold price fluctuations, various math-based forecasting methods have been developed.Among the widely used methods are Newton and Lagrange polynomial interpolation.These methods produce polynomials that are capable of interpolating historical gold price data, so they can be used to forecast gold prices.Although Newton and Lagrange polynomial interpolation has been used in many forecasting applications, there are still some problems that need to be addressed.One of them is forecasting accuracy which can be affected by many factors, such as the amount of test data used and sudden changes in economic or political factors that affect gold prices.
Research into the forecasting of gold price fluctuations based on Newton and Lagrange polynomial interpolation can help improve understanding of the method and find ways to improve forecasting accuracy.Through this research, it is also expected to find a more accurate and effective gold price forecasting model.The model is expected to benefit investors and traders in making better investment decisions in the face of unpredictable gold price fluctuations and minimize the risk of loss.In addition, this research can also open up opportunities for the development of other forecasting methods using different mathematical methods.
Newton and Lagrange polynomial interpolation are two methods used to estimate the value at a point not contained in the data set, based on known data points (Astuti et al., 2018).The Newton polynomial interpolation method uses a low-order polynomial and a dividend difference table.The dividend difference table is constructed from known data points, which are then used to construct the interpolating polynomials (Muhammad, 2011).The process of creating a dividend difference table involves calculating the differences from known data points (Astuti et al., 2018).Meanwhile, the Lagrange polynomial interpolation method uses higher-order polynomials and does not require a dividend difference table (Pratama et al., 2014).This method is based on creating interpolation polynomials using Lagrange basis functions, which are constructed from known data points.Each data point is associated with a basis function associated with it, and then interpolation polynomials are constructed from these basis functions.
There have been many previous studies that forecasted gold prices using various methods.Among these studies are articles that discuss the forecasting of gold prices using the ARIMA model and the ARIMA time series approach (Anggraeni et al., 2020;Sunyanti. and Mukhaiyar, 2019); deterministic trend model (Rakhmawati and Nurhalim, 2021); double exponential smoothing model with LOCF imputation and linear interpolation (Siregar et al., 2021).These studies developed a model to forecast the global gold price throughout the COVID-19 pandemic, solely relying on historical gold price data and excluding any external factors that could impact the model.Meanwhile, there are articles that discuss machine learning algorithms, approaches, and techniques (Pragna et al., 2022;Radhamani et al., 2022;ul Sami and Junero, 2017;Tripurana et al., 2022) that applied machine learning technique to forecast financial financial indicators, with a primary focus on forecasting the price of gold.In another research, discuss the forecasting of gold prices using Generalized Autoregressive Conditional Heteroscedasticity (Garch) model (Haris, 2020); local polynomial nonparametric method equipped with GUI R (Hendrian et al., 2021); average-based fuzzy time series method (Hariwijaya et al., 2020); multiple linear regression method (Sravani et al., 2021); Nearest Neighbor Retrieval method (Nugroho, 2018); data mining techniques (Mahena et al., 2015).These research explores gold price forecasting in the context of making investment decisions in gold stocks.It presents the outcomes of a forecasting process capable of creating models and predictions using historical data.Additionally, there is an article that conducts a comparison between Naive Bayes, support vector machine, and K-NN methods for forecasting fluctuations in gold prices, specifically within the realm of gold stock investment (Suryana and Sen, 2021).
On the other hand, there are also several previous studies that discuss the application of polynomial interpolation methods to forecast various data.There is article that discuss the application of the polynomial interpolation method to forecast the population of the province of East Nusa Tenggara by applying the Lagrange Interpolation method that found every year the population increases (Hurit and Nanga, 2022;Pratiwi et al., 2017).In another research, discuss the forecasting of virus spread in all regions of Indonesia using Newton Raphson interpolation method (Aulia et al., 2020).Meanwhile, there are articles that discuss the forecasting of stock prices using several polynomial interpolation methods such as Newton-Gregory forward, Newton-Gregory backward, Newton, and Lagrange (Muhammad, 2011;Pangruruk and Barus, 2016;Pangruruk and Barus, 2018a;Pangruruk et al., 2020;Pangruruk and Barus, 2018b).Additionally, there is an article that forecasting of the number of elementary, junior high, high school, and vocational school students in NTB Province, using the Newton-Gregory Advanced Polynomial method (Negara et al., 2020).Furthermore, there are studies that discuss the relationship between land area and palm oil production to forecast the agricultural production (palm oil production) in Riau province using Newton-Gregory forward polinomial interpolation (Sihombing, 2019).
Although polynomial interpolation has long been discovered and widely used in various fields, research that discusses its application in forecasting gold price fluctuations is still relatively new and has not been done in previous studies.Moreover, the novelty of this research is that it combines research that applies polynomial interpolation (Newton and Lagrange) and research that uses gold price data.In addition, this research uses the latest (data in 2023) and comprehensive (daily price data) gold price data information to improve forecasting accuracy.This study also compares the performance and accuracy of the order level of the polynomial interpolation forecasting model (Newton and Lagrange).The purpose of this study is to apply the Newton and Lagrange polynomial interpolation methods to historical gold price data to create a mathematical model that can predict gold price fluctuations, compare the performance and accuracy of the order levels of the Newton and Lagrange polynomial interpolation forecasting models, and present the results of gold price forecasts visually in the form of curves to facilitate interpretation and decision making.

B. RESEARCH METHOD
The research method used in this study is as follows: 1. Determining the data points to be studied.At this stage, matching points in a cartesian coordinate over a finite set of pairs of points (x 0 , y 0 ), (x 1 , y 2 ), . . ., (x n , y n ) without knowing the shape of the function rule.In this study, historical data points of daily gold prices during January-May 2023 were selected, namely 151 data points.The data was collected from the official web source of gold prices in Indonesia (www.logammulia.com).The selection of these data points is based on the consideration that these data are the latest and relevant data in forecasting gold prices.

Determine the form of the Newton and Lagrange polynomial interpolation equation.
The historical data points that have been obtained are then processed and analyzed using Scilab 2023.1.0software with Newton and Lagrange polynomial interpolation techniques.Based on the historical data points, test data points and test orders are then selected so that a range is formed that matches the amount of historical data available.At this stage, Newton and Lagrange polynomial interpolation techniques of order 2, 3, 5, 6, and 10 are used to build a mathematical model that can be used to forecast gold prices.The polynomial interpolation technique is a mathematical technique used to estimate the value of the function f (x) at points between known data points (Astuti et al., 2018).
The form of the polynomial interpolation equation can be determined using the general equation of a polynomial of a certain degree.In the Newton polynomial interpolation method, the form of the n-degree polynomial interpolation equation for (n + 1) data points is as follows (Astuti et al., 2018): For the Newton polynomial interpolation method in this study, the polynomial coefficients are determined using the forward difference technique (Astuti et al., 2018).The forward difference technique is used because the data has the same distance between points, which is data at the same time period.The equations used to calculate the coefficients of the Newton polynomial are: . . .
The square bracketed function value is called the divided difference value, so the coefficients a i are also called Newton divided difference coefficients.The coefficients of the polynomial can be determined using a forward difference table, known as its dividend difference table.This table is organized by the finite differences of the values of f (x) at the data points.Each row in this table indicates a finite difference of a higher order than the previous row.
As for the Lagrange polynomial interpolation method, the form of an n-degree polynomial for (n + 1) data points is as follows: For the Lagrange polynomial interpolation method, the polynomial coefficients are determined by calculating the nth Lagrange polynomial and function values at the data points.Furthermore, the equations used to calculate the coefficients on the Lagrange polynomials are: 3. Calculate the gold price forecasting from the polynomial interpolation equation obtained.
After obtaining a polynomial equation that matches the specified order and test data, the next step is to calculate the gold price at the desired time.To calculate the price of gold at a certain time using Newton and Lagrange polynomial interpolation, the value of x in the polynomial equation is replaced with the time index you want to forecast, then the result is calculated.The result will give an estimate of the gold price at the desired time.

Plotting the curve.
At the stage of describing the curve, Microsoft Excel software is used to visualize the data and model forecasting results.After the mathematical model is built using Newton and Lagrange polynomial interpolation techniques, the gold price forecasting value is calculated by entering the desired time data index value as input.Then, the forecasted value is depicted in the form of a curve with the x-axis being the time period and the y-axis being the gold price.The curve is then compared between the actual data and the forecasted data to evaluate the accuracy of the model.The evaluation results are used to determine which order of polynomial interpolation is more accurate in forecasting gold prices.

Evaluating the accuracy of the polynomial interpolation model.
After forecasting gold prices using the polynomial interpolation method, the next step is to evaluate the accuracy of the model.In this research, evaluating the accuracy of the model is done by comparing the forecasted data with the actual data available.The methods used to evaluate model accuracy include the Mean Absolute Error (MAE), Root Mean Squared Error (RMSE) and Mean Absolute Percentage Error (MAPE) methods.MAE, RMSE, and MAPE are measures of forecasting error used to measure how far the forecasting results are from the actual value.The smaller the MAE, RMSE, and MAPE values, the more accurate the polynomial interpolation forecasting model used (Lamabelawa, 2019;Muhammad Julian et al., 2022).The following are the formulas given for MAE, RMSE, and MAPE: Description: y i is the actual value of the i th observation, ŷi is the forecasted value of the i th observation, n is the total number of observations in the sample.

Interpreting the results.
After performing steps 1-5, the results will be obtained in the form of gold price forecasting based on existing historical data.The forecasting results should be interpreted with caution and should not be taken as certainty.Therefore, it is necessary to evaluate the forecasting results obtained, such as by comparing the forecasting results with actual data.If the forecasting results have a large error, it is necessary to review the historical data and the polynomial interpolation method used.This aims to ensure that the forecasting obtained are more accurate and can be used as a guide in providing recommendations and advice to investors and traders on how to use the mathematical model that has been developed for planning and in making better investment decisions in the face of unpredictable gold price fluctuations and minimizing the risk of loss.In addition, it should be noted that the forecasting results obtained through the Newton and Lagrange polynomial interpolation method are predictive and derived from historical data.Therefore, they cannot take into account external factors that may affect gold prices, such as changes in monetary policy from central banks, market supply and demand, or geopolitical and security factors.Therefore, it is necessary to periodically review and evaluate the forecasting results obtained to ensure that they are in line with actual conditions.

C. RESULT AND DISCUSSION
Based on 151 historical data points of daily gold prices during January-May 2023 taken from the official website of gold prices in Indonesia (www.logammulia.com),the points are matched in a cartesian coordinate, namely (x 0 , y 0 ), (x 1 , y 1 ), . . ., (x 150 , y 150 ).From these historical data points, the following points were selected as test data points presented in Table 1.Furthermore, the Newton and Lagrange polynomial interpolation method is used to build the forecasting model.In Figure 1, the Scilab software script for Newton and Lagrange polynomial interpolation is presented in general.The following is an example for the 2 nd order Newton and Lagrange polynomial interpolation results for the test data (x 0 , y 0 ), (x 5 , y 5 ), (x 10 , y 10 ) presented in Figure 2. In Figure 2, it can be seen that the interpolation results of Newton and Lagrange polynomials are the same.This is in accordance with the theory of uniqueness of polynomial interpolation (Astuti et al., 2018).Furthermore, the polynomial function is used to forecast the gold price data for x 1 until x 4 and x 6 until x 9 presented in Figure 3 as follows Furthermore, the following is presented in Table 2 the results of gold price forecasting calculations using Newton and Lagrange polynomial interpolation of order 2, 3, 5, 6, and 10 which have been obtained from Scilab software.Defined x value in the polynomial equation is the index of the desired time (date) variable.Furthermore, to compare the forecasting results and the actual data, the following evaluates the accuracy of the model using MAE, RMSE, and MAPE with the results as shown in Table 3.Based on the results in Table 3, it can be seen that the respective MAE, RMSE, and MAPE values for 2 nd order polynomial interpolation < 3 rd order < 5 th order < 6 th order < 10 th order.This means that the 2 nd order polynomial interpolation method is more effective than the 3 rd order polynomial interpolation method, 3 rd order polynomial interpolation is more effective than 5 th order polynomial interpolation, 5 th order polynomial interpolation is more effective than 6 th order polynomial interpolation, and 6 th order polynomial interpolation is more effective than 10 th order polynomial interpolation.From Table 3, it can also be concluded that the 2 nd order polynomial interpolation method is the most effective to use in forecasting gold prices because the smallest MAE, RMSE, and MAPE values are 6.895, 4.562, and 0.434% respectively.The results of this study are in line with the research of (Lamabelawa, 2019;Muhammad Julian et al., 2022).This suggests that a polynomial of 2 nd order has been able to model and forecast gold price fluctuations well.Furthermore, it can be said that the smaller the order of polynomial interpolation, the more effective it will be in forecasting data compared to higher order polynomial interpolation methods.However, it is important to remember that these conclusions are based on the data and methods used in this study.Variability in forecasting results can occur depending on the quality of the data, the time period used, and the interpolation method applied, among others.Therefore, further research and wider testing needs to be conducted to validate these conclusions.

D. CONCLUSION AND SUGGESTION
Based on the research that has been done, it can be concluded that the interpolation polynomial results obtained from the Newton and Lagrange methods on gold price data show similarities.This is in accordance with the interpolation polynomial uniqueness theorem.Both methods produce interpolation polynomials that can be applied to forecast gold prices.The forecasting results show a relatively small forecasting error rate based on the results of the MAE, RMSE, and MAPE values.Therefore, the application of Newton and Lagrange polynomial interpolation can be used as an alternative method in forecasting gold price fluctuations.During the research, it was found that the smaller the polynomial order used, the better the forecasting results.This is because the results showed that the MAE, RMSE, and MAPE values for polynomial interpolation of 2 nd order < 3 rd order < 5 th order < 6 th order < 10 th order respectively.Furthermore, in this case, it is found that the best order that gives the most effective and accurate forecasting results is 2 nd order.This suggests that a polynomial of 2 nd order has been able to model and forecast gold price fluctuations well.However, it is important to remember that these conclusions are based on the data and methods used in this study.Variability in forecasting results can occur depending on the quality of the data, the time period used, and the interpolation method applied, among others.Therefore, further research and wider testing needs to be conducted to validate these conclusions.

Figure 2 .
Figure 2. Example of 2 nd Order Polynomial Interpolation Results

Figure 3 .
Figure 3. Gold Price Data Forecasting Results

Table 1 .
Daily Gold Price Test Data Point

Table 2 .
Calculation Results of Gold Price Forecasting

Table 3 .
Results of MAE, RMSE, and MAPE