how to use vectorization and integral on erf function and erfc function?
古いコメントを表示

Im trying to code for these equations but my math background isnt on par with this level yet. I appreciate any help on my final!
My guess would be use the values that my graph of 1-erf(z) gave me but Im not sure my graph is correct because only one of the values matched the graph erfc(z).
7 件のコメント
syms z
around = 1/2
numterm = 7
matlabFunction(vpa(taylor(erfc(z), z, around, 'Order', numterm),16))
Henry B.
2021 年 5 月 27 日
Walter Roberson
2021 年 5 月 27 日
No, the 7 was arbitrary. You should have followed the first part of the assignment to determine how many terms were needed.
taylor takes a taylor series expansion; https://www.mathworks.com/help/symbolic/sym.taylor.html . It requires the Symbolic Toolbox. The current syntax of taylor() requires R2006b or later if I recall correctly. I don't think you can purchase Symbolic Toolbox for use with Octave.
taylor() computes the coefficients exactly, such as having explicit sqrt(pi) and erf(1/2) calls. vpa() converts all such constants to their floating point equivalents.
I would suggest that you take your existing code, and run it for the same number of terms that I used (that is, 7), and see whether you get the same output as would be computed by the function handle in my comment. If you do get the same output, to within round-off error, then you know that you are on the right track. If you get significant differences then you have done something wrong in your taylor expansion code.
Henry B.
2021 年 5 月 27 日
format long g
syms x
result = int(erfc(x), 0, 2)
double(result)
int(erfc(x), 0, x)
@Henry:
Why do you modify my code for the calculation of erfc by prescribing n as (1:6) ? n, the number of terms needed to approximate erfc(z) within a specified tolerance, is calculated within erfc depending on the magnitude of term. For higher values of z, the n also has to increase. So first try to understand what the code does before starting to modify it.
回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Mathematical Functions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


