Need to Solve for X

I.M.Gadget

New member
Joined
Jul 13, 2021
Messages
3
Hi
I am writing a program and need to convert a saturated pressure value to a saturated temperature value of particular fluids. I found a formula to go the opposite way (temp to press) so I need to change it to input the pressure (y) and solve for the temperature (x). It's been far too long since I've had to do anything like this so any help is greatly appreciated.
The formula as it is: y=A*x^4 + B*x^3 + C*x^2 + D*x + E
A,B,C,D and E are constants specific to the different fluids. So I need to x=....
Again any help is greatly appreciated.
Thanks
G
 
… convert a saturated pressure value to a saturated temperature value …
Hi I.M.Gadget. I have no knowledge of converting such values, but the purely symbolic solutions to that equation (a fourth-degree polynomial equation with four solutions) are a bit unwieldy. You can see the solutions here (they take some time to load). If you know of any relationships between numbers {A,B,C,D,E}, then we might be able to make simplifying substitutions.

?
 
Hey Otis
Thanks for your reply. I had totally forgotten about Wolfram. And you're right, the resulting solutions are completely unwieldy.
So the equation for one particular fluid is:
y=.00000008x^4+.000009x^3+.0074x^2+.8101x+23.558
And it fairly accurately follows the curve described by the attached pressure/temperature chart. Unfortunately, the programming language I'm using doesn't have a table or curve function. So I guess what I need to do is construct a new equation with pressure (y) as the given input and temperature (x) as the result.
 

Attachments

  • R22-PT-Chart.pdf
    132.1 KB · Views: 6
Hi
I am writing a program and need to convert a saturated pressure value to a saturated temperature value of particular fluids. I found a formula to go the opposite way (temp to press) so I need to change it to input the pressure (y) and solve for the temperature (x). It's been far too long since I've had to do anything like this so any help is greatly appreciated.
The formula as it is: y=A*x^4 + B*x^3 + C*x^2 + D*x + E
A,B,C,D and E are constants specific to the different fluids. So I need to x=....
Again any help is greatly appreciated.
Thanks
G

I don't think that a mathematical solution for that polynomial could be viable. The Ferrari's formula is extremely complex and involves a lot of steps. And programming that, could be a major issue and it will take you several days. I would try to use the following pseudocode:

t := -49

do t := t+1 untill P(t) > Pset or untill t = 150

return t -1
 
Hey Otis
Thanks for your reply. I had totally forgotten about Wolfram. And you're right, the resulting solutions are completely unwieldy.
So the equation for one particular fluid is:
y=.00000008x^4+.000009x^3+.0074x^2+.8101x+23.558
And it fairly accurately follows the curve described by the attached pressure/temperature chart. Unfortunately, the programming language I'm using doesn't have a table or curve function. So I guess what I need to do is construct a new equation with pressure (y) as the given input and temperature (x) as the result.
Did you try using Excel - and investigate the best fit curve?
 
y = 0.00000008x^4 + 0.000009x^3 + 0.0074x^2 + 0.8101x + 23.558
… a new equation with pressure (y) as the given input and temperature (x) as the result.
Those new equation(s) -- in the form of x ≈ [an expression in terms of A,B,C,D,E and y] -- is what wolframalpha displays. That's it.

How did you get the coefficients, in your example equation above?

When I'd looked at your attachment, I wondered whether the data could be estimated with a 2nd-degree polynomial, instead. I also thought about using a numerical approach (similar to a root-finding algorithm), to zero in on the x-values you seek.

?
 
@Otis - I found the coefficients on an HVAC forum from quite a few years ago. The OP had discussed 2nd and 3rd degree polynomials but said they weren't accurate enough for proper control/safety of the equipment.
@Subhotosh Khan - You're the second person to suggest using Excel. I'm going to look at it and see if I can figure it out. Thanks
 
You might want to compare the following to the results that you get from Excel. I used the figures in the pdf and the "polyfit" command in Python (with a ninth degree polynomial output). FYI: I noticed that the following mapping helped the polynomial fitting to get better results [imath]u = (y+54)^2[/imath] where y is degrees Fahrenheit.

Code:
x = sqrt((((((((( - 0.0000000000000001395945616*y + 0.0000000000002329183924)*y - 0.0000000001614143373)*y + 0.00000006013832832)*y - 0.00001303489215)*y + 0.001664128528)*y - 0.121308331)*y + 4.6056917)*y + 55.236057)*y + 183.4331) - 54
 
If pressure values are restricted to 0 < y < 381 then try the following, simpler, equation...

x = sqrt(((((( -0.000000000034839534*y + 0.000000044950085)*y - 0.000023401971)*y + 0.0065232551)*y - 1.1853378)*y + 281.235)*y + 2867) - 95
 
Top