Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Cephes/   (Cephes Mathematical Library ©)  Datei vom 9.5.2026 mit Größe 3 kB image not shown  

Quelle  shichi.c

  Sprache: C
 

/* shichi.c
 *
 * Hyperbolic sine and cosine integrals
 *
 *
 *
 * SYNOPSIS:
 *
 * double x, Chi, Shi, shichi();
 *
 * shichi( x, &Chi, &Shi );
 *
 *
 * DESCRIPTION:
 *
 * Approximates the integrals
 *
 *                            x
 *                            -
 *                           | |   cosh t - 1
 *   Chi(x) = eul + ln x +   |    -----------  dt,
 *                         | |          t
 *                          -
 *                          0
 *
 *               x
 *               -
 *              | |  sinh t
 *   Shi(x) =   |    ------  dt
 *            | |       t
 *             -
 *             0
 *
 * where eul = 0.57721566490153286061 is Euler's constant.
 * The integrals are evaluated by power series for x < 8
 * and by Chebyshev expansions for x between 8 and 88.
 * For large x, both functions approach exp(x)/2x.
 * Arguments greater than 88 in magnitude return MAXNUM.
 *
 *
 * ACCURACY:
 *
 * Test interval 0 to 88.
 *                      Relative error:
 * arithmetic   function  # trials      peak         rms
 *    DEC          Shi       3000       9.1e-17
 *    IEEE         Shi      30000       6.9e-16     1.6e-16
 *        Absolute error, except relative when |Chi| > 1:
 *    DEC          Chi       2500       9.3e-17
 *    IEEE         Chi      30000       8.4e-16     1.4e-16
 */


/*
Cephes Math Library Release 2.8:  June, 2000
Copyright 1984, 1987, 2000 by Stephen L. Moshier
*/


#include "mconf.h"

#ifdef UNK
/* x exp(-x) shi(x), inverted interval 8 to 18 */
static double S1[] = {1.83889230173399459482E-17,  -9.55485532279655569575E-17,
                      2.04326105980879882648E-16,  1.09896949074905343022E-15,
                      -1.31313534344092599234E-145.93976226264314278932E-14,
                      -3.47197010497749154755E-14, -1.40059764613117131000E-12,
                      9.49044626224223543299E-12,  -1.61596181145435454033E-11,
                      -1.77899784436430310321E-101.35455469767246947469E-9,
                      -1.03257121792819495123E-9,  -3.56699611114982536845E-8,
                      1.44818877384267342057E-7,   7.82018215184051295296E-7,
                      -5.39919118403805073710E-6,  -3.12458202168959833422E-5,
                      8.90136741950727517826E-5,   2.02558474743846862168E-3,
                      2.96064440855633256972E-2,   1.11847751047257036625E0};

/* x exp(-x) shi(x), inverted interval 18 to 88 */
static double S2[] = {-1.05311574154850938805E-172.62446095596355225821E-17,
                      8.82090135625368160657E-17,  -3.38459811878103047136E-16,
                      -8.30608026366935789136E-163.93397875437050071776E-15,
                      1.01765565969729044505E-14,  -4.21128170307640802703E-14,
                      -1.60818204519802480035E-133.34714954175994481761E-13,
                      2.72600352129153073807E-12,  1.66894954752839083608E-12,
                      -3.49278141024730899554E-11, -1.58580661666482709598E-10,
                      -1.79289437183355633342E-101.76281629144264523277E-9,
                      1.69050228879421288846E-8,   1.25391771228487041649E-7,
                      1.16229947068677338732E-6,   1.61038260117376323993E-5,
                      3.49810375601053973070E-4,   1.28478065259647610779E-2,
                      1.03665722588798326712E0};
#endif

#ifdef DEC
static unsigned short S1[] = {
    00222510115635016512000065740122734005075100203050101356,
    00231530111154001110301774620023636006032100602530124246,
    01245540106655015252501664000025205014014501710060106556,
    01250340056427000420501760220126305001673100250110134453,
    00270460172453011260401162350127216002207101166000137667,
    01301030115126007110400525350030672002545000100710141414,
    01306150165136013213701777370132031003161100744360175407,
    00324330077602010434500600760033121016574101671770172433,
    01336650025262017462100226120134403000676101245660145405,
    00346720126332003473701167440036004013765400373320131766,
    00367620104466012144501243260040217002510500621450042640};

static unsigned short S2[] = {
    01221020041774001605100551370022362001012500076510015773,
    00227130062551004022700716450123303001573200257310146570,
    01235570064016000206700677110024215013621401323740124234,
    00244670051425007106600642100125075012430501351230024170,
    01254650010261000556000342320025674006660200307240174557,
    00264770151520005151000672500026352016107601131540116271,
    01274310116470017746501272740130056005617401703150013321,
    01301050020575007532700367100030762004362501130460125035,
    00316210033211015435400220770032406012155500742700041141,
    00332340000116004161101737430034207001326301747150115563,
    00352670063300017575301172660036522007763300332550136200,
    0040204013045700144540166254};
#endif

#ifdef IBMPC
static unsigned short S1[] = {
    0x01b0, 0xbd4a, 0x3373, 0x3c75, 0xb05e, 0x2418, 0x8a3d, 0xbc9b, 0x7fe6,
    0x8248, 0x724d, 0x3cad, 0x7515, 0x2c15, 0xcc1a, 0x3cd3, 0xbda0, 0xbaaa,
    0x91b5, 0xbd0d, 0xd1ae, 0xbe40, 0xb80c, 0x3d30, 0xbf82, 0xe110, 0x8ba2,
    0xbd23, 0x3725, 0x2541, 0xa3bb, 0xbd78, 0x9394, 0x72b0, 0xdea5, 0x3da4,
    0x17f7, 0x33b0, 0xc487, 0xbdb1, 0x8aac, 0xce48, 0x734a, 0xbde8, 0x3862,
    0x0207, 0x4565, 0x3e17, 0xfffc, 0xd68b, 0xbd4b, 0xbe11, 0xdf61, 0x2f23,
    0x2671, 0xbe63, 0xac08, 0x511c, 0x6ff0, 0x3e83, 0xfea3, 0x3dcf, 0x3d7c,
    0x3eaa, 0x24b1, 0x5f32, 0xa556, 0xbed6, 0xd961, 0x352e, 0x61be, 0xbf00,
    0xf3bd, 0x473b, 0x559b, 0x3f17, 0x567f, 0x87db, 0x97f5, 0x3f60, 0xb51b,
    0xd464, 0x5126, 0x3f9e, 0xa8b4, 0xac8c, 0xe548, 0x3ff1};

static unsigned short S2[] = {
    0x2b4c, 0x8385, 0x487f, 0xbc68, 0x237f, 0xa1f5, 0x420a, 0x3c7e, 0xee75,
    0x2812, 0x6cad, 0x3c99, 0x39af, 0x457b, 0x637b, 0xbcb8, 0xedf9, 0xc086,
    0xed01, 0xbccd, 0x9513, 0x969f, 0xb791, 0x3cf1, 0xcd11, 0xae46, 0xea62,
    0x3d06, 0x650f, 0xb74a, 0xb518, 0xbd27, 0x0713, 0x216e, 0xa216, 0xbd46,
    0x9f2e, 0x463a, 0x8db0, 0x3d57, 0x0dd5, 0x0a69, 0xfa6a, 0x3d87, 0x9397,
    0xd2cd, 0x5c47, 0x3d7d, 0xb5d8, 0x1fe6, 0x33a7, 0xbdc3, 0xa2da, 0x9e19,
    0xcb8f, 0xbde5, 0xe7b9, 0xaf5a, 0xa42f, 0xbde8, 0xd544, 0xb2c4, 0x48f2,
    0x3e1e, 0x8488, 0x3b1d, 0x26d1, 0x3e52, 0x084c, 0xaf17, 0xd46d, 0x3e80,
    0x3efc, 0xc871, 0x8009, 0x3eb3, 0xb36e, 0x7f39, 0xe2d6, 0x3ef0, 0x73d7,
    0x1f7d, 0xecd8, 0x3f36, 0xb790, 0x66d5, 0x4ff3, 0x3f8a, 0x9d96, 0xe325,
    0x9625, 0x3ff0};
#endif

#ifdef MIEEE
static unsigned short S1[] = {
    0x3c75, 0x3373, 0xbd4a, 0x01b0, 0xbc9b, 0x8a3d, 0x2418, 0xb05e, 0x3cad,
    0x724d, 0x8248, 0x7fe6, 0x3cd3, 0xcc1a, 0x2c15, 0x7515, 0xbd0d, 0x91b5,
    0xbaaa, 0xbda0, 0x3d30, 0xb80c, 0xbe40, 0xd1ae, 0xbd23, 0x8ba2, 0xe110,
    0xbf82, 0xbd78, 0xa3bb, 0x2541, 0x3725, 0x3da4, 0xdea5, 0x72b0, 0x9394,
    0xbdb1, 0xc487, 0x33b0, 0x17f7, 0xbde8, 0x734a, 0xce48, 0x8aac, 0x3e17,
    0x4565, 0x0207, 0x3862, 0xbe11, 0xbd4b, 0xd68b, 0xfffc, 0xbe63, 0x2671,
    0x2f23, 0xdf61, 0x3e83, 0x6ff0, 0x511c, 0xac08, 0x3eaa, 0x3d7c, 0x3dcf,
    0xfea3, 0xbed6, 0xa556, 0x5f32, 0x24b1, 0xbf00, 0x61be, 0x352e, 0xd961,
    0x3f17, 0x559b, 0x473b, 0xf3bd, 0x3f60, 0x97f5, 0x87db, 0x567f, 0x3f9e,
    0x5126, 0xd464, 0xb51b, 0x3ff1, 0xe548, 0xac8c, 0xa8b4};

static unsigned short S2[] = {
    0xbc68, 0x487f, 0x8385, 0x2b4c, 0x3c7e, 0x420a, 0xa1f5, 0x237f, 0x3c99,
    0x6cad, 0x2812, 0xee75, 0xbcb8, 0x637b, 0x457b, 0x39af, 0xbccd, 0xed01,
    0xc086, 0xedf9, 0x3cf1, 0xb791, 0x969f, 0x9513, 0x3d06, 0xea62, 0xae46,
    0xcd11, 0xbd27, 0xb518, 0xb74a, 0x650f, 0xbd46, 0xa216, 0x216e, 0x0713,
    0x3d57, 0x8db0, 0x463a, 0x9f2e, 0x3d87, 0xfa6a, 0x0a69, 0x0dd5, 0x3d7d,
    0x5c47, 0xd2cd, 0x9397, 0xbdc3, 0x33a7, 0x1fe6, 0xb5d8, 0xbde5, 0xcb8f,
    0x9e19, 0xa2da, 0xbde8, 0xa42f, 0xaf5a, 0xe7b9, 0x3e1e, 0x48f2, 0xb2c4,
    0xd544, 0x3e52, 0x26d1, 0x3b1d, 0x8488, 0x3e80, 0xd46d, 0xaf17, 0x084c,
    0x3eb3, 0x8009, 0xc871, 0x3efc, 0x3ef0, 0xe2d6, 0x7f39, 0xb36e, 0x3f36,
    0xecd8, 0x1f7d, 0x73d7, 0x3f8a, 0x4ff3, 0x66d5, 0xb790, 0x3ff0, 0x9625,
    0xe325, 0x9d96};
#endif

#ifdef UNK
/* x exp(-x) chin(x), inverted interval 8 to 18 */
static double C1[] = {-8.12435385225864036372E-182.17586413290339214377E-17,
                      5.22624394924072204667E-17,  -9.48812110591690559363E-16,
                      5.35546311647465209166E-15,  -1.21009970113732918701E-14,
                      -6.00865178553447437951E-147.16339649156028587775E-13,
                      -2.93496072607599856104E-12, -1.40359438136491256904E-12,
                      8.76302288609054966081E-11,  -4.40092476213282340617E-10,
                      -1.87992075640569295479E-101.31458150989474594064E-8,
                      -4.75513930924765465590E-8,  -2.21775018801848880741E-7,
                      1.94635531373272490962E-6,   4.33505889257316408893E-6,
                      -6.13387001076494349496E-5,  -3.13085477492997465138E-4,
                      4.97164789823116062801E-4,   2.64347496031374526641E-2,
                      1.11446150876699213025E0};

/* x exp(-x) chin(x), inverted interval 18 to 88 */
static double C2[] = {8.06913408255155572081E-18,  -2.08074168180148170312E-17,
                      -5.98111329658272336816E-172.68533951085945765591E-16,
                      4.52313941698904694774E-16,  -3.10734917335299464535E-15,
                      -4.42823207332531972288E-153.49639695410806959872E-14,
                      6.63406731718911586609E-14,  -3.71902448093119218395E-13,
                      -1.27135418132338309016E-122.74851141935315395333E-12,
                      2.33781843985453438400E-11,  2.71436006377612442764E-11,
                      -2.56600180000355990529E-10, -1.61021375163803438552E-9,
                      -4.72543064876271773512E-9,  -3.00095178028681682282E-9,
                      7.79387474390914922337E-8,   1.06942765566401507066E-6,
                      1.59503164802313196374E-5,   3.49592575153777996871E-4,
                      1.28475387530065247392E-2,   1.03665693917934275131E0};
#endif

#ifdef DEC
static unsigned short C1[] = {
    01220250157055002170200214270022310013004301232650022340,
    00225610002231001774600130430123610013637500023520024467,
    00243000171555014130000004460124531017677701262100035616,
    01252070046604016776000771320026111012066600266060064143,
    01265160103615005412700054360126305010472100254150004134,
    00277000131556016472501575530130361017060200772740055406,
    01301160131420012547200172310031541015374701773120056304,
    01321140035517004154500431510132556002041501100440172442,
    00334020117041003115200103640033621007273700506470013720,
    01346000121366014001000632650135244002263700137560044742,
    00354020052052000652300435640036730010666000202770162146,
    0040216012325401351470005724};

static unsigned short C2[] = {
    00220240154550010431101442570122277016503701334430155601,
    01226110165102015705300552520023232014623501535110113222,
    00234020057340014530400104710124137016417101130710100002,
    01242370105473005613000220220025035007326600567460164433,
    00252250061313005560001654070125721005631201076130051215,
    01262620166534011533600666530026501006430701274420065573,
    00273150121375014202000453560027356014076400706410046570,
    01302150010503014633501777370130735004713400152150163665,
    01312420056523015527600500530131116003451500507070163512,
    00322470057507010754500320070033217010450100217060025047,
    00342050146413003374600765620035267004460500653550002772,
    00365220077173013071601703040040204013045401305710027270};
#endif

#ifdef IBMPC
static unsigned short C1[] = {
    0x4463, 0xa478, 0xbbc5, 0xbc62, 0xa49c, 0x74d6, 0x1604, 0x3c79, 0xc2c4,
    0x23fc, 0x2093, 0x3c8e, 0x4527, 0xa09d, 0x179f, 0xbcd1, 0x0025, 0xb858,
    0x1e6d, 0x3cf8, 0x0772, 0xf591, 0x3fbf, 0xbd0b, 0x0fcb, 0x9dfe, 0xe9b0,
    0xbd30, 0xcd0c, 0xc5b0, 0x3436, 0x3d69, 0xe164, 0xab0a, 0xd0f1, 0xbd89,
    0xa10c, 0x2561, 0xb13a, 0xbd78, 0xbbed, 0xdd3a, 0x166d, 0x3dd8, 0x8b61,
    0x4fd7, 0x3e30, 0xbdfe, 0x43d3, 0x1567, 0xd662, 0xbde9, 0x4b98, 0xffd9,
    0x3afc, 0x3e4c, 0xa8cd, 0xe86c, 0x8769, 0xbe69, 0x9ea4, 0xb204, 0xc421,
    0xbe8d, 0x421f, 0x264d, 0x53c4, 0x3ec0, 0xe2fa, 0xea34, 0x2ebb, 0x3ed2,
    0x0cd7, 0xd801, 0x145e, 0xbf10, 0xc93c, 0xe2fd, 0x84b3, 0xbf34, 0x68ef,
    0x41aa, 0x4a85, 0x3f40, 0xfc8d, 0x0417, 0x11b6, 0x3f9b, 0xe17b, 0x974c,
    0xd4d5, 0x3ff1};

static unsigned short C2[] = {
    0x3916, 0x1119, 0x9b2d, 0x3c62, 0x7b70, 0xf6e4, 0xfd43, 0xbc77, 0x6b55,
    0x5bc5, 0x3d48, 0xbc91, 0x32d2, 0xbae9, 0x5993, 0x3cb3, 0x8227, 0x1958,
    0x4bdc, 0x3cc0, 0x3000, 0x32c7, 0xfd0f, 0xbceb, 0x0482, 0x6b8b, 0xf167,
    0xbcf3, 0xdd23, 0xcbbc, 0xaed6, 0x3d23, 0x1d61, 0x6b70, 0xac59, 0x3d32,
    0x6a52, 0x51f1, 0x2b99, 0xbd5a, 0xcdb5, 0x935b, 0x5dab, 0xbd76, 0x4d6f,
    0xf5e4, 0x2d18, 0x3d88, 0x095e, 0xb882, 0xb45f, 0x3db9, 0x29af, 0x8e34,
    0xd83e, 0x3dbd, 0xbffc, 0x799b, 0xa228, 0xbdf1, 0xbcf7, 0x8351, 0xa9cb,
    0xbe1b, 0xca05, 0x7b57, 0x4baa, 0xbe34, 0xfce9, 0xaa38, 0xc729, 0xbe29,
    0xa681, 0xf1ec, 0xebe8, 0x3e74, 0xc545, 0x2478, 0xf128, 0x3eb1, 0xcfae,
    0x66fc, 0xb9a1, 0x3ef0, 0xa0bf, 0xad5d, 0xe930, 0x3f36, 0xde19, 0x7639,
    0x4fcf, 0x3f8a, 0x25d7, 0x962f, 0x9625, 0x3ff0};
#endif

#ifdef MIEEE
static unsigned short C1[] = {
    0xbc62, 0xbbc5, 0xa478, 0x4463, 0x3c79, 0x1604, 0x74d6, 0xa49c, 0x3c8e,
    0x2093, 0x23fc, 0xc2c4, 0xbcd1, 0x179f, 0xa09d, 0x4527, 0x3cf8, 0x1e6d,
    0xb858, 0x0025, 0xbd0b, 0x3fbf, 0xf591, 0x0772, 0xbd30, 0xe9b0, 0x9dfe,
    0x0fcb, 0x3d69, 0x3436, 0xc5b0, 0xcd0c, 0xbd89, 0xd0f1, 0xab0a, 0xe164,
    0xbd78, 0xb13a, 0x2561, 0xa10c, 0x3dd8, 0x166d, 0xdd3a, 0xbbed, 0xbdfe,
    0x3e30, 0x4fd7, 0x8b61, 0xbde9, 0xd662, 0x1567, 0x43d3, 0x3e4c, 0x3afc,
    0xffd9, 0x4b98, 0xbe69, 0x8769, 0xe86c, 0xa8cd, 0xbe8d, 0xc421, 0xb204,
    0x9ea4, 0x3ec0, 0x53c4, 0x264d, 0x421f, 0x3ed2, 0x2ebb, 0xea34, 0xe2fa,
    0xbf10, 0x145e, 0xd801, 0x0cd7, 0xbf34, 0x84b3, 0xe2fd, 0xc93c, 0x3f40,
    0x4a85, 0x41aa, 0x68ef, 0x3f9b, 0x11b6, 0x0417, 0xfc8d, 0x3ff1, 0xd4d5,
    0x974c, 0xe17b};

static unsigned short C2[] = {
    0x3c62, 0x9b2d, 0x1119, 0x3916, 0xbc77, 0xfd43, 0xf6e4, 0x7b70, 0xbc91,
    0x3d48, 0x5bc5, 0x6b55, 0x3cb3, 0x5993, 0xbae9, 0x32d2, 0x3cc0, 0x4bdc,
    0x1958, 0x8227, 0xbceb, 0xfd0f, 0x32c7, 0x3000, 0xbcf3, 0xf167, 0x6b8b,
    0x0482, 0x3d23, 0xaed6, 0xcbbc, 0xdd23, 0x3d32, 0xac59, 0x6b70, 0x1d61,
    0xbd5a, 0x2b99, 0x51f1, 0x6a52, 0xbd76, 0x5dab, 0x935b, 0xcdb5, 0x3d88,
    0x2d18, 0xf5e4, 0x4d6f, 0x3db9, 0xb45f, 0xb882, 0x095e, 0x3dbd, 0xd83e,
    0x8e34, 0x29af, 0xbdf1, 0xa228, 0x799b, 0xbffc, 0xbe1b, 0xa9cb, 0x8351,
    0xbcf7, 0xbe34, 0x4baa, 0x7b57, 0xca05, 0xbe29, 0xc729, 0xaa38, 0xfce9,
    0x3e74, 0xebe8, 0xf1ec, 0xa681, 0x3eb1, 0xf128, 0x2478, 0xc545, 0x3ef0,
    0xb9a1, 0x66fc, 0xcfae, 0x3f36, 0xe930, 0xad5d, 0xa0bf, 0x3f8a, 0x4fcf,
    0x7639, 0xde19, 0x3ff0, 0x9625, 0x962f, 0x25d7};
#endif

/* Sine and cosine integrals */

#ifdef ANSIPROT
extern double log(double);
extern double exp(double);
extern double fabs(double);
extern double chbevl(doublevoid *, int);
#else
double log(), exp(), fabs(), chbevl();
#endif
#define EUL 0.57721566490153286061
extern double MACHEP, MAXNUM, PIO2;

int shichi(x, si, ci) double x;
double *si, *ci;
{
  double k, z, c, s, a;
  short sign;

  if (x < 0.0) {
    sign = -1;
    x = -x;
  } else
    sign = 0;

  if (x == 0.0) {
    *si = 0.0;
    *ci = -MAXNUM;
    return (0);
  }

  if (x >= 8.0)
    goto chb;

  z = x * x;

  /* Direct power series expansion */

  a = 1.0;
  s = 1.0;
  c = 0.0;
  k = 2.0;

  do {
    a *= z / k;
    c += a / k;
    k += 1.0;
    a /= k;
    s += a / k;
    k += 1.0;
  } while (fabs(a / s) > MACHEP);

  s *= x;
  goto done;

chb:

  if (x < 18.0) {
    a = (576.0 / x - 52.0) / 10.0;
    k = exp(x) / x;
    s = k * chbevl(a, S1, 22);
    c = k * chbevl(a, C1, 23);
    goto done;
  }

  if (x <= 88.0) {
    a = (6336.0 / x - 212.0) / 70.0;
    k = exp(x) / x;
    s = k * chbevl(a, S2, 23);
    c = k * chbevl(a, C2, 24);
    goto done;
  } else {
    if (sign)
      *si = -MAXNUM;
    else
      *si = MAXNUM;
    *ci = MAXNUM;
    return (0);
  }
done:
  if (sign)
    s = -s;

  *si = s;

  *ci = EUL + log(x) + c;
  return (0);
}

Messung V0.5 in Prozent
C=98 H=86 G=91

¤ Dauer der Verarbeitung: 0.13 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.