• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Root Finding

 
john mater
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been set an assignment to develop functions newton and bisection which use these methods to find the roots of functions. I have a function class a testfunction class and a root class, im having trouble bringing everything together.. if someone could take a look over what ive got i'd be grateful.






Function class was given to us and I dont really understand how to use it.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49841
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go through the code in the (badly-named) Function class and see what the different options in the apply() method do. They appear to work out formulae of the x^3 + 3x^2 - 5x - 3 variety. And don't use Math.pow(x, 3) for cube. Use x * x * x.
 
john mater
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, noted and changed.. how do I go about creating a test class with some arbitrary starting values and a function from Function which tests my root finding methods?
 
john mater
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Someone please help as this code is driving me crazy.. I have two Classes Function and Roots:





My question is how do I modify Roots to call/use the functions created by my Function class? Thanks
 
Campbell Ritchie
Sheriff
Pie
Posts: 49841
70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does that class compile? Please tell us the details of what actually happens.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic