generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Algebraic equation solver

Previous Thread :: Next Thread 
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 07:00 PM
I just started it today and it isn't completely done however, I've gotten a bit of progress.

Example output :

> ax+b-2ax=x+y+x
> -1ax+b=+x+y+x --combine like terms
> -1ax+b=+2x+y --combine like terms
> -1ax=+2x+y-b --Subtract +b to both sides.
> -1ax-2x=+y-b --Subtract +2x to both sides.
> (1a-2)x=+y-b --combine like terms
> x=(+y-b)/(1a-2) --divide by
> Answer : x=(+y-b)/(1a-2)

Any ideas how to improve upon the current functionality? Make any of the current things I have running more efficient?

http://www.roblox.com/--item?id=71845995
Report Abuse
FunguyI is not online. FunguyI
Joined: 11 Sep 2009
Total Posts: 1412
06 Feb 2012 07:01 PM
This is nothing compared to the match I have, I wish mine was easier .-.
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Feb 2012 07:02 PM
You wouldn't have -1ax, you'd have (a-2)x.
:c


I like the idea, but the implementation will be a struggle.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 07:07 PM
a+0a-2a=-1a

But I did notice an error in the output,

> -1ax-2x=+y-b --Subtract +2x to both sides.
> (1a-2)x=+y-b --combine like terms

Gonna have to work better on sign recognition there -_-
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Feb 2012 07:16 PM
Woops, my bad. I didn't read the equation properly. X_X
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 07:49 PM
I fixed the sign issue.

Currently I'm just taking a brute-force approach to this.

 1. Get terms from each side
 2. Combine like-terms on each side
 3. Move all the terms from the left-side with the designated variable in them to the right-side
 4. Move all the terms from the right-side without the designated variable in them to the left-side
 5. Combine like-terms on each side to get a coefficient and x.
 6. Divide both sides by coefficient.

I'm contemplating on taking every step and turning it into a separate function then trying to figure out when the best time to use which is. But how do I judge when to do what?
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
06 Feb 2012 07:50 PM
String Manipulation?

All hail the Power of DX!
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 07:52 PM
@DX
What else would I use?
Report Abuse
DXPower is not online. DXPower
Joined: 21 Oct 2008
Total Posts: 2866
06 Feb 2012 07:56 PM
Um...

Well, I am called the Short Smart Kid at school, so:

I would first, use string.find and find all the characters.
Then, find if any are not separated by anything using captures, then, make a variable for it, knowing that it will be multiplied by it.

Then, find parentheses, and see if it not separated by something, if not, then do the same as above.

Then, find the = sign, check if there are items to the right, if there are, check to see if it is = or ~= to the otehr, then, print true or false.

That's the basic concept.

All hail the Power of DX!
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 07:58 PM
:o, can it simplify polynomials?

Like this, for example?

(5x-8^2+3x)-(2^2+4v-7x)

­<'+1 Post. Ujelly?'>
Report Abuse
ExoCross is not online. ExoCross
Joined: 26 Jan 2011
Total Posts: 179
06 Feb 2012 07:59 PM
I remember Algebra. :o
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 08:00 PM
@DX
Um, what? As you can already see from the start, it already works. That didn't help answer the question at all.
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 08:01 PM
@nate
No and that isn't even a polynomial.

(5x-64+3x)-(4+4v-7x)
5x-64+3x-4-4v+7x
15x-4v-68
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 08:03 PM
Making a string parser that can solve algebraic equations isn't as easy as you think/are saying it is.

­<'+1 Post. Ujelly?'>
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 08:03 PM
Yes, it's a polynomial...?

­<'+1 Post. Ujelly?'>
Report Abuse
SDuke524 is not online. SDuke524
Joined: 29 Jul 2008
Total Posts: 6267
06 Feb 2012 08:06 PM
?
I always thought polynomials were like
f(x)=x^4-3x^2+2x-14

But if you just want something like that, yeah the combining-like-terms part does that.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 08:08 PM
(5x-8^2+3x)-(2^2+4v-7x)
=5x-8^2+3x-2^2-4v+7x
=5x+3x+7x-8^2-2^2-4v
=15x-6^2-4v

That would be expanding and simplifying a polynomial. Not the best with polynomials, though.

­<'+1 Post. Ujelly?'>
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 08:24 PM
Try getting it to simplify polynomials, though.

­<'+1 Post. Ujelly?'>
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 08:25 PM
blah, also; sure you already know this, but 1x = x, so it would be a bit more neat to have that implemented, too.

­<'+1 Post. Ujelly?'>
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Feb 2012 09:32 PM
=5x+3x+7x-8^2-2^2-4v
=15x-6^2-4v

=8^2-2^2
=6^2


Umno.


64 - 4 != 36
Report Abuse
TheShoeBox is not online. TheShoeBox
Joined: 20 Aug 2010
Total Posts: 5022
06 Feb 2012 09:39 PM
Also, you keep multiplying variables by one.

For example, you're saying "-1ax" or "1ax"

They would just be "-ax" and "ax".

The one is pretty much invisible.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 09:44 PM
"Umno.
64 - 4 != 36"

Pretty sure when you're solving polynomials with numbers like 8²-2² you just do 8-2, 6²?

­<'+1 Post. Ujelly?'>
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
06 Feb 2012 09:46 PM
"Pretty sure when you're solving polynomials with numbers like 8²-2² you just do 8-2, 6²?"


Umno. You can't add/subtract bases, EVER.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
06 Feb 2012 09:50 PM
Ehh, yeah, that makes sense.

Would be like writing an equivalent ratio for something like 5²:2², you'd obviously need to find what they equal (25:4, then from there 50:8 or something like the such)

­<'+1 Post. Ujelly?'>
Report Abuse
StygianBlade is not online. StygianBlade
Joined: 15 Sep 2011
Total Posts: 426
06 Feb 2012 09:56 PM
"Umno. You can't add/subtract bases, EVER."


Yes you can. Take this equation:
2x + 4x = 6x

Now lets substitute x for 3:

2(3) + 4(3) = 6(3) =
6 + 12 = 18

------------------------------------

Of course it wouldn't work if you were trying to do something like:
2x + 4y

but I think you meant to say, you can't add bases WITHOUT like terms
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image