1. Euler's method is a numerical method for generating a table of values (xi , yi) that approximate the solution of the differential equation y' = f(x,y) with boundary condition y(xo) = yo. The first entry in the table is the starting point (xo , yo.). Given the entry (xi , yi ), then entry (xi+1 , yi+1) is obtained using the formula xi+1 = xi + delta x and yi+1 = yi + delta x delta f(xi , yi ). Where h is the small value called step size.

Use Euler's method to estimate the value of y when x = 2.5 for the solution of the differential equation y' = x + 3y/x with the boundary condition y(1) = 1. Take delta x = 0.1, the exact solution of this differential equation is y = 2x^3- x^2. Compare your approximation values with the exact value.

2. Write a program that estimates the integral of the following function f(x) using the trapezoidal rule. see image.

where f(x) = e^-x, limits a = 1 and b = 2.

Part of your program, use at least two functions named fun and trapez that define the integral function f(x) and compute the integral.

3. The cosine of an angle can be computed from the following infinite series: see image.

Write a program that reads an angle x (in radians) from the keyboard. Then, in a function compute the cosine of the angle using first five terms of the series. Print the value computed along with the value of the cosine computed using the C++ library function.

4. (Extra credit - 2 pts) Write a program using recursion to compute a^n, where n is a positive integer.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.