Go Back   Cyber Tech Help Support Forums > Software > Web Development & Graphic Design

Notices

Reply
 
Topic Tools
  #1  
Old October 17th, 2007, 07:06 AM
jan00b jan00b is offline
Member
 
Join Date: Jun 2007
Posts: 40
Making Var Stay Put!

Greetings those who know javascript(otherwise disregard). I'm having a bit of trouble with controlling my variables. I don't know of a simple example so I'll just flat out tell you what I'm doing. I'm trying to make a system of equations solving program using the elimination method.

Lets say you have

(X1+Y1+Z1=C1)
(X2+Y2+Z2=C2)

now in substitution you multiply each factor by one factor in the opposite equation, such as..

X2(X1+Y1+Z1=C1)
(-1*X1)(X2+Y2+Z2=C2)

in this step i can say

var X1=5;
var X2=10;
X1*=X2;
//X1 now is now 50;
//now we do the second part
X2=X1*-1
//when we say X1 we were hoping for 5 but no luck since it's 50.

you see what i mean? I could create a separate variable to hold the value of X1 then use that to multiply by -1 to get X2 but I'm doing a system with 3 unknowns with numerators and denominators. Having to make a new variable for every time I want to change the X1 term, and structure wise, that just won't cut it. Any other ways around this?

Last edited by jan00b; October 17th, 2007 at 07:50 AM.
Reply With Quote
  #2  
Old October 17th, 2007, 09:28 AM
oracle128's Avatar
oracle128 oracle128 is offline
Α Ω
 
Join Date: Oct 2000
O/S: Windows XP Pro
Location: Melbourne, Australia
Age: 24
Posts: 9,401
There's no other way around it. What you need will require multiple variables. But feel free to use arrays where more efficient. My only suggestion is, for easier comprehension, never change the values of your base variables (X1, X2 etc), in fact make them constants where possible.
__________________
Oracle's backup tutorial

"A lot of people say games are addictive. Well, they're addictive in the sense that anything you like doing you repeat endlessly. But no one would say, 'Mr Kasparov, you have a chess problem,' or 'Tiger Woods, you have a golf addiction.'" - Ian Livingstone, Creative Director, Eidos.

"A problem well stated is a problem half solved" - Charles Franklin Kettering
Reply With Quote
Reply

Bookmarks

Topic Tools

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
Forum Jump


All times are GMT +1. The time now is 02:49 AM.

[ RSS ]