Problem with creating a formula

__Question:__

Attachment 20448

a) We have a folded box shaped like a rectangle with the length **b** and width **a**. The box has four squares that we fold up, these squares are the height of the box **x**. Choose a couple of values for length **b** and width **a** and decide what **x** has to be in order for the box to have the largest volume.

b) Produce a formula that enables you to calculate what **x** has to be in order to get the largest volume when only given the length **a** and width **b**.

__My attempt to a solution:__

a)

1. First i got to make a function that describes the volume of the box

2. Derive the function in order to find the maximum point of the function

3. Find out which x-values that can't be a part of the solution (this is where my first problem lies) for example that x > 0 but can't be larger than...

4. If both x values are a part of the solution, then find out which one lies at a maximum point and finding the y coordinate by inserting the x value into the normal function.

Length: b-2x

Width: a-2x

Height: x

Attempt 1:

y= x(b-2x*a-2x)

y= x(ab + b*-2x + a*-2x +4x^2)

I then chose a = 20 b = 5 (measured in cm) this gave me

y= x(20*5 +5*-2x -20*-2x +4x^2)

y= 4x^3 -50x^2 +100x

y´= 12x^2 -100x +100

y´= x^2 - 25/3x + 25/3

When solving the equation using the quadratic formula i get x= 1,16 and x= 7,16 and when searching for the maximum point i get that when x= 1,16 we're at a maximum point which gives us y = 54,94. The maximum volume being 54,94cm^3 when x = 1,16.

Attempt 2:

a= 10

b=5

On attempt 2 i got x = 3,94 and x= 1,05 and the maximum point was at x= 1,05 and y= 54,5

Attempt 3:

a= 40

b= 20

On attempt 3 i got x= 15,77 x= 4,22 and the maximum point was at x= 4,22 and y= 1539,59.

b) This is where my problem lies, creating a formula where i only need a and b to get what x needs to be in order to get the maximum volume

Thanks in advance Mathmen