I am trying to implement and algorithm and I am not sure how to implement in Python.
The algorithm is given as [e ^ -ax] * [((e ^ by) - (e ^ -ax)) / ((e ^ by) + (e ^ -ax))]
Where:
^ represents power ofe is Euler's number with a value of 2.718a and b are constants and given as a = 0.2 and b = 0.45x and y are variables where a and b will always be >= 0This is what I have come up with but I am not sure if this is correct. It would be great if anyone can tell me if it's correct or is there an easier way to do this as it looks very complicated right now.
valueA = 0.2 * x
valueB = 0.45 * y
results = math.pow(math.e, -valueA) * (math.pow(math.e, valueB) - math.pow(math.e, -valueB)) / (math.pow(math.e, valueA) + math.pow(math.e, -valueB))
For computing ex, there's no need to write:
math.pow(math.e, x)
Instead, use math.exp and write:
math.exp(x)
or:
from math import exp
exp(x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With