Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

1. ## Solving a polynomial

I seeking to have some ideas in order to solve polynomial equations like 5x2+3x-8where x=7, then we can substitute this value of x in the given equation and can find the total value to which can be evaluated e.g. the above equation can be calcutaled as 258, also able to solve equations with two variables.
note: polynomial equation will be provided as string!(as user input).

2. ## Re: Solving a polynomial

What have you tried so far?

3. ## Re: Solving a polynomial

Originally Posted by Mr.777
What have you tried so far?
very good question, indeed. I'm not able to think how to convert a full equation variables into system variables??

4. ## Re: Solving a polynomial

Take a copy and pen, write down the steps of solving the thing. Start coding. If you get stuck, ask here.
Can you tell me by the way, how the above equation will be calculated to 258?

5. ## The Following User Says Thank You to Mr.777 For This Useful Post:

arvindbis (March 7th, 2012)

6. ## Re: Solving a polynomial

Originally Posted by Mr.777
Can you tell me by the way, how the above equation will be calculated to 258?
Note:wesolution is in reference to equation in first post in this thread.
there value of x is 7(already given i'm damn good at these ) just put this value of x, then equation will become 5*(square of 7 i.e.pow(7,2))+3*7-8 and result will amount to 258.
where 5x2 stands for 5times the square of x.

7. ## Re: Solving a polynomial

Alright.... So, what's the problem in coding all this equation's solution? You almost did that..

8. ## Re: Solving a polynomial

problem is that equations will be much more complex like 7x4y2z3+78xz+....you can't expect how many variable it may have as it deepends only on user input.
and secondly these equations are feeded as string.
from above i can conclude that my problem is how to repsent equations in java??
I had implemented in c and c++ as there I can use pionter arthmatics using Dynamic-linked-list while jvm is mangaing pointer here. I think you understood what I'm looking!
thank you

9. ## Re: Solving a polynomial

Well, i can tell you one thing. Extract the unique alphabets from the given String, Get user values for those unique alphabets(whatever you call them in Mathematics, i guess variables), start searching the String, replace the alphabets with the values, equate them and get your answer.

10. ## The Following User Says Thank You to Mr.777 For This Useful Post:

arvindbis (March 7th, 2012)

11. ## Re: Solving a polynomial

good idea still how to get the power system to work as you suggested( i really liked the idea). I tried it but still one problem is that term of equation "5x2" means 5 times square of x that means even if I'm able to replace the variable with value it may not give correct answers for equation of higher degrees like having terms x2, x3...etc

12. ## Re: Solving a polynomial

Get the String:
String equation = user input;

Separate the string into a String list(array? arrayList?) of components.

example
equation = x^7+13x^4-22

string1 = x^7
string2 = +
string3 = 13x^4 (not sure if you need 13(x^4) to be specific
string4 = -
string5 = 22

remember multiplication and division are commutative.