资源预览内容
第1页 / 共15页
第2页 / 共15页
第3页 / 共15页
第4页 / 共15页
第5页 / 共15页
第6页 / 共15页
第7页 / 共15页
第8页 / 共15页
第9页 / 共15页
第10页 / 共15页
亲,该文档总共15页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
数值分析实验报告实验序号:实验五实验名称:分段线性插值法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),满足以下条件: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)CDialog: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_CLICKED(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_SEPARATOR);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 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/ 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 rectangleint 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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号