0

I'm trying to write this equation in Python. I'm not exactly sure what I'm getting wrong here. Using pow() instead of ** seemed to get closer to the correct answer, which is 0.0000195. Any help appreciated.

vix ki equation

from math import e

deltaK = 25
k = 400
r = 0.0038
t = 0.0246575
q = 0.125

deltaK/pow(k, 2) * pow(e, r*t) * q

#output = 1.953308013456722e-05
JoeyMousepad
  • 87
  • 2
  • 6
  • 1
    the output looks correct. `1.953308013456722e-05` is `0.0000195`. `e-05` implies `10 raised to -5` – Krishna Chaurasia Feb 11 '21 at 08:21
  • 1
    I believe the answer is correct e-05 means there is 5 decimal behind . – Utpal Dutt Feb 11 '21 at 08:22
  • *facepalm* I had no idea those were the same numbers. My mathematical ignorance is showing. Thank you both very much. – JoeyMousepad Feb 11 '21 at 08:25
  • 1
    Looks good. you can suppress scientific notation on display: https://stackoverflow.com/questions/658763/how-to-suppress-scientific-notation-when-printing-float-values – Lesiak Feb 11 '21 at 08:28

1 Answers1

1

try

p= deltaK/pow(k, 2) * pow(e, r*t) * q
"{:.8f}".format(float(p))

it will print the answer the way you want it converting scientific to decimal

Utpal Dutt
  • 383
  • 3
  • 18