Home > Back-end >  Multiplication going wrong
Multiplication going wrong

Time:07-04

I have a lot of data and I want to make an account with them. I calculate x, then y. When I calculate x times y, the count is going wrong, why?? Sounds like something simple, where did I multiply it wrong, please?

the result

z = 0.5

a=0.1
a2= 43

b=0.15
b2 = 40

c = 0.20
c2 = 38

d = 0.25
d2  = 36

e = 0.30
e2 = 34

f= 0.35
f2 = 33

g = 0.40
g2 = 31

h = 0.45
h2 = 30

i = 0.50
i2= 28


um = (1/z**2)*9
print('um=',um)

x = (a/z**2) (b/z**2) (c/z**2) (d/z**2) (e/z**2) (f/z**2) (g/z**2) (h/z**2) (i/z**2)
print('x=',(1/um)*x)

y = (a2/z**2) (b2/z**2) (c2/z**2) (d2/z**2) (e2/z**2) (f2/z**2) (g2/z**2) (h2/z**2) (i2/z**2)
print('y=',(1/um)*y)

#Final

print(x*y)

CodePudding user response:

It seems that you did

print('x=',(1/um)*x)

and

print('y=',(1/um)*y)

Then, when you multiplied x*y, you actually multiplied different values in comparison to what you printed.

As I understand, for it to be correct you would need something like

print(((1/um)*x)*((1/um)*y))

or

r_um = 1/um
print((r_um*x)*(r_um*y))
  • Related