Skip to main content
gamedev.net
🔒 Locked

Substitution

Started by muphicks Feb 24, 2005 at 6:16 PM 5 replies 1.4k views
Original Post
muphicks
muphicks
Hey all, I'm working my way through the early chapters of "Mathematics for game developers". Hope you can bear with me if the answers seem obvious... I've only just started to "improve" my maths knowledge, and think I've a lot of work ahead of me :P 1) As part of the first chapter Christopher Trembley takes the function f(x) = 2x^2 + 3x - 5 and substitutes x = y + a. I've worked through the steps myself and obtained the same final equation: 2y^2 + y(4a + 3) + a^2 + 3a -5. However, he then substitutes using 4a+3 = 0, so a = -3/4. Initially my answer remains the same has his up to the following step in the substitution: f(y) = 2y^2 + 9/16 + 3(-3/4) - 5 at which point he simplifies to 2y^2 - 49/8 I am unable to see how the equation simplifies to that. The best I can get is: 2y^2 - 45/16 - 5 Does anyone have any idea where I've gone wrong? Or is this an error with the book (probably me :P) 2) Regardless of final simplification which I'm stuck on atm... assuming I do manage to obtain his simplification of 2y^2 - 49/8, I have another question. Based on all the above, he takes an example using x=4. Plugging this into the first equation "2x^2 + 3x - 5" gives a result of 39. Plugging it in his "2y^2 - 49/8" equation it also gives 39. However, if you plug it into the unsimplified equation 2y^2 + y(4a + 3) + a^2 + 3a -5 I get a result of 37.3125. Given that x=y+a, then y=x-a and we have used a as -3/4, so y=4.75. How come this doesn't equal 39 as the simplified version does? I take it I'm doing something wrong, but I'm not sure what. I'd like to think its a mistake in the book thats driving me round in circles, but my lack of maths atm makes it hard for me to assume that :P One final question whilst I'm at it.... Given that (y+a)^2 = y^2 + 2ya + a^2 and using y=4 and a=-0.75 How come (y+a)^2 = 10.5625 yet, y^2 + 2ya + a^2 = 9.4375 I'm assuming the equation would apply as follows: 4^2 + 2*4*-0.75 + -0.75^2 = 4^2 - 2*4*0.75 - 0.75^2 = 9.4375 Or is this not how you would use the negative "a" in the equation? since doing 4^2 + 2*4*-0.75 + 0.75^2 gives the same answer as (y+a)^2 Can anyone clarify which is the correct way to handle a negative value of "a" when substituting it the equation. Any help greatly appreciated :) oh and has anyone found an errata list for the maths for game developers book? Or know of anyone maintaining an un-official listing?
JohnBolton
JohnBolton
f(y)= 2y2 + y(4a + 3) + 2a2 + 3a -5

(-0.75)2 != - (0.752)
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
muphicks
muphicks
Hi, that clears up a few of my questions, I now understand where I was going wrong with question 3 :)

However, I'm still finding a few problems, which I imagine may be to do with -ve signs again.

Question 1) I've redone my formula bearing in mind what you said about a^2 and now get

2y^2 + 9/16 + 3(-3/4) - 5 (which is the final stage the book shows before showing the final solution)

However I'm still unable to simplify this down to what the book gets:

2y^2 - 49/8

Can anyone show me a break down of the steps used to simplify this so I can find out where I'm going wrong?


Question 2)
If I take 2(y+a)^2 + 3(y+a) - 5

and plug in y = 4.75, a = -3/4 then I get the result 39. Which agrees with the book.

However, the re-arranged version of that formula: 2y^2 + y(4a + 3) + a^2 + 3a -5 when evaluated with the same values produces 38.4375. How come? I've made sure that a^2 is really (-3/4)^2 and not -(3/4)^2 :) But that just changes my final value slighly, but its still not 39 that I would expect if the re-arrangment was sound.

I'm going to have another run through all this from the start again later today and see if I can find where I'm going wrong.

Again, any help appreciated :)
Squirm
Squirm
Quote:
Original post by muphicks

2y^2 + 9/16 + 3(-3/4) - 5 (which is the final stage the book shows before showing the final solution)


3(-3/4) = -9/4 = -36/16
5 = 5/1 = 80/16

9/16 - 36/16 - 80/16 = -115/16

That's the principle. Apparantly I've got some of my 12-year-old-level arithmetic wrong though ;)
muphicks
muphicks
Thats pretty much what I did. I put all 3 terms under a common /16 and then added/subtracted as appropriate. However I end up with 9 - 36 - 80 = -107/16. So I'm still unsure where 49/8 comes from. Well probably from 98/16, but as to how the book has obtained 98 I'm at a loss atm :(

I'm pretty sure the books final answer is correct, since when I plug in the x,y,a figures I've been using it returns the result 39 as expected, so I'm guessing I'm missing something on the re-arrangment side.
JohnBolton
JohnBolton
f(y) = 2y2 + y(4a + 3) + 2a2 + 3a - 5

so

f(y) = 2y2 + 18/16 + 3(-3/4) - 5
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
muphicks
muphicks
Quote:
Original post by JohnBolton
f(y) = 2y2 + y(4a + 3) + 2a2 + 3a - 5

so

f(y) = 2y2 + 18/16 + 3(-3/4) - 5


Thank you for your reply, you've hit the nail on the head. I've made a mistake in the original re-arrangement of the forumula missing out the 2 in the 2a^2 section. Which gave me 9/16 rather than 18/16. With the 2 everything works out correctly.

I compleatly missed this as the book shares the same mistake, so when my forumla matched the books I'd assumed it was correct, and that instead my fractions were wrong :P

Cheers for pointing me in the right direction :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.