This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java in General and the fly likes How to take  linear  equation as input. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to take  linear  equation as input." Watch "How to take  linear  equation as input." New topic
Author

How to take linear equation as input.

dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
ok,here is my problem i am trying to work on derivative of a linear equation.The equation is of form "A(x^2)+Bx+C".i have written my own method for finding the derivative.But this method finds the output when we give the input value of x,A,B,C.That is 4 values are given as input we get the answer .But know i have to give a linear equation as input,may be equation may vary ie somtimes it can be
1)A(x^2)-Bx+C
2)Ax-B.......and soo on.....my question is which variable and of what data type i should use to take linear equation as input,and how should i split each of the elements of linear equation.
if anybody have some suggestions you are welcome.Thanks in advance.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

Every second or lower order linear equation can be written as A(x^2) + Bx + C.

Suppose you have the equation 2(x^2) - 3x + 1, then A = 2, B = -3, C = 1.
Suppose you have the equation 3x - 4, then A = 0, B = 3, C = -4.

So you can just have your program take the coefficients A, B, C as input, and you can represent any second or lower order linear equation with just the coefficients. Note that A, B and C aren't restricted to numbers >= 1.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
Thank you for your valuable advice it realy helped me.
 
Don't get me started about those stupid light bulbs.
 
subject: How to take linear equation as input.