Skip to content

Commit

Permalink
fix exponent func
Browse files Browse the repository at this point in the history
  • Loading branch information
oren-lava committed Jan 19, 2025
1 parent 79dd551 commit b303d87
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions utils/math.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

const (
DecayFactorNaturalBaseString = "2.71828182845904523536028747135266249775724709369995957496696763"
DecayFactorNaturalBaseString = "2.718281828459045235"
)

func Min[T constraints.Ordered](x, y T) T {
Expand Down Expand Up @@ -37,15 +37,15 @@ func NaturalBaseExponentFraction(numerator, denominator int64, negative bool) ma

e := sdk.MustNewDecFromStr(DecayFactorNaturalBaseString)

// Step 1: Calculate e^a
eToA := e.Power(numeratorUint64)

// Step 2: Take the bth root
result, err := eToA.ApproxRoot(denominatorUint64)
// Step 1: Take the bth root of e
eRoot, err := e.ApproxRoot(denominatorUint64)
if err != nil {
panic(err)
}

// Step 2: Calculate (e^(1/b))^a
result := eRoot.Power(numeratorUint64)

if negative {
// Step 3: Take the reciprocal
result = sdk.OneDec().Quo(result)
Expand Down

0 comments on commit b303d87

Please sign in to comment.