フィルターのクリア

How can I define the error function and use a Maclaurin series to approximate a value?

3 ビュー (過去 30 日間)
codeconstructo
codeconstructo 2023 年 3 月 3 日
コメント済み: Sam Chak 2023 年 3 月 3 日
My question is: erf (x) = 2/sqrt(pi)*integral(exp(-(t^2)) from 0 to x
(a) Use the Maclaurin series (Taylor series centered at 0) to construct a table for erf (x) that is accurate
to 10^-4 for erf (xi) where xi = 0:2i for i = 0; 1; : : : ; 5.
I first defined the function and then realized that erf is a built in function so I tried
erf = @(x) erf(x)
erf = function_handle with value:
@(x)erf(x)
but got this response:
Unable to find function@(x)(2/(sqrt(pi)))*integral(exp(-(t^2)),0,x) within
C:\Users\dboeh\OneDrive\Documents\NAU\MAT 362\dbb223_03.m.
Does anyone have ideas?

回答 (1 件)

Sam Chak
Sam Chak 2023 年 3 月 3 日
Are you looking for something like this?
syms x
T1 = taylor(erf(x))
T1 = 
  3 件のコメント
Sam Chak
Sam Chak 2023 年 3 月 3 日
The built-in erf() function is stored in MATLAB installation directory.
which erf
built-in (/MATLAB/toolbox/matlab/specfun/@double/erf) % double method
You created an anonymous function in a m-file script (dbb223_03.m) which has the same filename as the built-in one and ran the m-file in OneDrive. So, it tries to search erf within the m-file. Try assigning another name.
% Creating an anonymous function
anonfcn = @(x) erf(x)
anonfcn = function_handle with value:
@(x)erf(x)
% Built-in
erf(pi)
ans = 1.0000
% Test
anonfcn(pi)
ans = 1.0000

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeError Functions についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by