# Minimize a function: Find value of x that result in lowest value of formula

#### gevni

##### New member
Hi, I have this formula, What I want is to find the value of "x" (without trying all possibilities) so that the result of the formula will be the lowest possible value under the constraint when x !=0, and x<n. Here, values of A,B,C, Q, R,n are already known and fixed.

$$\displaystyle f(x)=A\left(((\frac{Q}{n-x}-\frac{R}{x})+(n-x))n\right)+Bnx+C((\frac{R}{x})n)$$

How can I find the value of x? I know that x can be between 1 to n-1. But how do I continue from there? I was thinking there must be a way to calculate it instead of trying a lot of possibilities. Like some derived equation for optimal value of x that made the whole formula sum the lowest possible.

#### gevni

##### New member
Hi, I have this formula, What I want is to find the value of "x" (without trying all possibilities) so that the result of the formula will be the lowest possible value under the constraint when x !=0, and x<n. Here, values of A,B,C, Q, R,n are already known and fixed.

$$\displaystyle f(x)=A\left(((\frac{Q}{n-x}-\frac{R}{x})+(n-x))n\right)+Bnx+C((\frac{R}{x})n)$$

How can I find the value of x? I know that x can be between 1 to n-1. But how do I continue from there? I was thinking there must be a way to calculate it instead of trying a lot of possibilities. Like some derived equation for optimal value of x that made the whole formula sum the lowest possible.
Update: I remove the constant n and then take the 1st and 2nd derivative. Now my formula is like that;

$$\displaystyle f(x)=A\left((\frac{Q}{n-x}-\frac{R}{x})+(n-x)\right)+Bx+C(\frac{R}{x})$$

I took first and 2nd derivative as
$$\displaystyle f′(x)= A\left(\dfrac{R}{x^2}+\dfrac{Q}{\left(n-x\right)^2}-1\right)-\dfrac{CR}{x^2}+B$$

$$\displaystyle f′′(x)= A(\dfrac{2Q}{(n−x)^3}−\dfrac{2R}{x^3})+\dfrac{2CR}{x^3}$$

What would be the next step to find value of x that will minimize this equation?

#### MarkFL

Staff member
Okay, what you want to do now is equate your first derivative to zero to find your critical values, that is those values of $$x$$ that may optimize the function. What do you find?

#### gevni

##### New member
Okay, what you want to do now is equate your first derivative to zero to find your critical values, that is those values of $$x$$ that may optimize the function. What do you find?
Thanks you for the reply. For finding the critical points for x do I need to put the values of known constant in the formula?

#### MarkFL

Staff member
Thanks you for the reply. For finding the critical points for x do I need to put the values of known constant in the formula?
No, you can get your critical values in terms of the parameters. There's no need to plug those in.

#### MarkFL

Staff member

$$\displaystyle f'(x)=A\left(\frac{R}{x^2}+\frac{Q}{(n-x)^2}-1\right)-\frac{CR}{x^2}+B=0$$

$$\displaystyle f'(x)=\frac{AR}{x^2}+\frac{AQ}{(n-x)^2}-A-\frac{CR}{x^2}+B=0$$

$$\displaystyle f'(x)=\frac{AR(n-x)^2+AQx^2-Ax^2(n-x)^2-CR(n-x)^2+Bx^2(n-x)^2}{x^2(n-x)^2}=0$$

As you have stated that $$x\ne0$$ and $$x<n$$, this implies:

$$\displaystyle AR(n-x)^2+AQx^2-Ax^2(n-x)^2-CR(n-x)^2+Bx^2(n-x)^2=0$$

As this is a 4th degree polynomial, I would at this point consider substituting in for the parameters (as you asked about doing) and then using software or a numeric technique to approximate the roots.

#### gevni

##### New member
$$\displaystyle f'(x)=A\left(\frac{R}{x^2}+\frac{Q}{(n-x)^2}-1\right)-\frac{CR}{x^2}+B=0$$
$$\displaystyle f'(x)=\frac{AR}{x^2}+\frac{AQ}{(n-x)^2}-A-\frac{CR}{x^2}+B=0$$
$$\displaystyle f'(x)=\frac{AR(n-x)^2+AQx^2-Ax^2(n-x)^2-CR(n-x)^2+Bx^2(n-x)^2}{x^2(n-x)^2}=0$$
As you have stated that $$x\ne0$$ and $$x<n$$, this implies:
$$\displaystyle AR(n-x)^2+AQx^2-Ax^2(n-x)^2-CR(n-x)^2+Bx^2(n-x)^2=0$$