i mean that when u try to calculate equation above , u made lots of mistake because of missing parantheses or extra prantheses. i want to find a way or a tool that make calculations correctly and easily.
lets try to calculate â(l(R^2+2b^2))/(b^(2 ) g) this equation with
l=2, R=3,b=4,g=5 . the result should be 1.01242.
No it shouldn’t. Substitute the values:
â(l(R^2+2b^2))/(b^(2 ) g)
= â(2Ã(3^2 + 2Ã4^2))/(4^2 Ã 5)
= â(2Ã(9 + 2Ã16))/(16 Ã 5)
= â(2Ã(9 + 32))/80
= â(2Ã41)/80
= â82/80
= 9.05554/80
= 0.11319
Your answer 1.01242 is incorrect. The only way to get that answer is to
shift one of the closing brackets so that the square root covers the
entire expression, not just the denominator:
â(l(R^2+2b^2) /(b^(2 ) g) )
See how I moved one closing bracket ) next to the division and placed it
all the way to the end? Now you get 1.01242 as the answer.
could you do it in
first time and easily? that is what i mean. thank you
Yes.
Change the â to math.sqrt:
math.sqrt(l(R^2+2b^2))/(b^(2 ) g)
Change the ^ exponents to **
math.sqrt(l(R**2+2b**2))/(b**(2 ) g)
Remove the unnecessary brackets (parentheses) around the constant 2:
math.sqrt(l(R**2+2b**2))/(b**2 g)
Insert multiply operator *
where you have implied multiplication:
math.sqrt(l*(R**2+2*b**2))/(b**2*g)
and there you go:
>>> import math
>>> l=2; R=3; b=4; g=5
>>> math.sqrt(l*(R**2+2*b**2))/(b**2*g)
0.11319231422671772
Perfect in one go! If you want the other answer, move the closing
bracket:
>>> math.sqrt(l*(R**2+2*b**2))/(b**2*g)
0.11319231422671772
>>> math.sqrt(l*(R**2+2*b**2)/(b**2*g))
1.0124228365658292
The problem here is not Python, it is that you had the bracket in the
wrong place.