分段线性插值法

上传人:夏** 文档编号:564948739 上传时间:2023-09-22 格式:DOCX 页数:15 大小:42.26KB
返回 下载 相关 举报
分段线性插值法_第1页
第1页 / 共15页
分段线性插值法_第2页
第2页 / 共15页
分段线性插值法_第3页
第3页 / 共15页
分段线性插值法_第4页
第4页 / 共15页
分段线性插值法_第5页
第5页 / 共15页
点击查看更多>>
资源描述

《分段线性插值法》由会员分享,可在线阅读,更多相关《分段线性插值法(15页珍藏版)》请在金锄头文库上搜索。

1、数值分析实验报告实验序号:实验五实验名称:分段线性插值法1、实验目的:随着插值节点的增加,插值多项式的插值多项式的次数也增加,而对于高次的插值容易带来剧烈的震荡, 带来数值的不稳定(Runge现象)。为了既要增加插值的节点,减小插值的区间,以便更好的逼近插值函数, 又要不增加插值多项式的次数以减少误差,可采用分段线性插值。2、实验内容:求一个函数9 (x)用来近似函数f(x),用分段线性插值的方法来求解近似函数9 (x)并画出近似函数图 像及原函数图像。设在区间a,b 上,给定n+1个插值节点a二x x x x二b和相应的函数值0 1 2 ny , y,y,求一个插值函数9(x),满足以下条件

2、:0 1 n(1)9 (x ) = y (j = 0,1,2,., n);jj9(x)在每一个小区间xj,.J上是线性函数。对于给定函数f (x)二在区间Li,上画出fx)和分段线性插值函数9 (x)的函数图像。1. 分段线性插值的算法思想分段线性插值需要在每个插值节点上构造分段线性插值基函数 l (x) ,然后再作它们的线性组 j合。分段线性插值基函数的特点是在对应的插值节点上函数值取 1,其它节点上函数值取 0。插值 基函数如下:设在节点 aWx0x1LoadIcon(IDR_MAINFRAME);void CLDlg:DoDataExchange(CDataExchange* pDX)C

3、Dialog:DoDataExchange(pDX);/AFX_DATA_MAP(CLDlg)/ NOTE: the ClassWizard will add DDX and DDV calls here/AFX_DATA_MAPBEGIN_MESSAGE_MAP(CLDlg, CDialog)/AFX_MSG_MAP(CLDlg)ON_WM_SYSCOMMAND()ON_WM_PAINT()ON_WM_QUERYDRAGICON()ON_BN_CLICKED(IDC_LARGRI, OnLargri)ON_BN_CLICKED(IDC_BUTTON2, OnButton2)ON_BN_CLI

4、CKED(IDC_HERMITE, OnHermite)/AFX_MSG_MAPEND_MESSAGE_MAP()/ CLDlg message handlersBOOL CLDlg:OnInitDialog()CDialog:OnInitDialog();/ Add About. menu item to system menu./ IDM_ABOUTBOX must be in the system command range.ASSERT(IDM_ABOUTBOX & 0xFFF0) = IDM_ABOUTBOX);ASSERT(IDM_ABOUTBOX AppendMenu(MF_SE

5、PARATOR);pSysMenu-AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);/ Set the icon for this dialog. The framework does this automatically/ when the applications main window is not a dialogSetIcon(m_hIcon, TRUE); / Set big iconSetIcon(m_hIcon, FALSE); / Set small icon/ TODO: Add extra initialization

6、herereturn TRUE; / return TRUE unless you set the focus to a controlvoid CLDlg:OnSysCommand(UINT nID, LPARAM lParam)if (nID & 0xFFF0) = IDM_ABOUTBOX)CAboutDlg dlgAbout;dlgAbout.DoModal();elseCDialog:OnSysCommand(nID, lParam);/ If you add a minimize button to your dialog, you will need the code below

7、/ to draw the icon. For MFC applications using the document/view model,/ this is automatically done for you by the framework.void CLDlg:OnPaint()if (IsIconic()CPaintDC dc(this); / device context for paintingSendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/ Center icon in client rectangle

8、int cxIcon = GetSystemMetrics(SM_CXICON);int cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height() - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();/ The system calls this to obtain the cursor to display while the user drags / the minimized window.HCURSOR CLDlg:OnQueryDragIcon()return (HCURSOR) m_hIcon;void CLDlg:OnOK()int x00=300,y00=350,i,j;double x;CDC *pDC=GetDC();pDC-SetMapMode(MM_LOMETRIC);pDC-SetViewportOrg(x00,y00);/画坐标轴与原函数for

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 学术论文 > 其它学术论文

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号