一聚教程网:一个值得你收藏的教程网站

热门教程

几个 数值分析 的算法例子

时间:2022-06-30 11:21:35 编辑:袖梨 来源:一聚教程网

<%@ Language=VBScript %>
<%
'几个参考点的数据已经给出,输入参数只有 X
function view(result,inputx)    '输出结果,同时如果<1 and >0,就在前面补0
    if result<1 and result>0 then result=0&result
    Response.Write "计算结果:"&"
"
    Response.Write "F("&inputx&")="& result
end function
'********分段线性Lagrange插值**********
function Lagrange1(inputx)
dim k,i
dim x,y
x=array("0.1","0.2","0.3","0.4")
y=array("0.0998","0.1987","0.2955","0.3894")
if inputxif inputx>x(3) then k=2
for i=0 to 2
     if inputx>=x(i) and inputx<=x(i+1)    then k=i
     result=((inputx-x(k+1))/(x(k)-x(k+1)))*y(k) + ((inputx-x(k))/(x(k+1)-x(k)))*y(k+1)
next    
    result= view(result,inputx)
end function     

'********分段三点二次Lagrange插值**********
function Lagrange2(inputx)
dim i,j,k,t
dim x,y
result=0
x=array("0.1","0.2","0.3","0.4")
y=array("0.0998","0.1987","0.2955","0.3894")
if inputx<=x(1) then k=0
if inputx>=x(2) then k=1
if inputx>x(1) and inputxfor j=k to k+2
t=1
for i= k to k+2
     if i<>j then
     t= t * (inputx-x(i))/(x(j)-x(i))
     end if
next
     result = result + t*y(j)
next
result= view(result,inputx)
end function

热门栏目