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

Make a parabola steeper at both sides while keeping both ends

I’m having a parabola with both axes being from 0 to 1 as follows:

enter image description here

The parabola is created and normalized with the following code:

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

import matplotlib.pyplot as plt
import numpy as np

# normalize array
def min_max_scale_array(arr):
    arr = np.array(arr)
    return (arr - arr.min())/(arr.max()-arr.min())

x = np.linspace(-50,50,100)
y = x**2

x = min_max_scale_array(x)
y = min_max_scale_array(y)

fig, ax = plt.subplots()
ax.plot(x, y)

I want to create another one with both ends being the same but both sides become steeper like this:

enter image description here

I thought of joining an exponential curve and its reflection but that would make the resulting parabola looks pointy at the bottom.

Can you show me how to achieve this? Thank you!

>Solution :

If you want to modify any arbitrary curve, you can change the x values, for example taking a power of it:

# x and y are defined

for factor in [1.1, 1.5, 2, 3, 4]:
    x2 = 2*x-1
    x3 = (abs(x2)**(1/factor))*np.sign(x2)/2+0.5
    ax.plot(x3, y, label=f'{factor=}')

output:

enter image description here

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