Numerical Methods Project

Numerical methods provide a way to compute (approximate) values of solutions to differential equations, even when we cannot solve the equations exactly.  The drawback is the large number of numerical calculations required to obtain a desired value and level of precision.  In this project, you will use technology to implement the various numerical methods and use your technological solution to solve differential equations problems.

MAT 2680 Project

(Parts I-IV due Thursday, November 9, 2022)  Use technology to compute approximate solutions to the initial value problem below using Euler’s Method, the Improved Euler’s Method, and the Runge-Kutta Method.

Initial Value Problem. Your project will be based on the initial value problem provided in the WeBWorK assignment NumericalMethodsProject.

Part I: Use technology (see “Technology Options” below) to approximate the solution to your Initial Value Problem using Euler’s Method, the Improved Euler’s Method, and the Runge-Kutta Method. See “Project Requirements” below for more details.

Part II. Find the exact solution $y(x)$ to the Initial Value Problem and use it to determine the value requested in the problem. Round your answer to 8 decimal places.
Type or write your answer to this part and submit it with your project.

Part III. Compare the exact value obtained in Part II to the three numerical approximations obtained in Part I. How many correct decimal digits did each method produce? Which method was the most accurate?
Type or write your answer to this part and submit it with your project.

Part IV. Reflection.  Write one or two paragraphs (minimum 300 words) responding to the following.  Leave your response to this part as a comment on this post.

  1. Describe your project and how it works.
  2. Describe the process of building your numerical methods calculator.  What kind of technology did you decide to use, and why? Did you encounter any unexpected challenges in completing this project?
  3. Why do we need numerical methods in addition to the other methods studied in the class?
  4. Why is this assignment included in the class (instead of just computing the various methods using a calculator)?
  5. Please include a link to your project (if it is online), or clearly state that you will be sending me the files by email (and don’t forget to do it!).

Technology Options

You can choose your technology tool for this job – use any one of the following:

  1. a spreadsheet (Excel, Google Sheets, or other spreadsheet)
    • if you choose to create a spreadsheet, you should have columns for$x, y, f(x,y)$ , and so on, and each stage should appear in its own row (See Project Requirements below for more details)
    • HOW TO SUBMIT: If your project is a spreadsheet, either share it with me (if it is in Google Sheets or a similar cloud-based platform), or email the file to me as an attachment.
  2. a programming language (Java, Perl, or other programming language)
    • if you choose to write code, your program should output the values of $x, y, f(x,y)$ and so on at each stage (See Project Requirements below for more details)
    • HOW TO SUBMIT: If your project is code, please submit it using an online coding site like ideone.com â€“ once your code is working on the site, you can simply submit a link.  If you are using a programming language not supported by ideone.com, you can email the source code to me (for Python, try this site).
  3. mathematical software (MatLab, Maple, Mathematica, or other mathematical software)
    • if you choose to use mathematical software, your program should output the values of $x, y, f(x,y)$ and so on at each stage (See Project Requirements below for more details)
    • HOW TO SUBMIT: If your project uses mathematical software, either share it with me (if it is in MatLab Online or a similar cloud-based platform), or email the file to me as an attachment.

Project Requirements

  • Your solution must be able to carry out Euler’s Method, Improved Euler’s Method, and Runge-Kutta (you may implement these as three separate spreadsheets or programs if you wish).
  • Your solution should display all the points $(x,y)$ found along the way, not just the final point.
  • Your solution should also display other values found while carrying out each method:
    1. Euler’s Method: display the slope $f(x,y)$ at each stage
    2. Improved Euler’s: display the values of $k1, k2$ at each stage
    3. Runge-Kutta: display the values of $k1, k2, k3, k4$ at each stage
    4. You can display other values as well, if you wish (for example, the intermediate y-value in the Improved Euler method that we refer to as $z$).
  • Your solution may NOT use any built-in version of these methods (for example, most mathematical software contains a built-in command for Euler’s Method – you can use this to check your work, but you need to create your own solution).

Test Your Project

Test your project.  Data for the first few stages of calculation using each method can be found in WeBWorK.

20 Comments

  1. Claudio Malvino

    For my numerical methods project, I chose to use Python 3.9 as my programming language and I used the Spyder IDE through Anaconda. The reason that I chose to use this language over any other method is because it is a language that I have been learning how to use and because I knew that the for loop would be ideal for numerical methods. The code works by essentially following the steps for solving each respective numerical method. I first utilized the lambda function to construct the given differential equation in order to solve for the slope at any given point x and y. I then utilized a for loop to calculate the slope and y at every point along the domain x = [3.0, 3.48] of the graph of our given f(x,y). The only distinction between each numerical method in the code is slight alterations or additions to the for loop in order to get the desired values, but it really came down to using arrays and indices. I encountered difficulties with structuring the loops properly and getting the correct outputs. I also spent an absurd amount of time trying to figure out why I wasn’t getting the correct values for the Improved Euler’s method and it turned out to be because I didn’t correctly envelope the sum of k1 and k2 in parenthesis, so the program did the arithmetic in its own order. We need numerical methods in addition to the other methods studied because there will be times in which the differential equation will be too difficult to solve by hand therefore getting an exact solution is not viable and the use of a numerical method will give a very accurate approximation, plus when done computationally it saves a lot of time. The reason why this assignment is included in the class is because it provides an opportunity to learn a new tool and is a great exercise in problem solving. It also forces you out of your comfort zone and puts you in a great position to have to think creatively. Furthermore, it allows for students to also experience how differential equations are solved in industry and academia, through the use of powerful programs. Professor, I will be emailing the script and the document with my exact solution to you.

  2. abdelhameed nasr

    For my numerical method project, I decide to use MS Excel because It was simple, straightforward, and less time-consuming. Calculating an ODE solution by hand either Euler’s, Improved Euler’s, or Runge-Kutta can be a very tedious process, the process is simplified through MS Excel, where the x values are specified, and y values are recursively calculated from the previous value. As I was building the project I did not counter any major problems. My project works by using Excel to approximate the solution to the initial problem by using the equations learned in class and online resources. For Euler’s method the slope f(x,y) was displayed, In Improved Euler’s displayed values at k1,k2,z, and approximate y and In Runge-Kutta method in this case the fourth-order, The Runge-Kutta method displayed the values of k1,k2,k3,k4,z1,z2,z3,z4, and approximate y. Numerical methods are needed because they provide a way to solve problems quickly and easily compared to analytical solutions. Numerical methods are used for deeper understanding to predict the anomalies which are not possible in another method because another method can only solve only two or three unknown variables, but numerical methods can solve those variables more accurately. Analytical methods are the most rigorous ones, providing exact solutions, but they become hard to use for complex problems. And that is why the Numerical method has become popular with the development of computing capabilities and gives approximate solutions. They have sufficient accuracy for engineering purposes. The applications of the numerical method are many some of them are solving complex heat transfer problems involving mechanisms such as conduction, convection, radiation, and many other fields. The reason this project is included in this class is to provide an opportunity to understand and learn a new skill to solve the ODE that is complex. And to provide students with experience of why the Numerical method is useful and their use cases. Professor, I will be emailing you the spreadsheet and a word document that contains the answer for parts 2 and 3. 

  3. Indrid

    For this Numerical Methods Project, I used Microsoft Excel. The reason for this was that even though I was familiar with using coding languages, Microsoft Excel in my opinion seemed the most enjoyable and less time consuming to use. Using the example provided using Microsoft Excel, I encountered no problems. I separated all the variables into different columns, which made it easier to differentiate what’s what. In each column, I typed in the initial values such as the step size, and provided the initial x and y value. After this, using the formula’s we learned in class about each method, I added them and specified the location that the values will be from. For example, to find k using Euler’s Method, I would use the First Order formula given and specify where to get x and y for the formula. In my example, we were given y’ = 9x-3y, using this, I typed in “=9*(c6 [which is the location of x in my case]) – 3*(D6 [which is the location of y in my case])”. The only issues I encountered in this project were me confusing formula’s. For the Improved Euler’s Method and Runge-Kutta Method, I forgot that you’re supposed to divide the step size by 2 in order to find the z and k values. This made me confused for 15 minutes until I finally figured it out. Numerical methods are extremely important in which it helps us be a lot more accurate when trying to find the next points of a function. While these methods are a lot more tedious and time consuming, they help us when encountering an equation that is too complex to solve. While Analytical methods help us find the EXACT solution of a function, like I said before, some functions may be too complex to solve. We were assigned this project to further understand how to use our resources to make life easier for us. In the future, we will not be using these methods on paper, writing down each and every value. To aid us in learning how to make things simpler and less time consuming, this project was created. I have already sent the project as an Microsoft Excel file to your email.

  4. Jon Molina

    The method used for this project was google spreadsheet as it is similar to excel and best of all free. A spreadsheet is able to create formulas and adapt them into data that will help create the laborious process of calculating a Numerical Method. Three sheets were created for Euler’s, the improved Euler’s and the Runge-Kutta. There was a slight difficulty regaining my familiarity with a spreadsheet and adapting the formulas for the numerical method into it. But when the first method is figured out, the other methods flow together with ease with minimal alterations.

    The numerical methods are used in many applications in engineering and are helpful in the use in graphing out functions and IVP’s. This project was created to show a quicker and more efficient way to compute these methods as opposed to manually computing them in a calculator. It also helps to gain any type of experience for any application used in their creation.

    The Files for Parts 1 to 3 will be sent via email.

  5. Rayon D.

    For the project, I used Microsoft Excel. I used Excel because it was the software I was most familiar with compared to the alternatives. I separated all the variables and numbers into separate cells to avoid clutter and make it easy to read. I wasn’t sure/did not know how to do the Runge kutta and certain parts of the improved Euler method. I believe this specific topic is one of my weak points that I need to address. Numerical methods are needed cause they provide a simpler way to solve problems quickly compared to analytical solutions.

  6. Matthew

    In this project, I used Microsoft Excel in order to set up a numerical method calculator. I would first start off creating a formula that would give the slope of the function x and y in order to find the next coordinate point in Euler’s Method. Afterwards, my function would become more advanced as I progressed into designing the “Improved Euler’s Method” and “Runge Kutta Method”. I would build up on Improved Euler’s Method by finding not only the slope of the current coordinate but also the next step up and average it out to get a more accurate slope. The Runge Kutta method would also build upon both the Euler and Improved Euler by using parabolas to get a more accurate approximation. Although it’s not exactly a parabola that is being designed using quadratic function, I used coordinates that would soon form a parabola. Some problems that occurred while forming a calculator is the thought process into designing a Runge Kutta Method calculator. Since the Runge Kutta method uses a parabola in order to approximate a closer result, I needed to find a way to calculate the parabola without using a quadratic function to confuse me even further. Numerical methods are studied in class in order to make closer approximations to the value by using simple addition, subtraction, division and multiplication. Although this may sound like we need to take a differential equation and solve it with brute force, it’s a lot tedious for us to work with these numbers. This is different for the case of a computer which allows us to easily compare our answers to an approximated result from a computer. I feel like this assignment was included in the class to help us understand that we have powerful sources not just in our brains in order for us to solve these differential equations. We can design softwares and we can utilize these in order for us to compare and contrast the errors that humans may have while doing these equations. In short, I believe that we can struggle having to do these numerical methods with all these numbers that we’re dealing with and even if we made a mistake on one coordinate or problem, this may alter the answer. Rather than relying on ourselves, we can support ourselves with automated machines that can calculate with no errors if the function were to run properly.

  7. Naila

    For my project, I decided to program my methods using Java. All of my programs are composed of two methods; the main method and a calculation method. The main method prompts the user to enter the values of x, y, h, and xi + 1. It then takes those values to the calculation method and returns the final value. I used the print function to display the values. I used the scanner function to accept the user’s values. I used a while loop to do my calculations until it got to the desired x value. I started with the Runge-Kutta method and worked my way to the Euler’s method because I knew that if I could do the most complex one then the other would be easy. I did not encounter any problems however there were some annoyances. For example, my x value was supposed to increment by 0.05 but the program made it a longer decimal; 0.0499999999. In addition to the method that we have learned in class, the numerical method gives a deeper understanding of how to use a differential equation and it also results in a very close approximation. To fix the problem I added a decimal function that presented x to the 2nd decimal place. this project was included because it is very time-consuming to calculate each of these numerical methods with a calculator.

  8. Luke Gruber

    For this project I decided to go with a python code because I’ve used python for CS courses before. My code starts off by checking that the file name is main.py and then runs the main function. My main function consists of calling the runem, runiem, and runrk functions. The runem function is what performs the Euler’s Method, it takes the parameters for (xi,yi) and h. Inside the function is a for loop that iterates 6 times because n=6 which calls the function emstep every iteration and assigns it to a list newValue. The function emstep is every step of the method that results in (xi+1,yi+1) and returns the values that get put into newValue. Once the values are returned into the list, the new x-value (xi+1) is set to xval from index 0 of the list and the new y-value (yi+1) is set to yval from index 1. Once the loop iterates 6 times the function will print the approximated result rounded to 8 decimals. The other functions run similarly to runem and emstep functions with runiem and iemstep corresponding to the Improved Euler’s Method and runrk and rkstep corresponding to the Runge-Kutta Method. The process of completing the code was slow, it was hard to keep track of the variables when I was keeping them as global variables, so I decided to make 2 functions for each method in order to help keep track of the variables. Another challenge was remembering syntax for python such as concatenating strings and float values. In order to combine them the float has to be converted to a string first which can be solved by putting str() and then the value in the parentheses.

  9. ibrahimmuhammad

    My project is a Numerical Methods Calculator that takes two values in the formula y’ = Ax-By, where A and B are the x and y values respectively. It also requires an initial condition x and y value to be inputted along with a step size in order to perform its calculations. Once all values have been entered, the chart will display up to 9 digits. A graph will also demonstrate the coordinates to make the data easier to visualize. I decided to use Google Sheets because I am familiar with how it works and it is far easier to use than coding languages since I am not that good at programming. A few challenges I encountered was trying to plug in the formulas and see the data because I would often get a “#REF” error due to a minor mistake in the spreadsheet’s cells. Also for the Runge Kutta Method, some of the decimal values would fall off due to Google Sheets not fully understanding some of the data inputted, however the data was within a 10% give or take percentage range. We need numerical methods in addition to the other methods studied in the class because they prove if something works. They provide a way to solve problems quickly and easily compared to analytic solutions and the concept of numerical methods are used by engineers, physicists, and data scientists. It is also important to do this by hand and not through an algorithm in order for us to understand the inner workings of numerical methods.

    All the work which includes a PDF, Excel file, this document, and a link to the project itself will be emailed to Prof. Rietz. Along with this part 4 reflection being submitted in Openlab.

  10. Raymond manaf

    For the this Numerical Project, I used Excel as that is what I am most familiar with. Starting with the usual Euler’s Method, I first wrote down the Xi and Yi of my equation, and then the y = 8x-6y. After that I make a table on excel and added i,h,xi+1,m, and yi+1 on it. h and xi+1 are mostly given. h is 0.05 and xi+1 is 5.1 +0.05 every time. for m, i used the formula 8*(xi+1)-6*(yi+1). for yi+i, I used formula the previous yi+i + (m*h).

    The difficulty of this project for me was finding the right formula to placed it on the correct tables. I messed up a ton and finally after multiple trial and errors I completed the Euler’s method table. I then used similar approach to finish the Euler’s Method Improved. I used Z instead of m this time, and I added k1 and k2 to the equation. the final formula for the y1+1 is the previous y1 + h(k1+k2)/2 . This is also confusion to built at first because the order of which the numbers must be computated is not clear. Do I compute Z first or k2 first? I didnt know at first, but after multiply tries I got it right and perfect.

    For the Runge Kutta, this one is pretty straight forward to me as I just follow the formula from my note book and plug in k1, k2, k3, k4 and for the yi+1, the formula is y1+ (k1+2k2+2k3+k4)h /6 .

    For part 2 and part 3, I used online website to find the actual answer for the Euler’s method and Runge Kutta. contrary to my belief, my Euler’s method answer is the same as the actual answer on the website. meanwhile, my Runge Kutta answer is slightly off from the website’s answer. I do not know which one is the actual correct one.

    We need numerical method in addition to other methods because we can use this method in case we cannot find an answer the original way, so we find the closest answer to it.

    This assignment is included in this class probably because we need to be able to compute and make the system ourselves. so in case we needed it, we can do it.

    I will be sending the files to your city tech email professor.

  11. Justin Andrew

    For the Numerical Methods Project, I used Microsoft Excel to plot variables and their given functions. I had decided to use Excel since I have the most experience with it, and it does not take me much time to understand its functions in my efforts to reach the given goal. For Euler’s Method, I calculated the k with f(xi,yi). Improved Euler’s method demanded the averages of k1, and k2 alongside yi and h to find yi+1. For Runge Kutta, I had to find k1, z1, k2, z2, k3, z3, k4, and z4. To do this I used function formulas for each k, and steps for z. One challenge I had faced through building this project is that I was not able, but close to reaching the test numbers through my Runge-Kutta output. Despite tweaks and reevaluations, I couldn’t find an issue when browsing my notes or online resources, so I left the final output alone. Numerical methods are a great tool to study since they allow for a large amount of data to be found along a tangent line quickly, and efficiently. Numerical methods are necessary for differential equations studies since it allows us to explore more concrete applications of differential equations and the fundamentals of analyzing many points on tangent lines. I have sent my files via email.

    • Raymond manaf

      yoo same i used excel too. my answer on the euler’s method is more accurate than my Runge Kutta i dont know why.

    • ibrahimmuhammad

      I had a similar experience. I think that the Euler is more accurate overall and also more simple.

  12. aiden

    https://replit.com/@AidenRivera4/Runge-Kunta?v=1

    https://replit.com/@AidenRivera4/Eulers-Improved?v=1

    https://replit.com/@AidenRivera4/Eulers-Method?v=1

    What I decided to do for my project was make a code using  the coding language C++. Basically what I programmed the code to do was be able to use a given set of numbers/Variables and construct a full answer for every step of a certain Numerical Method. The three methods used are Euler’s Method, Euler’s Improved, and Runge Kunta. Each method has the same starting numbers but each is more accurate than the last. Euler’s method being the least accurate and Runge Kunta being the most accurate. I decided to use coding because I’m currently a Computer Engineering Major so I code on a normal basis in other classes. I’ve learned many languages including C++, Java, C, Linux, and Python. C++ is my most recent language so it’s more common at this moment for me. I didn’t get any drastic challenges unless you count slightly forgetting how to code. With so many coding languages sometimes you mix up the languages you learn. That was my only challenge. When asking why we need numerical methods a simple answer I can give is NASA. You can actually say we are learning rocket science because numerical methods can be used in finding a rockets landing spot. As shown in the movie “Hidden Figures”. I believe this assignment is included in this class because it gives a fun way to remember such a long process. There are many equations and steps in numerical methods, so this gives us a more fun and easier way to remember. If we did the normal casual way of learning it probably won’t stick in our heads as well as this would. Having to write the steps and equations over and over again creates repetition which then creates memory stored. It becomes almost like muscle memory. I actually enjoyed doing this project. I may not be used to doing stuff like this in a math course but it was a nice twist. Would I do it again if given the chance. Would i like to do it all the time, probably not, but still I liked it and that’s all that matters.

    y(2.9)=?

    Eulers: 2.44299

    Eulers I: 2.34144

    Runge: 2.35029 (Most Accurate)

  13. Diego

    This project was based on numerical methods, which essentially is a process to find a point, based on numerical evidence without exactly knowing the equation. These types of methods are more common in space travel for instance because when launching something into orbit, any change in force will change the trajectory of the rocket so the equation (path it travels) changes as well. Due to the uncertainty of the equation, there is a method to ESTIMATE where the rocket will be at a given time, following the path not exactly, but numerically. For my calculations, I used Google Sheets due to its convenience and my prior experience with both Excel and Sheets. I chose Google Sheets because it is easier to edit on my phone than Excel, plus I use Google Chrome. Google Sheets does that math for you and you just have to plug in certain numbers, I find that easy and the process was not difficult. Although I did have to be careful numerous times because of the way that I put the equations on the cell of the spreadsheet. Occasionally, I would miss a negative sign, or type in Euler’s number incorrectly. We need numerical methods in addition to other methods because they are still a branch of differential equations that can help us estimate a point of (y) when the equation is not necessarily reliable. The other methods can be used because we know we can gain one solid equation and find points along that equation. What do we do when, for example, the equation is not explicit BUT we have a valid starting point? That is the basics of numerical methods like Euler method. This assignment is included not just the calculations because, anyone is able to calculate using MATLAB, Excel, or Google Sheets but the most important takeaway should be the understanding behind “why” we use these methods. If a person can understand the fundamentals of Euler’s method, improved or Runge-Kuta Method, the reflection is responsible for displaying that.

    I will send my Google Sheets link via Email and a separate PDF showing the work I used to find y in Part II

  14. Shane

    This project was based on Numerical Methods which is are very key techniques in the world of math, physics, and engineering. Which makes sense why I have to take this class because I am an engineer. These numerical methods are used by NASA to project spaceship trajectory as seen in the movie Hidden Figures. For my project I was given the problem dy/dx= 6x-3y and that y(4.7)=0.9. I used Microsoft Excel for my project because that is the software that I am most familiar with. I have used microsoft excel in the past and am training in Microsoft office so this was my top option. The actual answer to my initial value problem (6.34) was different of those found in my numerical methods (7.3) but it was closest to the Runge Kutta method. I believe this is the most accurate method because it contains multiple steps and tracks the trajectory of the slope at any points. Some challenges I faced while doing my project was a ton of list error saying that I could not contain letters in my equations. I clearly knew that but could not find what was wrong until I discovered adding a “$” symbol will help with the list error. This affected me because I only listed my “h” once instead of on every line. It is important for us to go through trial and error to the learn the methods this way because its helpful to understand the origin of things. Also, if all computers were to go down someone would have to know how to do the math. I enjoyed this project and now understand all three numerical methods perfectly.

    • Shane

      Professor I emailed my excel file as an attachment

  15. MOHAMED KANTAKO

    For this project that is based on Numerical Methods, We were asked to choose a technology tool to provide multiple solutions for the initial value problem. For instance, I choose to provide my solutions using Google spreadsheet. Basically, I used formulas to make up my table using both Euler’s methods and Runge-Kutta’s method to approximate the solution closest to the exact solution to the problem. Building a numerical method calculator for this project made me realize a lot of things but one of them is that it takes a real struggle to learn from mistakes. Along the way there were some obstacles that I faced, like differentiating and finding out the right formula for the table in order to make the process easier and simple. Numerical methods are crafty methods to find out the solution to the problem with a formula that is easy to understand and manipulate. This project may be assigned to students because it helps enhance their skills to solve future problems they may encounter. I already sent you an email with my project attached to the file.

  16. Elliott Stewart

    For this project, it was based on Numerical Methods, which is essentially the method to find points constructed from numerical values without any knowledge of the real equations or any real solutions. Numerical methods are applied in many aspects of everyday life in the fields of physical sciences. The project calls for the use of technology tools, my choice being excel spreadsheets. Im personally not too familiar with coding languages besides Matlab a little bit so using excel will allow me to provide my solutions for the initial problem dy/dx=4x-7y with the condition of y(3.5)=0.1. The value to approximate to is y(3.86) [Exact solution: 0.70408167]

    So first starting with Euler’s method, I began on paper, mapping out my values with the proper formula to make sure I was lining up precisely with the given values presented in webwork. Afterwards, I input the required information, labeled them as i, h for step size, x_i, y_i, k=f(xi,yi), y(i+1). With the applied formula: 4(A)-7(B), y_i+hĂ—f(x_i,y_i), the approximations then put themselves in place. Continuing on to the Improved Euler’s, it turned out to be as simple as the first method. Using the formula: y_i+h/2 (k_1i+k_2i), z(i+1)=y_i+hĂ—k_1i, x(i+1)= x_i+h k_2i= 2(x(i+1) )-(z(i+1)the answers again followed suit down to the x=3.86. I only then began to see an issue when dealing with the runge-kutta. The values I placed would not go past x_2 & y_2, so I was stuck on that for quite a bit. I don’t think I understand the last method too well. The formula for this method is supposedly y(i+1)= y_i+h/6 (k_1+2k_2+2k_3+k_4), using this I believe I got fairly close the approximation I needed, so I left it as is.

    We need Numerical Methods while working with problems such as differential equations because it allows for us to obtain a sufficient approximation over just crunching numbers to a level where we aren’t able to comprehend. It saves tons of times while still getting the job accurately done. The reason this project was assigned was maybe to give another perspective or give us students a new tool in going forward with our classes and perhaps careers and seeing how it could be applied in the real world, just for experience and knowledge.

    Prof. I have sent the spreadsheets via email.

Leave a Reply

Your email address will not be published. Required fields are marked *