Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-24-2008, 04:27 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default [SOLVED] Algorithm for solving 2 equations, 2 unknowns
Anyone have an algorithm for solving a simple 2 equations, 2 unknown problem?
How do you do unknowns in an equation? It seems like you need a parser, substituter and reducer.

The equation(s) is y = ax + b (a straight line) where x and y are known for two points on the line. How do you find the values of a & b?

For example:
Given the points: pt1= 1,0 and pt2= 3,1
equation1 = 0 = a*1 + b
equation2 = 1 = a*3 + b

How do you write a program to solve for the values of a and b?

Also posted at CodeGuru Forums - Algorithm for solving 2 equations, 2 unknowns

Thanks,
Norm

A bit rusty with algebra:

slope = (p2.y - p1.y) /(double) (p2.x - p1.x);
intercept = p1.y - slope * p1.x;

Last edited by Norm; 08-24-2008 at 07:31 PM.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solving this equations problem in Java matt_well New To Java 17 08-30-2008 09:05 PM
Suggestions required for solving a Java problem bilal_ali_java Advanced Java 3 08-16-2008 01:11 AM
I need a help in solving this method using vectors java_fun2007 New To Java 2 11-26-2007 07:51 PM
equations Peter New To Java 2 07-04-2007 06:15 AM
Help me with this algorithm Marcus Advanced Java 3 07-02-2007 01:30 PM


All times are GMT +2. The time now is 05:34 PM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org