简体   繁体   中英

How to find Lagrange Interpolation Polynomial with Z3 in Python?

I'm learning math with Z3 library and Python language, and i don't know How i can find a Polynomial based on Lagrange Interpolation Polynomial? Eg,

I have
f(0) = y0
f(1) = y1
f(2) = y2
....

And I want to find f(X)

I'm work well with Scipy but When changing to Z3 library, it's have no more docs I can be found :(

I don't know how to answer your question in context of Z3. Z3 does not contain any built-in solver for lagrangian interpolation. You can set of a system of polynomial equalities where the coefficients are kept symbolic. You can then ask Z3 whether the system is solvable. It produces in general algebraic numbers for the coefficients, so I am not sure this is the fit for your application. Of course, in python you can write:

a, b, c = Real('a b c')
def f(X):
    return a*X*X + b*X + c

solve(f(0) == y0, f(1) == y1, f(2) == y2)

where y0 , y1 , y2 are constants.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM