• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

yield calculation

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a Mathematical equation that cannot be solved linearly. Can some one help me find a simple logic to calculate yield.

Given a financial instrument which offers the annual payments

Years from NowPromised Annual Payments
1$2,000=c1
2$2,000=c2
3$2,500=c3
4$4,000=c4

The price of the financial instrument is :$7,704=P
Use the equation below to calculate the yield y:

P = (c1/((1+y)^1)) + (c2/((1+y)^2)) + (c3/((1+y)^3)) + (c4/((1+y)^4))
where P, c1, c2, c3, and c4 are above
and y is the yield of the financial instrument

Find the yield y which satisfies the above equation.

Write a JAVA console or windows program to do this.
Input :
input for c1
input for c2
input for c3
input for c4
input for price

Output:
yield y

There has to be a way to start from the approx. value. I need some advice on this.

Thanks for your help,
Vinay
 
Sheriff
Posts: 22862
132
Eclipse IDE Spring TypeScript Quarkus Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not a Java problem per se, but just a mathematical problem.

You have an equation with only one variable - y. You will have to rewrite that to make it easier. For instance:

P == (c1/((1+y)^1)) + (c2/((1+y)^2)) + (c3/((1+y)^3)) + (c4/((1+y)^4))
=== // multiple both sides with (1+y)^1, (1+y)^2, (1+y)^3 and (1+y)^4, under the assumption that y != -1
P * (1+y)^1 * (1+y)^2 * (1+y)^3 * (1+y)^4 == c1 * (1+y)^2 * (1+y)^2 * (1+y)^3 + c2 * (1+y)^1 * (1+y)^3 * (1+y)^4 + c3 * (1+y)^1 * (1+y)^2 * (1+y)^4 + c4 * (1+y)^1 * (1+y)^2 * (1+y)^3

Now rewrite that into a form of a * y^4 + b * y^3 + c * y^2 + d * y + e == 0, and solve that.

However, this is not the place for that. Moving to a more appropriate forum.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That last equation is a quartic equation. (Follow the link for more info on solving it).
 
Ranch Hand
Posts: 376
Scala Monad
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe there's a numerical method to solve it...
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could find an approximate solution with a numerical method, but quartic equations can also be solved algebraically, as is explained on the Wikipedia page that I posted a link to.
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic