react-equation icon indicating copy to clipboard operation
react-equation copied to clipboard

Formula calculation error when we use units along with the power(^)

Open Nits7029 opened this issue 2 years ago • 1 comments

Let me explain here I am using this type of value for the formula.

Screenshot 2023-01-19 at 3 28 15 PM

and it shows output like this

Screenshot 2023-01-19 at 3 28 33 PM

And its shows the wrong answer here. if I want to get the correct answer. I have to write an equation like this. so how can I calculate power(^) for variables with unit?

Screenshot 2023-01-19 at 3 25 58 PM

And it shows output like this

Screenshot 2023-01-19 at 3 29 13 PM

that's the correct answer.

So, in the first case, the formula variable with the unit can't get calculated correctly with power. and second case it is correct but I can't write a formula like this in my case.

Nits7029 avatar Jan 19 '23 10:01 Nits7029

@Nits7029 Hm, I think I disagree about what is correct here. Would you expect (2m)^2 to equal 4m or 4m^2? I would definitely argue for the latter, since it should be equivalent to 2m * 2m. Exponentiation affects units as well. I think you'd find a lot of confusing behavior with the other interpretation, I can come up with a lot of weird interactions with units and variables if that was the case.

If it's mostly a matter of how the equation looks, you could omit the parentheses around the exponents and around the fractions, because of the grouping enforced by order of operations:

0.8*(12^0.85N)/mm^2*(12^0N)/mm^2

Screenshot 2023-01-19 at 16 14 53

Note that the parentheses around the numerators of the fractions are automatically hidden in the rendered equation, since they are only necessary in the text-version. The same thing would happen with parentheses in the denominators.

kgram avatar Jan 19 '23 15:01 kgram