Question: Please answer just question number 1.4. You will need 1.3 to answer this.so I attached the answer of 1.3. And please do it in c++
Please answer just question number 1.4. You will need 1.3 to answer this.so I attached the answer of 1.3. And please do it in c++ code. Thanks
1.4 Yield from bond price . This is the hand calculation. But it is important. . In practice, we observe the market prices of bonds and we have to calculate their yields. . Let us confine our attention to the simple case of a newly issued bond . We shall employ a bisection algorithm to calculate the yield, given an input market price for a bond. From the previous problem, you have a function to calculate the bond price given the yield. . We shall employ this function in an iteration loop. . The inputs are (i) double F. (ii) double c, int n, iv) double Bkt (v) double tol (vi) int max.iter. The output is (vii double &y . We also need an input tolerance parameter tol. Remember that a bisection algorithm needs . As a safety check, let us also input an upper limit max.iter on the number of iterations, in . The function sigmature is The market bond price be Bmarket This is the input target value for our bisection algorithm. a cutoff parameter to stop iteration. case the computations take too long. int yield from-price(double F, double c, int double B.market, double tol, int ax iter, double & y); The return type is "int not void, because the biseetion algorithm might not converge. If it succeeds, we return 0. It it fails, we return 1 The following pseudocode describes the steps. You can use it as the basis to write a working function. 1. We know that the bond price decreases as the yield increases. We also know that the bond price is a continuous function of the eld. These are both important useful pieces of infor- mation 2. We select an initial-low yield" of Mow-0.0 and an initial "high yield" ofUhigh = 100.0 3. Set Slow = 0.0 and calculate an output Bylow using price.from-yield(F, c, yJow, n 4. If IBy.low .-Bnarketl 5. We expeet By Jow to be larger than the target value Bmarket So if By low which we hope will bracket the true yield B.y low) (success). even a yield of zero is too high. Set y tol, then we are done. Set y = ylow and a function return value of 0 Bmarket it means 0 and a function return value of 1 (fail)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
