I’ve the data corresponding to two points on the line Ff = a z + b, which meet the following condition :
0.1 a + b = 0
0.2 a + b = 0.2 (Lb + 0.2 Hg) G/L
The following code is used to find the coefficients a and b:
In[165]:= data = {{0.1, 0}, {0.2, 0.2 (Lb + 0.2 Hg) G/L }};
a z + b /.
Solve[a data[[1, 1]] + b == data[[1, 2]] &&
a data[[2, 1]] + b == data[[2, 2]], {a, b}] // Simplify
Ff = 2 (z - 0.1) (Lb + 0.2 Hg) G/L
% - %% // Simplify
Out[166]= {0. + (0.4 G (Hg (-0.1 + 1. z) + Lb (-0.5 + 5. z)))/L}
Out[167]= (2 G (0.2 Hg + Lb) (-0.1 + z))/L
Out[168]= {0. + (5.55112*10^-17 G Lb)/L}
Where, the equation Ff = 2 (z - 0.1) (Lb + 0.2 Hg) G/L is the solution calculated by hand. As you can see, it’s not consistent with the result given by Wolfram.
Thank you for pointing out this. Although Out[166] and Out[167] are also exactly the same, it’s difficult to check and compare them with our naked eye, especially at the first glimpse.
On the other hand, as you can see, the difference between them is not equal to zero, which gives me an impression that they are inconsistent with each other. So, I want to find a method to check/confirm the coincidence between them programmatically in the definition field of the independent variables.
I still don’t know how to perform the corresponding consistency check on the real number field.
but in general there will almost certainly be cases where you cannot completely reconcile the real number field with finite decimal approximations, floating point representations and calculations. This problem may most often appear when you think some numbers with decimal points represent exact quantities while Mathematica almost always interprets anything with a decimal point as approximate floating point quantities.
It seems that there is no perfect solution to this type of problem. Basically, the root cause is that there is no perfect way to accurately represent all irrational numbers in a computer.
Side remark: The following approach, which does not use any approximation, seems to be a better solution to the problem discussed here:
In[248]:= data = {{0.1, 0}, {0.2, 0.2 (Lb + 0.2 Hg) G/L }};
Y = a z + b /.
Solve[And @@ (a #[[1]] + b == #[[2]] & /@ data), {a, b}][[1]];
Ff = 2 (z - 0.1) (Lb + 0.2 Hg) G/L;
Y == Ff // Expand // Factor // FullSimplify
Y == Ff // Expand // Together // FullSimplify
(*Y==Ff//Rationalize//Simplify
Y==Ff//Expand//Chop//Factor//Simplify*)
Out[251]= True
Out[252]= True