Simple Algebra Problem

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Simple Algebra Problem

Post by dandymcgee »

Alright so creating some sort of function for random sets of numbers is usually one of my strong points, but this one has me (sort of) stumped. I need to determine y when given x and get the following results:

x | y
======
2 = 25
3 = 20
4 = 15
5 = 10
6 = 5

Here is what I have right now, but there must be a way to simplify it:
y = ( ( x - 1 ) * 25 ) - ( 5 * ( x - 2 ) )

[random]
If I remember correctly I could distribute and simplify ( not really any simpler :P ) it to:
y = (25x - 25) - (5x - 10)

At least I think that's right. (EDIT: Nevermind this doesn't work for anything other than x = 2 lol )
[/random]

The result when x = 1 is irrelevant as 1 will be a special case where y will equal 50. Is my function as simple as it gets or did I miss something?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Simple Algebra Problem

Post by Ginto8 »

dandymcgee wrote:Alright so creating some sort of function for random sets of numbers is usually one of my strong points, but this one has me (sort of) stumped. I need to determine y when given x and get the following results:

x | y
======
2 = 25
3 = 20
4 = 15
5 = 10
6 = 5

Here is what I have right now, but there must be a way to simplify it:
y = ( ( x - 1 ) * 25 ) - ( 5 * ( x - 2 ) )

[random]
If I remember correctly I could distribute and simplify ( not really any simpler :P ) it to:
y = (25x - 25) - (5x - 10)

At least I think that's right. (EDIT: Nevermind this doesn't work for anything other than x = 2 lol )
[/random]

The result when x = 1 is irrelevant as 1 will be a special case where y will equal 50. Is my function as simple as it gets or did I miss something?
It's simple linear equations (Edit: BTW this is crap they're teaching the high math class in MY school -_-'); the equation is:
y = 35 - 5x
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
KuramaYoko10
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 55
Joined: Fri Oct 31, 2008 8:02 pm

Re: Simple Algebra Problem

Post by KuramaYoko10 »

If the equation you want to simplify is "y = (25x - 25) - (5x - 10)", then you have:

y = 25x - 25 - 5x + 10 //after distributing the - sign on the second parenthesis, then
y = 20x - 15

To check it is right...
x = 2 give y = 25

y =( 20 * 2) - 15
y = 40 - 15
y = 25

So the simplified equation is corect ;)
Ginto8 wrote:It's simple linear equations (Edit: BTW this is crap they're teaching the high math class in MY school -_-'); the equation is:
y = 35 - 5x
I am afraid this is not the right answer then ...
Type a message here!!
[b][color=#BF0000]MarauderIIC[/color][/b] wrote:"Never" is never true in programming.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple Algebra Problem

Post by dandymcgee »

Ginto8 wrote: It's simple linear equations (Edit: BTW this is crap they're teaching the high math class in MY school -_-'); the equation is:
y = 35 - 5x
Haha thanks Ginto works perfectly :P

y = -5x + 35
I knew I had to use a negative since they have an inverse relationship.. just didn't know where, how did you do it?
KuramaYoko10 wrote: y = 20x - 15

To check it is right...
x = 2 give y = 25

y =( 20 * 2) - 15
y = 40 - 15
y = 25

So the simplified equation is corect ;)

I am afraid this is not the right answer then ...
Yeah it only works for x = 2 :P Thanks for trying to help though.
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
Ginto8
ES Beta Backer
ES Beta Backer
Posts: 1064
Joined: Tue Jan 06, 2009 4:12 pm
Programming Language of Choice: C/C++, Java

Re: Simple Algebra Problem

Post by Ginto8 »

dandymcgee wrote:
Ginto8 wrote: It's simple linear equations (Edit: BTW this is crap they're teaching the high math class in MY school -_-'); the equation is:
y = 35 - 5x
Haha thanks Ginto works perfectly :P

y = -5x + 35
I knew I had to use a negative since they have an inverse relationship.. just didn't know where, how did you do it?
I figured out y when x = 1, and x = 0, based on the pattern. At x = 0, y = 35. At x = 1, y = 30. Which meant the equation was y = 35 - x(35 - 5), or y = 35 - 5x. ;) Logic + algebra = awesomeness. =P
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
User avatar
MarauderIIC
Respected Programmer
Respected Programmer
Posts: 3406
Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA

Re: Simple Algebra Problem

Post by MarauderIIC »

dandymcgee wrote:x | y
======
2 = 25
3 = 20
4 = 15
5 = 10
6 = 5
You asked ginto how he got it. Here's how I would have simply thought/observed about it:

You're clearly losing 5 every time you increase x, starting from...
(1, 30)
(0, 35)

so
y = -5x + 35

But again if you had extended out to the y-intercept, you would have gotten slope = rise/run = (-5)/(1) = -5, (could have gotten slope w/o y-intercept) y-intercept 35:
y = mx + b
y = -5x + 35
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
User avatar
KuramaYoko10
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 55
Joined: Fri Oct 31, 2008 8:02 pm

Re: Simple Algebra Problem

Post by KuramaYoko10 »

dandymcgee wrote:
Ginto8 wrote: It's simple linear equations (Edit: BTW this is crap they're teaching the high math class in MY school -_-'); the equation is:
y = 35 - 5x
Haha thanks Ginto works perfectly :P

y = -5x + 35
I knew I had to use a negative since they have an inverse relationship.. just didn't know where, how did you do it?
KuramaYoko10 wrote: y = 20x - 15

To check it is right...
x = 2 give y = 25

y =( 20 * 2) - 15
y = 40 - 15
y = 25

So the simplified equation is corect ;)

I am afraid this is not the right answer then ...
Yeah it only works for x = 2 :P Thanks for trying to help though.

Sorry about that... :oops:

I followed your equation and di just one checking.. the problem foolished me xD
Here is how I would have get:

y - y0 = m(x - x0)
m = deltaY / deltaX

putting the values from your chart in...

y - 25 = -5(x - 2)
y = -5x - 10 + 25
y = 35 - 5x //which certainly works now xD

Sorry again.... take care ;)
Type a message here!!
[b][color=#BF0000]MarauderIIC[/color][/b] wrote:"Never" is never true in programming.
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Simple Algebra Problem

Post by dandymcgee »

Omg, I'm so stupid. The only reason I didn't think make x = 0 and get the y-intercept is because like I said when x = 1 it's a special case and x will never be equal to 0 ("Why would I plug in a value that will never occur in my program", is how I was thinking). I should have completely set details like that aside when I was finding the equation for the line. :)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
Post Reply