Polynomials

Sort by

recency

|

260 Discussions

|

  • + 0 comments
    import numpy
    
    COEFF = numpy.array(input().split(), float)
    X = float(input())
    print(numpy.polyval(COEFF, X))
    
  • + 0 comments
    import numpy
    p = list(map(float, input().split()))
    x = int(input())
    print(numpy.polyval(p,x))
    
  • + 0 comments

    For Python3 Platform

    import numpy
    
    P = list(map(float, input().split()))
    x = float(input())
    
    print(numpy.polyval(P, x))
    
  • + 0 comments
    import numpy as np
    print(np.polyval(list(map(float,input().split())),int(input())))
    
  • + 0 comments

    My compact solution, easily a one-liner when ignoring the import statement…

    import numpy as np
    
    print(np.polyval(np.loadtxt([input()], float), int(input())))
    

    I see others cast x as float. It worked fine for me as int. Go figure!