This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Polynomial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Polynomial" Watch "Polynomial" New topic


Renard Sild

Joined: May 20, 2009
Posts: 1
Below I tried to describe a complex polynomial which is a part of my newton method. When I define the complex number x, for example x = new ComplexNumber (0,0), it doesn't return the right value. Also I have overriden the basic string format to make it look like a complex number, but it doesn't show. It does show if I perform an arithmic operation like when I test a method. As a beginner I am clueless.

btw all methods for the complex arithmetic operations are defined and tested, ComplexNumber(real part, imaginary part)

note: My first attempt I tried to split the polynomial into a real and an imaginary part, but that doesn't work well when the root is also a complexnumber... So I moved on to the above.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44590
Welcome to JavaRanch

Please go through that expression and work out what sort of algebraic formula it corresponds to. Use a pencil and paper and work from right to left; every time you reach a dot put round brackets () around your expression. See whether that gives the correct formula.
I don't understand the bit about "String". Do you mean what you get when you print the ComplexNumber to screen?
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 44590
Have you got it to work?
I agree. Here's the link:
subject: Polynomial
It's not a secret anymore!