简体   繁体   English

如何在Python中使用Z3查找Lagrange插值多项式?

[英]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? 我正在使用Z3库和Python语言学习数学,但是我不知道如何找到基于拉格朗日插值多项式的多项式? Eg, 例如,

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

And I want to find f(X) 我想找到f(X)

I'm work well with Scipy but When changing to Z3 library, it's have no more docs I can be found :( 我与Scipy配合良好,但是当更改为Z3库时,找不到更多文档了:(

I don't know how to answer your question in context of Z3. 我不知道如何在Z3的背景下回答您的问题。 Z3 does not contain any built-in solver for lagrangian interpolation. Z3不包含用于拉格朗日插值的任何内置求解器。 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. 然后,您可以询问Z3该系统是否可解决。 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: 当然,在python中,您可以编写:

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. 其中y0y1y2是常数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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