код такой:
#include <stdio.h>
double sum2(double x, unsigned int N, unsigned int i)
{
double t;
if (i < N && i > 1)
{
if (i % 10 == 0)
{
printf("\\right.\\right.\\right.\\right.\\right.\\right.\\right.\\right.\\right. \\cdot[/tex]\n[tex]");
}
printf("\\left(1-\\dfrac{%u}{%u}x", 2*i-3, 2*i);
t = 1.0 - (2.0*i-3.0) / (2.0*i) * x * sum2(x, N, i + 1);
printf("\\right)");
return t;
}
else if (i == 1 || i == 0)
{
printf("\\left(1+\\dfrac12x");
t = 1.0 + 1.0/2.0 * x * sum2(x, N, 2);
printf("\\right)");
return t;
}
else
{
return 1;
}
}
int main(int argc, char *argv[])
{
printf("\nSum: %e\n", sum2(1.0, 150, 1));
return 0;
}
насколько я понял, эта сумма сходится при малом количестве членов только в окрестности единицы. для сходимости в областях подальше, надо очень много членов ряда и хорошую библиотеку для работы с числами произвольной точности.
\( \left(1+\dfrac12x\left(1-\dfrac{1}{4}x\left(1-\dfrac{3}{6}x\left(1-\dfrac{5}{8}x\left(1-\dfrac{7}{10}x\left(1-\dfrac{9}{12}x\left(1-\dfrac{11}{14}x\left(1-\dfrac{13}{16}x\left(1-\dfrac{15}{18}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{17}{20}x\left(1-\dfrac{19}{22}x\left(1-\dfrac{21}{24}x\left(1-\dfrac{23}{26}x\left(1-\dfrac{25}{28}x\left(1-\dfrac{27}{30}x\left(1-\dfrac{29}{32}x\left(1-\dfrac{31}{34}x\left(1-\dfrac{33}{36}x\left(1-\dfrac{35}{38}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{37}{40}x\left(1-\dfrac{39}{42}x\left(1-\dfrac{41}{44}x\left(1-\dfrac{43}{46}x\left(1-\dfrac{45}{48}x\left(1-\dfrac{47}{50}x\left(1-\dfrac{49}{52}x\left(1-\dfrac{51}{54}x\left(1-\dfrac{53}{56}x\left(1-\dfrac{55}{58}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{57}{60}x\left(1-\dfrac{59}{62}x\left(1-\dfrac{61}{64}x\left(1-\dfrac{63}{66}x\left(1-\dfrac{65}{68}x\left(1-\dfrac{67}{70}x\left(1-\dfrac{69}{72}x\left(1-\dfrac{71}{74}x\left(1-\dfrac{73}{76}x\left(1-\dfrac{75}{78}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{77}{80}x\left(1-\dfrac{79}{82}x\left(1-\dfrac{81}{84}x\left(1-\dfrac{83}{86}x\left(1-\dfrac{85}{88}x\left(1-\dfrac{87}{90}x\left(1-\dfrac{89}{92}x\left(1-\dfrac{91}{94}x\left(1-\dfrac{93}{96}x\left(1-\dfrac{95}{98}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{97}{100}x\left(1-\dfrac{99}{102}x\left(1-\dfrac{101}{104}x\left(1-\dfrac{103}{106}x\left(1-\dfrac{105}{108}x\left(1-\dfrac{107}{110}x\left(1-\dfrac{109}{112}x\left(1-\dfrac{111}{114}x\left(1-\dfrac{113}{116}x\left(1-\dfrac{115}{118}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{117}{120}x\left(1-\dfrac{119}{122}x\left(1-\dfrac{121}{124}x\left(1-\dfrac{123}{126}x\left(1-\dfrac{125}{128}x\left(1-\dfrac{127}{130}x\left(1-\dfrac{129}{132}x\left(1-\dfrac{131}{134}x\left(1-\dfrac{133}{136}x\left(1-\dfrac{135}{138}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{137}{140}x\left(1-\dfrac{139}{142}x\left(1-\dfrac{141}{144}x\left(1-\dfrac{143}{146}x\left(1-\dfrac{145}{148}x\left(1-\dfrac{147}{150}x\left(1-\dfrac{149}{152}x\left(1-\dfrac{151}{154}x\left(1-\dfrac{153}{156}x\left(1-\dfrac{155}{158}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{157}{160}x\left(1-\dfrac{159}{162}x\left(1-\dfrac{161}{164}x\left(1-\dfrac{163}{166}x\left(1-\dfrac{165}{168}x\left(1-\dfrac{167}{170}x\left(1-\dfrac{169}{172}x\left(1-\dfrac{171}{174}x\left(1-\dfrac{173}{176}x\left(1-\dfrac{175}{178}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{177}{180}x\left(1-\dfrac{179}{182}x\left(1-\dfrac{181}{184}x\left(1-\dfrac{183}{186}x\left(1-\dfrac{185}{188}x\left(1-\dfrac{187}{190}x\left(1-\dfrac{189}{192}x\left(1-\dfrac{191}{194}x\left(1-\dfrac{193}{196}x\left(1-\dfrac{195}{198}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{197}{200}x\left(1-\dfrac{199}{202}x\left(1-\dfrac{201}{204}x\left(1-\dfrac{203}{206}x\left(1-\dfrac{205}{208}x\left(1-\dfrac{207}{210}x\left(1-\dfrac{209}{212}x\left(1-\dfrac{211}{214}x\left(1-\dfrac{213}{216}x\left(1-\dfrac{215}{218}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{217}{220}x\left(1-\dfrac{219}{222}x\left(1-\dfrac{221}{224}x\left(1-\dfrac{223}{226}x\left(1-\dfrac{225}{228}x\left(1-\dfrac{227}{230}x\left(1-\dfrac{229}{232}x\left(1-\dfrac{231}{234}x\left(1-\dfrac{233}{236}x\left(1-\dfrac{235}{238}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{237}{240}x\left(1-\dfrac{239}{242}x\left(1-\dfrac{241}{244}x\left(1-\dfrac{243}{246}x\left(1-\dfrac{245}{248}x\left(1-\dfrac{247}{250}x\left(1-\dfrac{249}{252}x\left(1-\dfrac{251}{254}x\left(1-\dfrac{253}{256}x\left(1-\dfrac{255}{258}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \left(1-\dfrac{257}{260}x\left(1-\dfrac{259}{262}x\left(1-\dfrac{261}{264}x\left(1-\dfrac{263}{266}x\left(1-\dfrac{265}{268}x\left(1-\dfrac{267}{270}x\left(1-\dfrac{269}{272}x\left(1-\dfrac{271}{274}x\left(1-\dfrac{273}{276}x\left(1-\dfrac{275}{278}x\right.\right.\right.\right.\right.\right.\right.\right.\right. \cdot \)
\( \ldots \)
Sum: 1.414291e+000