c6-11 (779512), страница 2

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

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

x, y, and z must be nonnegative, and at most one can be zero. TINY must be at least 5 times the machine underflow limit,BIG at most one fifth the machine overflow limit.{float alamb,ave,delx,dely,delz,e2,e3,sqrtx,sqrty,sqrtz,xt,yt,zt;if (FMIN(FMIN(x,y),z) < 0.0 || FMIN(FMIN(x+y,x+z),y+z) < TINY ||FMAX(FMAX(x,y),z) > BIG)nrerror("invalid arguments in rf");xt=x;yt=y;zt=z;do {sqrtx=sqrt(xt);sqrty=sqrt(yt);sqrtz=sqrt(zt);alamb=sqrtx*(sqrty+sqrtz)+sqrty*sqrtz;xt=0.25*(xt+alamb);yt=0.25*(yt+alamb);zt=0.25*(zt+alamb);ave=THIRD*(xt+yt+zt);delx=(ave-xt)/ave;dely=(ave-yt)/ave;delz=(ave-zt)/ave;} while (FMAX(FMAX(fabs(delx),fabs(dely)),fabs(delz)) > ERRTOL);e2=delx*dely-delz*delz;e3=delx*dely*delz;return (1.0+(C1*e2-C2-C3*e3)*e2+C4*e3)/sqrt(ave);}A value of 0.08 for the error tolerance parameter is adequate for single precision (7significant digits).

Since the error scales as 6n , we see that 0.0025 will yield double precision(16 significant digits) and require at most two or three more iterations. Since the coefficientsof the sixth-order truncation error are different for the other elliptic functions, these values forthe error tolerance should be changed to 0.04 and 0.0012 in the algorithm for RC , and 0.05 and0.0015 for RJ and RD . As well as being an algorithm in its own right for certain combinationsof elementary functions, the algorithm for RC is used repeatedly in the computation of RJ .The C implementations test the input arguments against two machine-dependent constants, TINY and BIG, to ensure that there will be no underflow or overflow during thecomputation. We have chosen conservative values, corresponding to a machine minimumof 3 × 10−39 and a machine maximum of 1.7 × 1038 .

You can always extend the range ofadmissible argument values by using the homogeneity relations (6.11.22), below.#include <math.h>#include "nrutil.h"#define ERRTOL 0.05Sample 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).#include <math.h>#include "nrutil.h"#define ERRTOL 0.08#define TINY 1.5e-38#define BIG 3.0e37#define THIRD (1.0/3.0)#define C1 (1.0/24.0)#define C2 0.1#define C3 (3.0/44.0)#define C4 (1.0/14.0)6.11 Elliptic Integrals and Jacobian Elliptic FunctionsTINY 1.0e-25BIG 4.5e21C1 (3.0/14.0)C2 (1.0/6.0)C3 (9.0/22.0)C4 (3.0/26.0)C5 (0.25*C3)C6 (1.5*C4)float rd(float x, float y, float z)Computes Carlson’s elliptic integral of the second kind, RD (x, y, z).

x and y must be nonnegative, and at most one can be zero. z must be positive. TINY must be at least twice thenegative 2/3 power of the machine overflow limit. BIG must be at most 0.1 × ERRTOL timesthe negative 2/3 power of the machine underflow limit.{float alamb,ave,delx,dely,delz,ea,eb,ec,ed,ee,fac,sqrtx,sqrty,sqrtz,sum,xt,yt,zt;if (FMIN(x,y) < 0.0 || FMIN(x+y,z) < TINY || FMAX(FMAX(x,y),z) > BIG)nrerror("invalid arguments in rd");xt=x;yt=y;zt=z;sum=0.0;fac=1.0;do {sqrtx=sqrt(xt);sqrty=sqrt(yt);sqrtz=sqrt(zt);alamb=sqrtx*(sqrty+sqrtz)+sqrty*sqrtz;sum += fac/(sqrtz*(zt+alamb));fac=0.25*fac;xt=0.25*(xt+alamb);yt=0.25*(yt+alamb);zt=0.25*(zt+alamb);ave=0.2*(xt+yt+3.0*zt);delx=(ave-xt)/ave;dely=(ave-yt)/ave;delz=(ave-zt)/ave;} while (FMAX(FMAX(fabs(delx),fabs(dely)),fabs(delz)) > ERRTOL);ea=delx*dely;eb=delz*delz;ec=ea-eb;ed=ea-6.0*eb;ee=ed+ec+ec;return 3.0*sum+fac*(1.0+ed*(-C1+C5*ed-C6*delz*ee)+delz*(C2*ee+delz*(-C3*ec+delz*C4*ea)))/(ave*sqrt(ave));}#include <math.h>#include "nrutil.h"#define ERRTOL 0.05#define TINY 2.5e-13#define BIG 9.0e11#define C1 (3.0/14.0)#define C2 (1.0/3.0)#define C3 (3.0/22.0)#define C4 (3.0/26.0)#define C5 (0.75*C3)#define C6 (1.5*C4)#define C7 (0.5*C2)#define C8 (C3+C3)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).#define#define#define#define#define#define#define#define265266Chapter 6.Special Functionsif (FMIN(FMIN(x,y),z) < 0.0 || FMIN(FMIN(x+y,x+z),FMIN(y+z,fabs(p))) < TINY|| FMAX(FMAX(x,y),FMAX(z,fabs(p))) > BIG)nrerror("invalid arguments in rj");sum=0.0;fac=1.0;if (p > 0.0) {xt=x;yt=y;zt=z;pt=p;} else {xt=FMIN(FMIN(x,y),z);zt=FMAX(FMAX(x,y),z);yt=x+y+z-xt-zt;a=1.0/(yt-p);b=a*(zt-yt)*(yt-xt);pt=yt+b;rho=xt*zt/yt;tau=p*pt/yt;rcx=rc(rho,tau);}do {sqrtx=sqrt(xt);sqrty=sqrt(yt);sqrtz=sqrt(zt);alamb=sqrtx*(sqrty+sqrtz)+sqrty*sqrtz;alpha=SQR(pt*(sqrtx+sqrty+sqrtz)+sqrtx*sqrty*sqrtz);beta=pt*SQR(pt+alamb);sum += fac*rc(alpha,beta);fac=0.25*fac;xt=0.25*(xt+alamb);yt=0.25*(yt+alamb);zt=0.25*(zt+alamb);pt=0.25*(pt+alamb);ave=0.2*(xt+yt+zt+pt+pt);delx=(ave-xt)/ave;dely=(ave-yt)/ave;delz=(ave-zt)/ave;delp=(ave-pt)/ave;} while (FMAX(FMAX(fabs(delx),fabs(dely)),FMAX(fabs(delz),fabs(delp))) > ERRTOL);ea=delx*(dely+delz)+dely*delz;eb=delx*dely*delz;ec=delp*delp;ed=ea-3.0*ec;ee=eb+2.0*delp*(ea-ec);ans=3.0*sum+fac*(1.0+ed*(-C1+C5*ed-C6*ee)+eb*(C7+delp*(-C8+delp*C4))+delp*ea*(C2-delp*C3)-C2*delp*ec)/(ave*sqrt(ave));if (p <= 0.0) ans=a*(b*ans+3.0*(rcx-rf(xt,yt,zt)));return ans;}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).float rj(float x, float y, float z, float p)Computes Carlson’s elliptic integral of the third kind, RJ (x, y, z, p). x, y, and z must benonnegative, and at most one can be zero. p must be nonzero. If p < 0, the Cauchy principalvalue is returned. TINY must be at least twice the cube root of the machine underflow limit,BIG at most one fifth the cube root of the machine overflow limit.{float rc(float x, float y);float rf(float x, float y, float z);float a,alamb,alpha,ans,ave,b,beta,delp,delx,dely,delz,ea,eb,ec,ed,ee,fac,pt,rcx,rho,sqrtx,sqrty,sqrtz,sum,tau,xt,yt,zt;6.11 Elliptic Integrals and Jacobian Elliptic Functions267float rc(float x, float y)Computes Carlson’s degenerate elliptic integral, RC (x, y).

x must be nonnegative and y mustbe nonzero. If y < 0, the Cauchy principal value is returned. TINY must be at least 5 timesthe machine underflow limit, BIG at most one fifth the machine maximum overflow limit.{float alamb,ave,s,w,xt,yt;if (x < 0.0 || y == 0.0 || (x+fabs(y)) < TINY || (x+fabs(y)) > BIG ||(y<-COMP1 && x > 0.0 && x < COMP2))nrerror("invalid arguments in rc");if (y > 0.0) {xt=x;yt=y;w=1.0;} else {xt=x-y;yt = -y;w=sqrt(x)/sqrt(xt);}do {alamb=2.0*sqrt(xt)*sqrt(yt)+yt;xt=0.25*(xt+alamb);yt=0.25*(yt+alamb);ave=THIRD*(xt+yt+yt);s=(yt-ave)/ave;} while (fabs(s) > ERRTOL);return w*(1.0+s*s*(C1+s*(C2+s*(C3+s*C4))))/sqrt(ave);}At times you may want to express your answer in Legendre’s notation.

Alternatively, you may be given results in that notation and need to compute their valueswith the programs given above. It is a simple matter to transform back and forth.The Legendre elliptic integral of the 1st kind is defined asZF (φ, k) ≡0φpdθ1 − k 2 sin2 θ(6.11.17)The complete elliptic integral of the 1st kind is given byK(k) ≡ F (π/2, k)(6.11.18)In terms of RF ,F (φ, k) = sin φRF (cos2 φ, 1 − k 2 sin2 φ, 1)K(k) = RF (0, 1 − k 2 , 1)(6.11.19)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).#include <math.h>#include "nrutil.h"#define ERRTOL 0.04#define TINY 1.69e-38#define SQRTNY 1.3e-19#define BIG 3.e37#define TNBG (TINY*BIG)#define COMP1 (2.236/SQRTNY)#define COMP2 (TNBG*TNBG/25.0)#define THIRD (1.0/3.0)#define C1 0.3#define C2 (1.0/7.0)#define C3 0.375#define C4 (9.0/22.0)268Chapter 6.Special FunctionsThe Legendre elliptic integral of the 2nd kind and the complete elliptic integral ofthe 2nd kind are given byZφE(φ, k) ≡p1 − k 2 sin2 θ dθ0(6.11.20)− 13 k 2 sin3 φRD (cos2 φ, 1 − k 2 sin2 φ, 1)E(k) ≡ E(π/2, k) = RF (0, 1 − k 2 , 1) − 13 k 2 RD (0, 1 − k 2 , 1)Finally, the Legendre elliptic integral of the 3rd kind isZφΠ(φ, n, k) ≡0dθp(1 + n sin θ) 1 − k 2 sin2 θ2= sin φRF (cos2 φ, 1 − k 2 sin2 φ, 1)(6.11.21)− 13 n sin3 φRJ (cos2 φ, 1 − k 2 sin2 φ, 1, 1 + n sin2 φ)(Note that this sign convention for n is opposite that of Abramowitz and Stegun [12],and that their sin α is our k.)#include <math.h>#include "nrutil.h"float ellf(float phi, float ak)Legendre elliptic integral of the 1st kind F (φ, k), evaluated using Carlson’s function RF .

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

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

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

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