用以下公式求 f(x) 的值。当通项的绝对值小于 10^-7 时停止计算, x 的值由键盘输入。 f(x)=a 1 x^1-a 2 x^2+a 3 x^3-...+(-1) ^(n+1)*a n x^n+...,|X|<1 其中 a 1 =1 , a 2 =2 , a n =1/(a n-2 +a n-1 ) ,n=1,2,3,4,5,... Option Explicit Private Sub Commandl_Click() Dim x As Single , fx As Single Dim a As Single,a1 As Single,a2 As Single Dim t As Single a1=l : a2=2 x=text1 If ___________ Then MsgBox("x 必须在 -1---1 之间 ") ExitSub End If fx=a 1 *x-a 2 *x*x t=(-1)*x*x Do a=1/(a l +a 2 ) t=(-1)*x*x fx= __________ a l =a 2 Loop Until Abs(a*t)<0.0000001 Text2=fx End Sub
举一反三
- 完成以下功能:计算分段函数完成程序。 x2+1 (x<0) y= 2x+1 (0≤x<1) 3x3 (x≥1) Private Sub Command1_Click() Dim y As Single, x As Single x = InputBox("请输入x的值") If x() Then y = x * x + 1 () x < 1 Then y = 2 * x + 1 Else y = 3 * x ^ 3 End If Print x; y End Sub
- \( {1 \over {1 + x}} \)的麦克劳林公式为( )。 A: \( {1 \over {1 + x}} = 1 + x + { { {x^2}} \over 2} + \cdots + { { {x^n}} \over {n!}} + o\left( { { x^n}} \right) \) B: \( {1 \over {1 + x}} = 1 + x + {x^2} + \cdots + {x^n} + o\left( { { x^n}} \right) \) C: \( {1 \over {1 + x}} = 1 - x + {x^2} - \cdots + {( - 1)^n}{x^n} + o\left( { { x^n}} \right) \) D: \( {1 \over {1 + x}} = 1 - x - { { {x^2}} \over 2}- \cdots - { { {x^n}} \over {n!}} + o\left( { { x^n}} \right) \)
- \( {1 \over {1 + x}} \)的麦克劳林公式为( ). A: \( {1 \over {1 + x}} = 1 + x + { { {x^2}} \over 2} + \cdots + { { {x^n}} \over {n!}} + o\left( { { x^n}} \right) \) B: \( {1 \over {1 + x}} = 1 + x + {x^2} + \cdots + {x^n} + o\left( { { x^n}} \right) \) C: \( {1 \over {1 + x}} = 1 - x + {x^2} - \cdots + {( - 1)^n}{x^n} + o\left( { { x^n}} \right) \)
- 求方程组的解,取初值为(1,1,1)。[img=250x164]180333307ab8fde.jpg[/img] A: f=@(x) [x(1)^3+x(2)-x(3)-5; 2*x(1)+3*x(2)^2-6; x(1)+x(2)+x(3)-3];x=fsolve(f,[1,1,1],optimset('Display','off')) B: x=fsolve(@(x) [x(1)^3+x(2)-x(3)-5; 2*x(1)+3*x(2)^2-6; x(1)+x(2)+x(3)-3],[1,1,1]) C: f=@(x) [x(1)^3+x(2)-x(3)-5; 2*x(1)+3*x(2)^2-6; x(1)+x(2)+x(3)-3];x=fzero(f,[1,1,1]) D: x=fzero(@(x) [x(1)^3+x(2)-x(3)-5; 2*x(1)+3*x(2)^2-6; x(1)+x(2)+x(3)-3],[1,1,1])
- 函数\(f(x) = x^2,\; x \in [-\pi,\pi]\)的Fourier级数为 A: \(\frac{\pi^2}{3}+4\Sigma_{n=1}^{\infty} \frac{(-1)^n}{n^2} \sin nx ,\; x \in [-\pi,\pi]\) B: \(\frac{\pi^2}{3}+4\Sigma_{n=1}^{\infty} \frac{(-1)^n}{n^2} \cos nx ,\; x \in [-\pi,\pi]\) C: \(\frac{2\pi^2}{3}+4\Sigma_{n=1}^{\infty} \frac{(-1)^n}{n^2} \sin nx ,\; x \in [-\pi,\pi]\) D: \(\frac{2\pi^2}{3}+4\Sigma_{n=1}^{\infty} \frac{(-1)^n}{n^2} \cos nx ,\; x \in [-\pi,\pi]\)