I am making a class (in software) in wich several algorithms are used to convert values. Now almost all functions need to go two way, so sg_to_plato(sg) and plato_to_sg(plato)
These algorithms I gather from online sources and literature. Is is all working within reasonable range, but the vice-versa results aren't exactly the same
sg_to_plato(plato_to_sg(18)) is not 18 but 17,9.
I now use for example:
def sg_to_plato(sg):
return 190.74*math.pow(sg,3) - 800.47*math.pow(sg,2) + 1286.4*sg - 676.67
def plato_to_sg(plato):
return plato/(258.6-(plato/258.2*227.1))+1
but these two formulas do not seem related.
Can't I "inverse" or "reverse" the formula I use for the first to use in the other? I looked at:Learning how to flip equations but my math is not sufficient to apply the theory.
Question one: Is a formula given 1 input and 1 output always reversible?
Question two: Would someone like to explain how this is done
EDIT: As Gerry Myerson correctly pointed out, the discrepancy could be accounted to the fact I am rounding, but this is not the case. Even unrounded i get approx the same result. I removed the round bit all the same.