You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
erfc with complex number
24 views (last 30 days)
Show older comments
Hi all
I want to compute erfc(.) of a complex number. How can I do that? Is there any way to use erfc(.) of matlab?
Accepted Answer
Matt Fig
on 10 May 2011
14 Comments
Dilip Jose
on 30 Jan 2020
sir will you pls tel me how to define erfc(.)....in terms of complex number ....im having my rsults interms exponentiam and complementary error function ....dont know how to plot this.....struggling for 3 months
Dilip Jose
on 30 Jan 2020
i have tried something but couldn't....pls find the attachemnt
Dilip Jose
on 30 Jan 2020
close all
syms z;
gr=5;
gc=5;
M=1;
w=0.5;
pr=7;
sc=2.01;
t=0.4;
m=(M+(2*1i*w));
s1=z;
s2=(2*sqrt(t));
x=((s1)./(s2));
a1=(x*t);
a2=(2*m*(sqrt(pi)));
a=((m)./(pr-1));
b=((m)./(sc-1));
x=((s1)./(s2));
u1=((x^2+(m*t))*t);
u2=4*m;
d1=(x*(sqrt(t)))*(1-(4*m*t));
d2=(8*m^3/2);
v1=gr;
v2=(a*(1-pr));
k1=gc;
k2=(b*(1-sc));
h1=exp(a*t);
h2=2;
e1=(exp(2*x*(sqrt(m*t))));
e2=(erfc(x+(sqrt(m*t))));
e3=(exp(-2*x*(sqrt(m*t))));
e4=(erfc(x-(sqrt(m*t))));
b1=(exp(2*x*((sqrt((m+a)*t)))));
b2=(erfc(x+(sqrt((m+a)*t))));
b3=(exp(-2*x*(sqrt((m+a)*t))));
b4=(erfc(x-(sqrt((m+a)*t))));
b5=(exp(2*x*((sqrt((m+b)*t)))));
b6=(erfc(x+(sqrt((m+b)*t))));
b7=(exp(-2*x*(sqrt((m+b)*t))));
b8=(erfc(x-(sqrt((m+b)*t))));
e5=exp(-(x^2+(m*t)));
c1=(exp(2*x*(sqrt(pr*a*t))));
c2=(erfc(x*(sqrt(pr)+(sqrt(a*t)))));
c3=((exp(-2*x*(sqrt(pr*a*t)))));
c4=(erfc(x*(sqrt(pr)-(sqrt(a*t)))));
l1=(exp(2*x*(sqrt(sc*b*t))));
l2=(erfc(x*(sqrt(sc)+(sqrt(b*t)))));
l3=((exp(-2*x*(sqrt(sc*b*t)))));
l4=(erfc(x*(sqrt(sc)-(sqrt(b*t)))));
f1=(exp(b*t));
f2=2;
l=((a1)./(a2));
f=((f1)./(f2));
h=((h1)./(h2));
j1=((u1)./(u2));
j2=((d1)./(d2));
j3=((v1)./(v2));
j4=((k1)./(k2));
q1=(2*(j1*((e1*e2)+(e3*e4))+(j2*((e3*e4)-(e1*e2))-(l*e5))));
q2=((j3+j4)*(1/2)*((e1*e2)+(e3*e4)));
q3=((j3*(h*(b1*b2)+(b3*b4))));
q4=((j4*(f*(b5*b6)+(b7*b8))));
q5=(j3*(erfc(x*sqrt(pr))));
q6=(j4*erfc(x*sqrt(sc)));
q7=(j3*(h*((c1*c2)+(c3*c4))));
q8=(j4*(f*((l1*l2)+(l3*l4))));
q=(q1+q2-q3-q4-q5-q6+q7+q8);
fplot(z,q);
xlim([0 5])
ylim([0 1])
hold on
title('Axial velocity profiles for different values of gr & gc');
hold off
Walter Roberson
on 30 Jan 2020
The symbolic toolbox can take erfc of a complex number as long as it is passed in symbolic form. erfc(sym(.3-.2i)) for example.
Dilip Jose
on 5 Feb 2020
yes sir now im using fadf.m for erfc...but now symbolic variable is exist inside fadf ...error shwing wat to do
Walter Roberson
on 5 Feb 2020
Edited: Walter Roberson
on 5 Feb 2020
Dilip Jose
on 5 Feb 2020
Edited: Dilip Jose
on 5 Feb 2020
sir i have installed package.....in that erfc change to fadf.....in fadf(symbolic variable)...what to do....
syms z
dt=0.01;t1=0;t2=5;t=(t1:dt:t2);
u=0.2;
w=0.5;
M=1;
m=((M+(2*1i*w))*u);
k=(fadf(z./(2*(u).^.5)+(M+(2*1i*w))*u).^.5);
re_k=real(k);im_k=imag(k);
plot(re_z,im_k);
Walter Roberson
on 5 Feb 2020
fadf is not designed for symbolic use.
If you have the symbolic toolbox then it already handles erfc of a complex number as long as the number is passed in symbolic form.
Dilip Jose
on 5 Feb 2020
yes sir thank you...in my result z is infinite plane ....by defining sym z...i have done my plotting....but in velocity profile equation ...erfc of complex number exist....fadf is used to define erfc of complex...getting error...how to define z infinite plane extent..need a support.
Walter Roberson
on 5 Feb 2020
In your original code at https://www.mathworks.com/matlabcentral/answers/7153-erfc-with-complex-number#comment_791526 you have
fplot(z,q);
where z is a plain symbolic variable and q is a symbolic expression in z. However, q is complex valued and fplot() cannot plot complex valued things. You can, though, do things like
fplot3(z, real(q), imag(q))
You cannot use fplot to plot over the entire z plane -- for one thing the imaginary component of q goes to about - 9.878*10^6730 by the time z is -1e4 .
Walter Roberson
on 5 Feb 2020
fafd needs to be able to test
ind_neg = imag(z)<0; % if some imag(z) values are negative, then ...
z(ind_neg) = conj(z(ind_neg)); % ... bring them to the upper-half plane
FF = zeros(size(z)); % define array
ind_ext = abs(z)>8; % external indices
ind_band = ~ind_ext & imag(z)<5*10^-3; % narrow band indices
It cannot test those things for symbolic z, because z could have any value to be determined later.
To work with fafd, you will need to create specific numeric z and calculate based upon those.
syms z
dt=0.01;t1=0;t2=5;t=(t1:dt:t2);
u=0.2;
w=0.5;
M=1;
m=((M+(2*1i*w))*u);
k=(fadf(z./(2*(u).^.5)+(M+(2*1i*w))*u).^.5);
re_k=real(k);im_k=imag(k);
plot(re_z,im_k);
You do not use t after you create it, so perhaps your z should be set to be t ?
Walter Roberson
on 5 Feb 2020
To check, you have
d2=(8*m^3/2);
Is it possible that that should be
d2=(8*m^(3/2));
The current expression would be equivalent to the clearer
d2=4*m^3;
Or even 8/2 instead of 4 if that somehow made documentation sense. With the /2 where it is and with the leading multiplier already even, people are going to wonder.
Dilip Jose
on 13 Feb 2020
thank you so much sir ...got some results...hope the best.
More Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)