Finding Root of an Equation with Variables Dependent on Each other

91 Views Asked by At

Sorry for the title. I'm sure there is better terminology. I'd be interested to here what that terminology is haha.

Here is my problem:

If x < 40, y = 0.01
If x > 40, y = 0.02
If x > 50, y = 0.03

0 = -1000 + (x-30–[x*y])*50 

Solve for $x$ and $y$.

This is a breakeven revenue equation that would normally only include $x$ (price) but now also includes $y$ (a royalty % of price).

I need to do solve this in a way that can be accomplished programmatically with R or VBA.

It was suggested to me that I could make a guess for $y$, solve for $x$, and then again solve for $x$ and so on until I came to an answer for each. Would it not be an infinite loop?

2

There are 2 best solutions below

0
On BEST ANSWER

As you said - the best way to solve this would be to loop over all values of $y$, solve for $x$, and then see if $x$ falls within the correct bin. For instance, if you try $y=0.01$, you'll find that $x>50$, so that cannot be a solution. There is no infinite loop.

0
On

This appears to be the function: $$ f(x) = \left\{ \begin{array}{rr} 50(x-30-.01 \cdot x) - 1000 & : x < 40 \\ 50(x-30-.02 \cdot x) - 1000 & : x > 40 \land x \le 50 \\ 50(x-30-.03 \cdot x) - 1000 & : x > 50 \\ \end{array} \right. $$

Which we can simply to $$ f(x) = \left\{ \begin{array}{rr} 50\left(\frac{99x}{100}-30\right) - 1000 & : x < 40 \\ 50\left(\frac{98x}{100}-30\right) - 1000 & : x > 40 \land x \le 50 \\ 50\left(\frac{97x}{100}-30\right) - 1000 & : x > 50 \\ \end{array} \right. $$

We could try setting each statement equal to zero, solve for $x$ and see if $x$ falls within the conditions for that given equation

To do this programmatically it might be best to look over at stackoverflow