Questions regarding parabolic equations

Discussion in 'Web Design' started by MateoLeo, Sep 10, 2017.

  1. MateoLeo

    MateoLeo New Member

    Joined:
    Sep 10, 2017
    Messages:
    3
    Likes Received:
    0
    I'm trying to create a function that will return y in increasing and decreasing the value, in proportion to a parabolic function.
    So really just have y increase and decrease along the line it creates.
    I'm just trying to make an image move along my screen in a manner other than only to the left in one speed. If there is a better way to create this then please let me know!

    So far I found this online but I have a vague idea of what it will return.

    PHP:
    = (** 2) - (c)
        
    = (-cmath.sqrt(d)) / (a)
        return 
    float(y)
     
  2. Andrew80

    Andrew80 New Member

    Joined:
    Sep 10, 2017
    Messages:
    3
    Likes Received:
    0
    Hello, Mateoleo, I'm new here, I'm trying to figure it out, but if I miss something please ignore me.

    That function is the quadratic equation. It's useful for finding intercepts (zeros) of linear equations. It can return two values. It should return a set of points, not just 1:
    PHP:
    import cmath

    def quadratic
    (abc):
        
    cmath.sqrt(b**- (c))
        return {(-
    d)/(2*a), (-d)/(2*a)}
    Graphing a parabola is easy. If you want to just find a few pointsyou can just apply the function for any value of xAlthough the graph is usually shown diverting from the vertexso calculate the vertex (h,kwith h=-b/2a and k=f(h), then just make a range of points up or down the x axis.
    PHP Code:
    import cmath

    class Function:
        
    def __init__(selfabc):
            
    self.aself.bself.abc

        def __call__
    (selfx):
            return (
    self.x**2) + (self.x) + self.c

        
    @staticmethod
        def frange
    (xyjump=1.0):
            while 
    y:
                yield 
    x
                x 
    += jump

        
    @property
        def vertex
    (self):
            
    = -self./ (self.a)
            
    self(h)
            return 
    hk

        def points
    (selfpairs=3step=1.0):
            
    hself.vertex
            x1 
    = list(self.frange(h-(pairs step), hstep))
            
    x2 = list(self.frange(h+1h+(step * (pairs+1)), step))
            
    y1y2 = list(map(selfx1)), list(map(selfx2))
            return list(
    zip(x1y1)) + [(hk)] + list(zip(x2y2))
    This would generate points on a graph f(x) = (x^2)/2x 1
    PHP Code
    :
    = Function(0.52, -1)
    print(
    f.points())
    print(
    f.points(6))
    print(
    f.points(step=2)) 
     

Share This Page