Math problem
Published by: **neilrh** on 17 Aug 2012 view comments(3)

I'm having some math issues, around the concept of rectangles: lengths, widths and areas.

Now back at school we all learnt that Area = Length x Width. But the problem I am facing is to calculate the change in length and width that an increase to the area would create. Thus I have area (A) and I need to add P% scrap/waste to it, what is the new Length and Width? I'm kind of thinking that log tables might enter into this, but it's been so long since I messed with log tables that I have no recollection of where to start.

Oh and to add a kink in the works, I'm not sure which solution I need:

Area = Width x Length NewArea = Area + 10% Option 1: NewArea = (Width + Fixed) * (Length + Fixed) Fixed = ?? Option 2: NewArea = (Width + Perc%) * (Length + Perc%) Perc = ??

(Sign in to Post a Comment)

Comment on: Math problem

Posted: 7 years 5 months 3 days 10 hours 41 minutes ago

Posted: 7 years 5 months 3 days 10 hours 41 minutes ago

It's just algebra...

You want the same amount of scrap in both directions? So ...

A = W * L

// NewArea is Area + Scrap%

NewA = A + S% = A * (1 + S/100) = A * (100 + S)/100

NewA = W * L * (100 + S)/100

// NewArea is still a rectangle

NewA = NewW * NewL

// If you want the same amount of scrap all around...

NewW = W + NewS% = W * (1 + NewS/100) = W * (100 + NewS)/100

NewL = L + NewS% = L * (1 + NewS/100) = L * (100 + NewS)/100

// So...

NewA = W * (100 + NewS)/100 * L * (100 + NewS)/100

NewA = W * L * (100 + NewS)/100*(100 + NewS)/100

NewA = W * L * (100 + NewS)*(100 + NewS)/(100*100)

// But the new area is the new area

W * L * (100 + S)/100 = W * L * (100 + NewS)*(100 + NewS)/(100*100)

// As long as W and L are not zero, we can divide

(100 + S)/100 = (100 + NewS)*(100 + NewS)/(100*100)

// Multiply both sides by 100*100

(100 + S)*100 = (100 + NewS)*(100 + NewS)

// Multiply it out

10000 + 100*S = 10000 + 200*NewS + NewS*NewS

0 = NewS*NewS + 200*NewS - 100*S

// This is just a quadratic equation in NewS

// aX**2 + bX + c = 0, so a = 1, b = 200, c = -100*S

// First calculate the discriminant, b**2-4*a*c

Disc = 200*200 - 4*1*(-100*S)

Disc = 40000 + 400*S

// As long as Disc is positive, you'll have real solutions

// Back to quadratic equation, X = (-b (+/-) sqrt(b**2-4ac))/2a,

// And we already have the b**2-4ac

NewS1 = (-200 + sqrt(Disc))/2

NewS2 = (-200 - sqrt(Disc))/2

// Simple obversation tells us NewS2 will be negative, so

NewScrap = (-200 + sqrt(Disc))/2

This is almost RPG syntax already. Square root can be either %SQRT(Disc) or Disc**0.5, your preference.

You could rework this math if you wanted to keep the Scrap in decimal form, e.g. 0.10 instead of 10 (percent), but it's probably easier to just divide the final answer by 100 if you need that.

The only requirement is that the discriminant must be greater than 0, which means the original Scrap percentage must be greater -100. Negative scrap doesn't make sense anyway, so that's not much of a limitation.

For original Scrap value of 10%, this works out to new length and widths having about 4.88 percent scrap. But that's the total length and width. If the original area is centered within the new area, this would mean 2.44% on all outside edges.

Comment on: Math problem

Posted: 7 years 5 months 3 days 10 hours 2 minutes ago

Posted: 7 years 5 months 3 days 10 hours 2 minutes ago

OK - it wasn't that bad. If the original Scrap percentage (I'll call it Sp this time) is expressed as a decimal, it works out to

Disc = 4 + 4*Sp

NewSp = (-2 + Disc**0.5)/2

Where NewSp is also expressed as a decimal. Disc is positive as long as Scrap percentage is >= -1 (i.e., -100%), so no danger there. As before, when Sp = 0.10, NewSp comes out to 0.0488.

Comment on: Math problem

Posted: 7 years 5 months 3 days 8 hours 52 minutes ago

Posted: 7 years 5 months 3 days 8 hours 52 minutes ago

Well it seems to work, when I play with numbers on a calculator. Now I have to wait until Monday when we have the control tables populated, so I can run the program and see what screwed up results get pushed out the back.