Results 1 to 3 of 3
 05062013, 11:12 PM #1Member
 Join Date
 Feb 2013
 Posts
 7
 Rep Power
 0
Totally lost. How do I do these seemingly easy mathematical functions in Java?
How do I do this in Java?
Java Code:Center points 1,1 & 2,2 (One and two lines below are the equation of two circles) (x1)^2 + (y1)^2 = 1 (x2)^2 + (y2)^2 = 1 Do all the operations of the above equations x^2 – 2x + 1 + y^2 – 2y + 1 = 1 x^2 – 2x + 1 + y^2 – 2y = 0 x^2 – 4x + 4 + y^2 – 4y + 4 = 1 x^2 – 4x + 7 + y^2 – 4y = 0 Multiply one of the equations by 1 x^2 + 2x – 1 – y^2 + 2y = 0 Add the equation that was multiplied by 1 to the equation that wasn't multiplied by 1 2x + 6 – 2y = 0 Put the above sum in terms of x 2x = 2y 6 x = y + 3 Take the equation that was multiplied by 1 before it was multiplied by 1 and substitute x for what x was found to equal in the above equation which was y + 3 (y + 3)^2 – 2(y + 3) + 1 + y^2 – 2y = 0 Do all the operations of the above equation y^2 – 6y + 9 + 2y – 6 + 1 + y^2 – 2y = 0 2y^2 – 6y + 4 = 0 Use the quadratic formula to solve for y ax^2 + bx + c = 0 a = 2  b = 6  c = 4 y = ( b + sqrt ( b^2 – 4ac ) ) / 2a y = ( b – sqrt ( b^2 – 4ac ) ) / 2a
Last edited by calculatingexistence; 05072013 at 01:21 AM.
 05072013, 12:10 AM #2Senior Member
 Join Date
 Jan 2013
 Location
 Northern Virginia, United States
 Posts
 5,642
 Rep Power
 9
Re: Totally lost. How do I do these seemingly easy mathematical functions in Java?
Native java has no ability to solve equations. So you need to either install a package for that purpose or use basic algebra and isolate one variable in terms of another. Then it's plug and chug.
Also note:
Multiplication is done by using *
Exponentiation is done by using Math.pow()
Square root is done by using Math.sqrt()
^ is bitwise exclusive or so don't use it for exponentiation
Regards,
JimThe Java^{TM} Tutorials  SSCCE  Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
 05072013, 01:22 AM #3Member
 Join Date
 Feb 2013
 Posts
 7
 Rep Power
 0
Similar Threads

Mathematical functions
By Stev in forum New To JavaReplies: 14Last Post: 11272010, 03:08 PM 
Totally lost with reading excel
By nkk in forum New To JavaReplies: 4Last Post: 09132010, 10:15 AM 
I'm lost, totally(pointer exceptions?)
By helpisontheway in forum New To JavaReplies: 4Last Post: 12012009, 07:41 AM 
New to Java  totally lost as to what to download
By RR_QQ in forum New To JavaReplies: 1Last Post: 09042008, 09:07 AM
Bookmarks