c5-9 (779493)

Файл №779493 c5-9 (Numerical Recipes in C)c5-9 (779493)2017-12-27СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла

5.9 Derivatives or Integrals of a Chebyshev-approximated Function1955.9 Derivatives or Integrals of aChebyshev-approximated FunctionCi =ci−1 − ci+12(i − 1)c0i−1 = c0i+1 + 2(i − 1)ci(i > 1)(5.9.1)(i = m − 1, m − 2, . . . , 2)(5.9.2)Equation (5.9.1) is augmented by an arbitrary choice of C0 , corresponding to anarbitrary constant of integration. Equation (5.9.2), which is a recurrence, is startedwith the values c0m = c0m−1 = 0, corresponding to no information about the m + 1stChebyshev coefficient of the original function f.Here are routines for implementing equations (5.9.1) and (5.9.2).void chder(float a, float b, float c[], float cder[], int n)Given a,b,c[0..n-1], as output from routine chebft §5.8, and given n, the desired degreeof approximation (length of c to be used), this routine returns the array cder[0..n-1], theChebyshev coefficients of the derivative of the function whose coefficients are c.{int j;float con;cder[n-1]=0.0;cder[n-2]=2*(n-1)*c[n-1];for (j=n-3;j>=0;j--)cder[j]=cder[j+2]+2*(j+1)*c[j+1];con=2.0/(b-a);for (j=0;j<n;j++)cder[j] *= con;n-1 and n-2 are special cases.Equation (5.9.2).Normalize to the interval b-a.}void chint(float a, float b, float c[], float cint[], int n)Given a,b,c[0..n-1], as output from routine chebft §5.8, and given n, the desired degreeof approximation (length of c to be used), this routine returns the array cint[0..n-1], theChebyshev coefficients of the integral of the function whose coefficients are c.

The constant ofintegration is set so that the integral vanishes at a.{int j;float sum=0.0,fac=1.0,con;con=0.25*(b-a);for (j=1;j<=n-2;j++) {cint[j]=con*(c[j-1]-c[j+1])/j;Factor that normalizes to the interval b-a.Equation (5.9.1).Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.

Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).If you have obtained the Chebyshev coefficients that approximate a function ina certain range (e.g., from chebft in §5.8), then it is a simple matter to transformthem to Chebyshev coefficients corresponding to the derivative or integral of thefunction.

Having done this, you can evaluate the derivative or integral just as if itwere a function that you had Chebyshev-fitted ab initio.The relevant formulas are these: If ci , i = 0, . . . , m − 1 are the coefficientsthat approximate a function f in equation (5.8.9), Ci are the coefficients thatapproximate the indefinite integral of f, and c0i are the coefficients that approximatethe derivative of f, then196Chapter 5.Evaluation of Functionssum += fac*cint[j];fac = -fac;}cint[n-1]=con*c[n-2]/(n-1);sum += fac*cint[n-1];cint[0]=2.0*sum;Accumulates the constant of integration.Will equal ±1.Special case of (5.9.1) for n-1.Set the constant of integration.}Since a smooth function’s Chebyshev coefficients ci decrease rapidly, generally exponentially, equation (5.9.1) is often quite efficient as the basis for a quadrature scheme.

TheroutinesR x chebft and chint, used in that order, can be followed by repeated calls to chebevif a f (x)dx is required for many different values of x in the range a ≤ x ≤ b.RbIf only the single definite integral a f (x)dx is required, then chint and chebev arereplaced by the simpler formula, derived from equation (5.9.1),Z b1111f (x)dx = (b − a)c1 − c3 −c5 − · · · −c2k+1 − · · ·2315(2k + 1)(2k − 1)a(5.9.3)where the ci ’s are as returned by chebft. The series can be truncated when c2k+1 becomesnegligible, and the first neglected term gives an error estimate.This scheme is known as Clenshaw-Curtis quadrature [1].

It is often combined with anadaptive choice of N , the number of Chebyshev coefficients calculated via equation (5.8.7),which is also the number of function evaluations of f (x). If a modest choice of N doesnot give a sufficiently small c2k+1 in equation (5.9.3), then a larger value is tried. In thisadaptive case, it is even better to replace equation (5.8.7) by the so-called “trapezoidal” orGauss-Lobatto (§4.5) variant,cj = Nπkπ(j − 1)k2 X00f coscosNNNj = 1, . . .

, N(5.9.4)k=0where (N.B.!) the two primes signify that the first and last terms in the sum are to bemultiplied by 1/2. If N is doubled in equation (5.9.4), then half of the new functionevaluation points are identical to the old ones, allowing the previous function evaluations to bereused. This feature, plus the analytic weights and abscissas (cosine functions in 5.9.4), giveClenshaw-Curtis quadrature an edge over high-order adaptive Gaussian quadrature (cf. §4.5),which the method otherwise resembles.If your problem forces you to large values of N , you should be aware that equation (5.9.4)can be evaluated rapidly, and simultaneously for all the values of j, by a fast cosine transform.(See §12.3, especially equation 12.3.17.) (We already remarked that the nontrapezoidal form(5.8.7) can also be done by fast cosine methods, cf.

equation 12.3.22.)CITED REFERENCES AND FURTHER READING:Goodwin, E.T. (ed.) 1961, Modern Computing Methods, 2nd ed. (New York: Philosophical Library), pp. 78–79.Clenshaw, C.W., and Curtis, A.R. 1960, Numerische Mathematik, vol. 2, pp. 197–205. [1]Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.

Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).Clenshaw-Curtis Quadrature5.10 Polynomial Approximation from Chebyshev Coefficients1975.10 Polynomial Approximation fromChebyshev Coefficientsf(x) ≈m−1Xgk xk(5.10.1)k=0Yes, you can do this (and we will give you the algorithm to do it), but wecaution you against it: Evaluating equation (5.10.1), where the coefficient g’s reflectan underlying Chebyshev approximation, usually requires more significant figuresthan evaluation of the Chebyshev sum directly (as by chebev).

This is becausethe Chebyshev polynomials themselves exhibit a rather delicate cancellation: Theleading coefficient of Tn (x), for example, is 2n−1 ; other coefficients of Tn (x) areeven bigger; yet they all manage to combine into a polynomial that lies between ±1.Only when m is no larger than 7 or 8 should you contemplate writing a Chebyshevfit as a direct polynomial, and even in those cases you should be willing to toleratetwo or so significant figures less accuracy than the roundoff limit of your machine.You get the g’s in equation (5.10.1) from the c’s output from chebft (suitablytruncated at a modest value of m) by calling in sequence the following two procedures:#include "nrutil.h"void chebpc(float c[], float d[], int n)Chebyshev polynomial coefficients. Given a coefficient array c[0..n-1], this routine generatesPPn-1ka coefficient array d[0..n-1] such that n-1k=0 dk y =k=0 ck Tk (y) − c0 /2.

The methodis Clenshaw’s recurrence (5.8.11), but now applied algebraically rather than arithmetically.{int k,j;float sv,*dd;dd=vector(0,n-1);for (j=0;j<n;j++) d[j]=dd[j]=0.0;d[0]=c[n-1];for (j=n-2;j>=1;j--) {for (k=n-j;k>=1;k--) {sv=d[k];d[k]=2.0*d[k-1]-dd[k];dd[k]=sv;}sv=d[0];d[0] = -dd[0]+c[j];dd[0]=sv;}for (j=n-1;j>=1;j--)d[j]=d[j-1]-dd[j];d[0] = -dd[0]+0.5*c[0];free_vector(dd,0,n-1);}Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use.

Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).You may well ask after reading the preceding two sections, “Must I store andevaluate my Chebyshev approximation as an array of Chebyshev coefficients for atransformed variable y? Can’t I convert the ck ’s into actual polynomial coefficientsin the original variable x and have an approximation of the following form?”.

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

Тип файла
PDF-файл
Размер
146,88 Kb
Материал
Тип материала
Высшее учебное заведение

Тип файла PDF

PDF-формат наиболее широко используется для просмотра любого типа файлов на любом устройстве. В него можно сохранить документ, таблицы, презентацию, текст, чертежи, вычисления, графики и всё остальное, что можно показать на экране любого устройства. Именно его лучше всего использовать для печати.

Например, если Вам нужно распечатать чертёж из автокада, Вы сохраните чертёж на флешку, но будет ли автокад в пункте печати? А если будет, то нужная версия с нужными библиотеками? Именно для этого и нужен формат PDF - в нём точно будет показано верно вне зависимости от того, в какой программе создали PDF-файл и есть ли нужная программа для его просмотра.

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

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