Sunday, February 21, 2021

IslandT: Create an ascending order power integration function completed with upper and lower bounds using Python

This article will show you a simple method to create an ascending order power integration function completed with upper and lower bounds using Python which you can later use to find the answer to any integration function which you need to solve! For example, we can use this function to find the answer to the below formula!

altThe ascending order third power integration

Integration is used in many scientific and technology-related issues so it is a very important equation which scientists will use to solve many of their daily problems. Below is the full function which is good for any problem which satisfied the previous condition.

def integration(power, constant_list, upper, lower):
   
    sum = 0 # sum of upper limit
    sum1 = 0 # sum of lower limit

    for i in range(0, (power+1)):
        sum += (constant_list[i]) * ((upper) ** (i+1))/(i+1)
        sum1 += (constant_list[i]) * ((lower) ** (i+1))/(i+1)
    return sum - sum1

Let us tried to find the answer to the above formula first…

print(integration(3, [5, 3, 4, 9], 5, 3))
altSolution 1

Now let us entered negative value and rational number into the above function…

print(integration(3, [1, 3, -4/7, 9/5], 5, 3)) 
altSolution 2

Finally, what if we want to omit one of the power factor in the equation? Yes we can enter zero into the above function and get the answer we want as well!

altThe non ascending order power
print(integration(3, [0, 3, 0, 8], 8, 4)) # The answer is 7752.0

We can adjust the above function to find any type of the answer we need in the future using this base function!



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...