Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a python functoon to implement the Newton-Raphson optimization method to calculate the IRR of cash flows. (Please include comments in code explaining steps) Write

Write a python functoon to implement the Newton-Raphson optimization method to calculate the IRR of cash flows. (Please include comments in code explaining steps)
image text in transcribed
Write a function to implement the Newton-Raphson optimization method to calculate the IRR of cash flows. The function should: 1. Take as input a numpy array of cashflows, an initial guess for the IRR (optional), and an epsilon tolerance level (optional). a. Numpy array input: Element O is the time 0 cash flow, Element t is the time t cash flow b. Set guess =0.05 as the default value if not provided by the function call c. Set =0.001 as the default value if not provided by the function call d. Hint: please google "create optional arguments function python" to learn how to make certain arguments optional and set default values if not provided 2. Implement the Newton-Raphson optimization method to calculate the IRR of the cash flows based on the initial guess and tolerance a. Hint 1: You may find it useful to define two functions. One to calculate the present value of cash flows [f(x)] and another to calculate the derivative of the present value function at a particular value [f(x)]. b. Hint 2: Please google how to implement a "while loop" in Python, which will be useful to use to know when to stop generating new guesses. 3. Provide debugging informational output via a print statement, on how the optimization method arrived at the answer a. Output should show each iteration number, what the guess is in that iteration, what the present value is at that guess and the new guess (if applicable), Something like: "Iteration \#3: Guess =7.5%,PV=12.345, New Guess =5.4% " b. Output should also show the total number of iterations taken and the final answer for the IRR 4. Output a plot where the x-axis is the iteration number and the y-axis is the IRR guess at each iteration

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

Students also viewed these Databases questions

Question

Problem: Evaluate the integral: I = 1- 1 dx 9

Answered: 1 week ago

Question

Describe the Indian constitution and political system.

Answered: 1 week ago

Question

Explain in detail the developing and developed economy of India

Answered: 1 week ago

Question

Problem: Evaluate the integral: I = X 52+7 - 1)(x+2) dx

Answered: 1 week ago