利用Lagrange內插法滿足 f(x)=log e (x)=ln (x) -----(b)
'''
n=3
xa=1.5
1.0 0.000
1.2 0.182
1.4 0.336
2.0 0.693
/* Lagrange Interpolation Algorithm
* Read in data file of ex1-4.dat which has n point values
* and the value of interpolating point xa. Based on Lagrange
* Interpolation algorithm to compute p(xa) and output its value.
* (x[i],f[i]):given points and n+1 are number of points
* Ln,k(x)=l=summation of (x-x[i])/(x[k]-x[i]).
* p(x)=ff=L(x)*f(x[k])
*/
'''
print('\nLagrange Interpolation Algorithm\n')
xa=1.5
x= list()
x.extend([1.0,1.2,1.3,1.4])
f= list()
f.extend([0.0,0.182,0.336,0.693])
result=0.0
n=3
print(x)
print(f)
print('\n')
for k in range (0,n+1): #n -->n+1
temp=1.0;
for i in range (0,n+1): #n -->n+1
if(i !=k):
temp=temp * ( xa - x[i]) / ( x[k] - x[i])
result=result+temp*f[k]
s = 'The value of p' + repr(xa) + '= ' + repr(result) + '...'
print(s)
輸出畫面
Lagrange Interpolation Algorithm
[1.0, 1.2, 1.3, 1.4]
[0.0, 0.182, 0.336, 0.693]
The value of p1.5= 1.3737500000000018...
>>>
訂閱:
張貼留言 (Atom)
MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構
MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 這張圖片展示了一個 結合 MQTT 協定與 Modbus 通訊的遠端監控與控制系統架構 (主要透過 Node-RED 進行資料整合)。 系統包含三個核心部分,其運作功能說明如下: 1. ESP32 終端設備(硬體控制層...
-
數位IC設計入門-Verilog combinational logic 8 to 1 Multiplexer 多工器 Behavioral Modeling (& Test Bench) //數位IC設計入門-Verilog combinationa...
-
python pip 不是内部或外部命令 -- 解決方法 要安裝 Pyqt5 1. 首先,開啟命令提示字元。 2. 輸入 pip3 install pyqt5 好像不能執行 ! ! 錯誤顯示 : ‘ pip3 ’ 不是內部或外部命令、可執行的程式或批...
-
Line 發報機 Python TKinter (CONFIG_LINE Message API_2.py) import serial import serial.tools.list_ports import tkinter as tk from tkinter import...
沒有留言:
張貼留言