CH-02 (523169), страница 3

Файл №523169 CH-02 (Pao - Engineering Analysis) 3 страницаCH-02 (523169) страница 32013-09-15СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 3)

And, the selected functions are sin(X/20),sin(3X/20), and sin(5X/20). That is, M = 3. The supporting function FS.m issimply:function F=FS(i,xv)F=sin((2.*i-1).*xv.(pi./20);Having prepared this file FS.m on a disk which is in drive A, we can now applyLeastSqG.m interactively as follows:>> X = [1.4,3.2,4.8,8,10]; Y = [2.25,15,26.25,33,35]; C = LeastSqG(A:FS,X,Y,3,5)The results shown on screen are:If four functions X, X2, sin(X), and cos(X) are selected, we may change theFS.m file to:© 2001 by CRC Press LLCSame as for the FORTRAN and QuickBASIC versions, if we are given six(X,Y) points, (1,2), (2,4), (3,7), (4,11), (5,23), and (6,45), MATLAB application ofLeastSqG.m will be:>> X=[1,2,3,4,5,6]; Y=[2,4,7,11,23,45]; C-LeastSqG('A:FS',X,Y,4,6)The results are:Notice that the values in [A] and {R} are to be multiplied by the factor 1.0e +003 as indicated.

For saving space, [A], {R}, and {C} are listed side-by-side whenactually they are displayed from top-to-bottom on screen. To further utilize thecapability of MATLAB, the obtained {C} values are checked to plot the fitted curveagainst the provided six (X,Y) points. The following additional statements areentered in order to have a screen display as illustrated in Figure 3:FIGURE 3. The ‘*’ argument in the second plot statement requests that the character * isto be used for plotting the given points,© 2001 by CRC Press LLCThe statement XC = [1:0.2:6] generates a vector of XC containing value from1 to 6 with an increment of 0.2.

The command “hold” enables the first plot of XCvs. YC which is the resulting least-squares fitted curve, to be held on screen untilthe given points (X,Y) are superimposed. The ‘*’ argument in the second plotstatement requests that the character * is to be used for plotting the given points, asillustrated in Figure 3.Next, another example is given to show how MATLAB statements can be applieddirectly with defining a m function, such as FS which describes the selected set offunctions for least-squares curve fit.

Consider the problem of least-squares fit of thepoints (1,2), (3,5), and (4,13) by the linear combination Y = C1f1(X) + C2f2(X) wheref1(X) = X–1 and f2(X) = X2. An interactive application of MATLAB may go as follows:The resulting curve is plotted in Figure 4 using 31 points, (XC,YC), calculatedbased on the equation Y = –7.0526(X–1) + 2.1316X2 for X values ranging from 1to 4. The three given points, (X,Y), are superimposed on the graph using ‘*’character.

Notice from the above statements, the coefficients C(1) and C(2) are solvedfrom the matrix equation [A]{C} = {R} where the elements in [A] are generatedusing interactively entered statement and so are the elements of {R}. MATLABmatrix operations such as transposition, subtraction, multiplication, and inversionare all involved. Also, notice that here no use of MATLAB ‘hold’ as for generatingFigure 1, is necessary if X, Y, XC, and YC are all used as arguments in calling the© 2001 by CRC Press LLCFIGURE 4. The curve is plotted using 31 points, (XC,YC), calculated based on the equationY = –7.0526(X–1) + 2.1316X2 for X values ranging from 1 to 4.plot function. The statement XC = 1:0.1:4 generates a XC row matrix having elements starting from a value equal to 1, equally incremented by 0.1 until a value of4 is reached.MATHEMATICA APPLICATIONSMathematica has a function called Fit which least-squares fits a given set of(x,y) points by a linear combination of a number of selected functions.

As the firstexample of interactive application, let us find the best straight line which gives theleast squared errors for fitting a set of five points. This is the case of two selectedfunctions f1(x) = 1 and f2(x) = x. the interactive application goes as follows:In[1]: = Fit[{{1,2},{2,5},{3,8},{5,11},{8,24}}, {1, x}, x]Out[1]: = –1.47403 + 3.01948 xNotice that Fit has three arguments: first argument specifies the data set, secondargument lists the selected function, and the third argument is the variable for the© 2001 by CRC Press LLCderived equation.

In case that three points are given and the two selected functionsare f1(x) = x–1 and f2(x) = x2, then the interactive operation goes as follows:In[2]: = Fit[{{1,2},{3,5},{4,13}}, {x–1, x^2}, x]Out[2]: = –7.05263 (–1 + x) + 2.13158 xTwo other examples previously presented in the MATLAB applications can alsobe considered and the results are:In[3]: = (Fit[{{1,2}, {2,4}, {3,7}, {4,11}, {5,23}, {6,45}},{x, x^2, Sin[x], Cos[x]}, x])Out[3]: = –4.75756 x + 2.11159 x2 – 0.986915 Cos[x] + 5.76573 Sin[x]andIn[4]: = (Fit[{{1.4, 2.25}, {3.2, 15}, {4.8, 26.25}, {8, 33}, {10, 35}},{Sin[Pi*x/20], Sin[3*Pi*x/20], Sin[5*Pi*x/20]}, x])Pi x 3 Pi x 5 Pi x Out[4]: = 35.9251 Sin − 1.19261 Sin − 3.46705 Sin  20  20  20 All of the results obtained here are in agreement with those presented earlier.2.5 PROGRAM CUBESPLN — CURVE FITTINGWITH CUBIC SPLINEIf a set of N given points (Xi,Yi) for i = 1, 2,…,N is to be fitted with a polynomialof N–1 degree passing these points exactly, the polynomial curve will have manyfluctuations between data points as the number of points, N, increases.

A popularmethod for avoiding such over-fluctuation is to fit every two adjacent points with acubic equation and to impose continuity conditions at the point shared by twoneighboring cubic equations. This is like using a draftsman’s spline attempting topass through all of the N given points. It is known as cubic-spline curve fit. For atypical interval of X, say Xi to Xi + 1, the cubic equation can be written as:Y = a i X3 + bi X 2 + ci X + d i(1)where ai, bi, ci, and di are unknown coefficients. If there are N–1 intervals and eachinterval is fitted by a cubic equation, the total number of unknown coefficients isequal to 4(N–1).

They are to be determined by the following conditions:1. Each curve passes two specified points. The first and last specified pointsare used once by the first and N-1st curves, respectively, whereas allinterior points are used twice by the two cubic curves meeting there. Thisgives 2 + 2(N–2), or, 2N–2 conditions.© 2001 by CRC Press LLC2. Every two adjacent cubic curves should have equal slope (first derivativewith respect to X) at the interior point which they share. This gives N–2conditions.(2)3. For further smoothness of the curve fit, every two adjacent cubic curvesshould have equal curvature (second derivative with respect to X) at theinterior point which they share.

This gives N–2 conditions.4. At the end points, X1 and XN, the nature spline requires that the curvaturesbe equal to zero. This gives 2 conditions.Instead of solving the coefficients in Equation 1, the usual approach is to applythe above-listed conditions for finding the curvatures, Y″ at the interior points, thatis for i = 2,3,…,N–1 since (Y″)1 = (Y″)N = 0. To do so, we notice that if Y is a cubicpolynomial of X, Y″ is then linear in X and can be expressed as:Y′′ = AX + B(3)If this is used to fit the ith interval, for which the increment in X is here denotedas Hi = Xi + 1–Xi, we may replace the unknown coefficients A and B with thecurvatures at Xi and Xi + 1, (Y″)i and (Y″)i + 1 by solving the two equations:Yi′′ = AX i + BandYi′′+1 = AX i +1 + B(4,5)By using the Cramer’s rule, it is easy to obtain:A=Yi′+1 − Yi′′X i +1 − X iandB = Y′′ −X i (Yi′′+1 − Yi′′)X i +1 − X i(6,7)Consequently, Equation 3 can be written as:Y′′ =Yi′′(X − X) + YHi′′+1 (X − Xi )H i i +1i(8)Equation 8 can be integrated successively to obtain the expressions for Y andY as:22− Yi′′Y′′Y′ +X i +1 − X) + i +1 ( X − X i ) + C1(9)(2Hi2H iand33Y′′Y′′Y = i ( X i +1 − X) + i +1 ( X − X i ) + C1X + C2(10)6H i6H i© 2001 by CRC Press LLCThe integration constants C1 and C2 can be determined by the conditions that atXi, Y = Yi and at Xi + 1, Y = Yi + 1.

Based on Equation 10, the two conditions lead to:Yi =Yi′′ 2H + C1X i + C26 iandYi +1 =Yi′′+1 2H + C1X i +1 + C26 i(11,12)Again, Cramer’s rule can be applied to obtain:C1 =(Y′′− Y′′ )Hi +1i6i−Yi − Yi +1Hi(13)andC2 = −(Xi+1Yi′′− XiYi′′+1 )Hi − XiYi+1 − Xi+1Yi6HiHi(14)Substituting C1 and C2 into Equations 11 and 12 and rearranging into termsinvolving the unknown curvatures, the expressions for the cubic curve are:Y=3 Y′′  ( X − X )3Yi′′  ( X i +1 − X)i− H i ( X i +1 − X) + i +1 − H i ( X − X i )Hi6 6  Hi X − X X − Xi + Yi  i +1+ Yi +1  Hi  Hi (15) H ( X − X )2  ( X − X )2 H  Y − Yii + Yi′′+1 Y′ = Yi′′  i − i +1− i  + i +1Hi2Hi6 6 2 H i(16)andEquation 15 indicates that the cubic curve for the ith interval is completelydefined if in addition to the specified values of Yi and Yi + 1, the curvatures at Xi andXi + 1, (Y″)i and (Y″)i + 1 respectively, also can be found.

To find all of the curvaturesat the interior points X2 through XN–1, we apply the remaining unused conditionsmentioned in (2). That is, matching the slopes of two adjacent cubic curves at these© 2001 by CRC Press LLCinterior points. To match the slope at Xi, first we need to have the slope equationfor the preceding interval, that is from Xi–1 to Xi, for which the increment is denotedas Hi–1. From Equation 16, we can easily write out that slope equation as:2H ( X − X )2 H  Y − YX i − X) (i −11i −1i− + Yi′′ Y′ = Yi′′−1 −− i+ iH i −12 H i −1 2 H i −16 6(17)Using Equations 16 and 17 and matching the slopes at the interior point Xi andafter collecting terms, we obtain: Y − Yi Yi − Yi −1 H i −1Yi′′−1 + 2(H i −1 + H i )Yi′′ + H i Yi′′+1 = 6 i −1−H i  H i −1(18)This equation can be applied for all interior points, that is, at X = Xi for i =2,3,…,N–1.

Hence, we have N–2 equations for solving the N–2 unknown curvatures,(Y″)i for i = 2,3,…,N–1 when the X and Y coordinates of N + 1 points are specifiedfor a cubic-spline curve fit. Upon substituting the calculated curvatures into Equation15, we obtain the desired cubic polynomial for each interval of X.If the N given points, (Xi,Yi) for i = 1,2,…,N, has a periodic pattern for everyincrement of XN-X1, we can change the above formation for the open case to suitthis particular need by requiring that the points be specified with YN = Y1 and thatcurvatures also should be continuous at the first and last points. That is to removethe 4th rule, and also one condition each for the 2nd and 3rd rules described in (2).Equation 18 is to be used for i = 1,2,…,N to obtain N equations for solving the Ncurvatures.

Характеристики

Тип файла
PDF-файл
Размер
476,77 Kb
Тип материала
Учебное заведение
Неизвестно

Список файлов книги

Свежие статьи
Популярно сейчас
Как Вы думаете, сколько людей до Вас делали точно такое же задание? 99% студентов выполняют точно такие же задания, как и их предшественники год назад. Найдите нужный учебный материал на СтудИзбе!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6384
Авторов
на СтудИзбе
308
Средний доход
с одного платного файла
Обучение Подробнее