I have a file (data com 300 lines) which contains expressions describing a combination of a set of values and their associated uncertainties. Like:
(18.13053098972887 +/- 0.9408208676613867) + (4.198532451786269 +/- 1.006181051488966)
(11.64429613156244 +/- 0.8494858154859093) / (9.363430186640471 +/- 1.426559761587884)
(8.380090296880461 +/- 0.7207204182841811) - (14.66227215207273 +/- 1.695262722671032) (14.89348010703303 +/- 0.5526766418243718) - (11.38945635408163 +/- 0.6236755388832851)
(7.799527276109394 +/- 0.2574050770442082) + (16.72086955979466 +/- 1.110203643562272)
(9.608384727728524 +/- 0.4631992350332439) + (10.37543680415251 +/- 1.163914272905167) (4.18157352367416 +/- 0.6524763186462224) / (10.3161260811612 +/- 1.110916984908603) (3.776332299345897 +/- 1.075189965311438) - (11.53599019583698 +/- 0.7387217730283737) (14.93653570161044 +/- 1.60794403241016) / (11.83556322752483 +/- 0.466637508245185)
(13.85353967547417 +/- 0.9246529699786543) / (14.20790420838551 +/- 0.3679686461109668) (20.63305806977545 +/- 1.545379194198176) * (10.95731035336255 +/- 1.434931108092665) (20.80371993819163 +/- 1.273124703682392) + (15.93093231553212 +/- 0.5784831928649479)
(13.61241819963037 +/- 0.04285690967801981) - (7.682740816076352 +/- 0.4521933933719993)
Each line comprises one expression. The format of each term in the expression is (value +/- uncertainty), including the brackets. They are combined via addition, subtraction, multiplication and division. The usual operator precedence applies, that is: division and multiplication take precedence over addition and subtraction. No parentheses are used beyond those containing single expressions.
I need to evaluate each expression and write the result with its uncertainty to an output file with one result per line. Finally, calculate the sum of all expressions and its associated uncertainty.
Does anyone can help me with that?