Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Multiplication going wrong

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)

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading