Equation solved for x instead of y

goldensolo

New member
Joined
Nov 4, 2012
Messages
3
I need help taking an equation that calculates the voltage based on the sccm leak rate from a flow sensor and work it to do the opposite so I can program my macro.

y=a+(b*X)+(c*X^2)+(d*X^3)+(e*X^4)+(f*X^5)

a = 1.11E+00
b = 1.79E-02
c = -4.84E-05
d = 8.14E-08
e = -7.15E-11
f = 2.45E-14
x = 25
result when x is 25 = 1.528

I need the equation to solve for x when y is known. Help, it has been 10 years since I had to do this!
 
Last edited:
I need help taking an equation that calculates the voltage based on the sccm leak rate from a flow sensor and work it to do the opposite so I can program my macro.


y = a + bx + cx^2 + dx^3 + ex^4 + fx^5


a = 1.11E+00
b = 1.79E-02
c = -4.84E-05
d = 8.14E-08
e = -7.15E-11
f = 2.45E-14


x = 25


result when x is 25 = 1.528


I need the equation to solve for x when y is known. Help, it has been 10 years since I had to do this!

Well, that equation to solve is simply:

1.528 = 1.11 + (1.79E-2)x - (4.84E-5)x^2 + (8.14E-8)x^3 - (7.15E-11)x^4 + (2.45E-14)x^5

I think what you're trying to ask for is a solution method.

Here's the bad news: there is no formula for solving a fifth-degree polynomial. You will need to use one of several numercial processes (i.e., looped iterations) that approximate x by "zeroing in on it".

I'm not sure whether you understand how involved it will be to program one of these processes into your device.

If you were dealing with something like y=ax^2+bx+c (second-degree polynomial) or y=ax^3+bx^2+cx+d (third-degree polynomial), then there would be a formula to find x given y (quadratic formula and cubic formula, respectively).

Note about notation: Do not interchange symbols x and X -- in algebra, upper-case and lower-case versions of a letter do not represent the same quantity.

Also, when y = 1.528, x = 24.968, not 25 :cool:

What sort of macro language are you working with?
 
Last edited:
Re:

The macro is based in C.

Currently I can us RSLogix to scale the voltage to the leak rate but since the signal is not linear I have to use about 20 scale rungs to get the accuracy I need. Then I have 3 leak testers running so it is unnecessarily bogging down the processor. That is why I thought I could use a macro to take some of the load and get higher accuracy since I can only get one decimal accuracy on a 16 bit processor.

Is it possible to solve it for the root of the quadratic equation, granted it would be more lengthy?
 
Is it possible to solve it for the root of the quadratic equation

Seems like you're using the same pronoun above to reference two different things. I do not understand this latest question, but I will say that your posted equation cannot be modeled by a quadratic polynomial.

I mentioned quadratics and cubics, only as examples of the types of polynomials for which there exist closed-form formulas to determine roots. :cool:
 
Yes! :cool:

Language C is more than adequate to program a numerical method (iterative loops) for zeroing in on an approximated value of x associated with any valid given y value. (You may zero in to 16-digits of accuracy, if you so desire.)

If you are aces at programming in C, then the only substantial challenge is for you to learn and understand how to implement one of the many numercical methods.
 
Last edited:
So you're saying there's a chance!

Nope - there is no chance for an "exact" solution.

Your problem has 5th. power - it is called a quintic.

It has proven that a general quintic polynomial cannot be solved in closed form.
 
So you're saying there's a chance!

Here is the way...
\(\displaystyle \text{Let}\text{ }f=a+b\text{x + c}x^2\text{ + d}x^3\text{ + e}x^4\text{ + f}x^5\text{- n}\)
\(\displaystyle \text{and}\text{ }f'=b\text{ + 2c}x\text{ + 3d}x^2\text{ + 4e}x^3\text{ + 5f}x^4\)
\(\displaystyle \text{then }\, x_1\,\text{= }x_0\text{ - }\frac{f'\left(x_0\right)}{f\left(x_0\right)}\)

n = the result you want from y, what is x?
Make a guess x0,
Put the guess into the formula and get x1
This result is a much better guess, which you can improve by repeating this process again.
 
Here is another way to approximate the root (bi-section method):

Find two values of x, xn and xp such that

f(xn) < 0 and f(xp) > 0

(1) Then calculate [xn + xp]/2 and f[(xn+ xp)]/2

(2) If f[(xn+ xp)]/2 < 0 then set (xn) = [xn + xp]/2 and repeat (1)

(3) If f[(xn+ xp)]/2 > 0 then set (xP) = [xn + xp]/2 and repeat (1)
 
Top