how to use vectorization and integral on erf function and erfc function?
Mostra commenti meno recenti

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 Commenti
syms z
around = 1/2
numterm = 7
matlabFunction(vpa(taylor(erfc(z), z, around, 'Order', numterm),16))
Henry B.
il 27 Mag 2021
Walter Roberson
il 27 Mag 2021
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.
il 27 Mag 2021
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.
Risposte (0)
Categorie
Scopri di più su Mathematical Functions in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


