請問依下各位先進 以下程式要如何寫呢 小弟感激不盡
Develop an m-file named fun_xb that evaluates the flowing series:
f( x )=x-x^2/2+x^3/3-..+(-1)^(n+1)*x^n/n
The values of x and n are to given by input. Test the function by comparing the result with hand calculations for x=1 and n=4 .The foregoing sreies is a truncated Maclaurin expansion of log(1+x) and coverges for -1
Knowing this,test your function for selected x value, such as x=-0.5 and 0.5,with n= 1,2,3,5,10,20,50,and compare with log(1+x). (Convergence becomes increasingly difficult as x approaches -1 or 1)
Develop an m-file named fun_xb that evaluates the flowing series:
f( x )=x-x^2/2+x^3/3-..+(-1)^(n+1)*x^n/n
The values of x and n are to given by input. Test the function by comparing the result with hand calculations for x=1 and n=4 .The foregoing series is a truncated Maclaurin expansion of log(1+x) and coverges for -1<X<1.
Knowing this,test your function for selected x value, such as x=-0.5 and 0.5,with n= 1,2,3,5,10,20,50,and compare with log(1+x). (Convergence becomes increasingly difficult as x approaches -1 or 1)
Test的部分應該不難吧?
手算部分就直接算
至於log(1+x)也不難compute啊
就隨便選個x值~n就用那些指定的
然後跟f( x )算出來的結果比較就可以了
可以plot graph來做具體的比較
life is an eternal flight of myself from myself.
內文搜尋




























































































