Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
find rhe root a complcated equation

Subject: find rhe root a complcated equation

From: george veropoulos

Date: 17 Nov, 2010 09:09:04

Message: 1 of 3

Dear friends.
I m trying to solve a complicated equation with the matlab (find the roots).
I construct a functio of this equation....

function f=energy(x)
syms x;
digits(3);
global V0;
evjoule=1.602*10.^(-19);

% length in m
D=3*10.^(-9);
L=40*10.^(-9);
L1=9*10.^(-9);
V0=0.858*evjoule;
%V0 is 60% of energy gap
%GaAs in region 1 3 5
%InAs in region 2 and 4
m_0=9.109*10.^(-34);%free electron mass
m1_star=0.067.*m_0;
m2_star=0.027.*m_0;
m3_star=0.067.*m_0;
m4_star=0.027.*m_0;
m5_star=0.067.*m_0;
h_bar=6.626*10.^(-34);% in J sec
k_1=(2.*m1_star./h_bar.^2).^0.5.*(x-V0).^0.5;
k_2=(2.*m2_star./h_bar.^2).^0.5.*x.^0.5;
k_3=(2.*m3_star./h_bar.^2).^0.5.*(x-V0).^0.5;
k_4=(2.*m4_star./h_bar.^2).^0.5*x.^0.5;
k_5=(2.*m5_star./h_bar.^2)^0.5*(x-V0).^0.5;
A11=-exp(i.*k_2.*(D+L));
A12=0;
A13=0;
A14=0;
A15=exp(-i.*k_1.*(D+L));
A16=exp(i.*k_2.*(D+L));
A17=0;
A18=0;
A21=(i.*k_2./m2_star).*exp(i.*k_2.*(D+L));
A22=0;
A23=0;
A24=0;
A25=(i.*k_1./m1_star)*exp(-i.*k_1.*(D+L));
A26=(-i.*k_2./m2_star)*exp(-i.*k_2.*(D+L));
A27=0;
A28=0;
A31=exp(i.*D.*k_2);
A32=-exp(-i.*k_4.*D);
A33=0;
A34=0;
A35=0;
A36=exp(-i.*k_2.*D);
A37=-exp(-i.*k_3.*D);
A38=0;
A41=(i.*k_2./m2_star).*exp(i.*k_2.*D);
A42=(i.*k_3./m3_star).*exp(i.*k_3.*D);
A43=0;
A44=0;
A45=0;
A46=-(i.*k_2./m2_star).*exp(-i.*k_2.*D);
A47=(i.*k_3./m3_star)*exp(-i.*k_3.*D);
A48=0;
A51=0;
A52=exp(-i.*k_3.*D);
A53=-exp(-i.*k_4.*D);
A54=0;
A55=0;
A56=0;
A57=exp(i.*k_3.*D);
A58=-exp(i.*k_4.*D);
A61=0;
A62=(i.*k_3./m3_star)*exp(-i.*k_3.*D);
A63=-(i.*k_4./m4_star)*exp(-i.*k_4.*D);
A64=0;
A65=0;
A66=0;
A67=-(i.*k_3./m3_star)*exp(i.*k_3.*D);
A68=-(i.*k_4./m4_star)*exp(i.*k_4.*D);
A71=0;
A72=0;
A73=exp(-i.*k_4.*(D+L1));
A74=exp(-i.*k_5.*(D+L));
A75=0;
A76=0;
A77=0;
A78=exp(i.*k_4.*(D+L1));
A81=0;
A82=0;
A83=(i.*k_4./m4_star).*exp(-i.*k_4.*(D+L1));
A84=-(i.*k_5./m5_star).*exp(-i.*k_5.*(D+L1));
A85=0;
A86=0;
A87=0;
A88=-(i.*k_4./m4_star).*exp(D+L1);
A=vpa([A11 A12 A13 A14 A15 A16 A17 A18 ;A21 A22 A23 A24 A25 A26 A27 A28 ;A31 A32 A33 A34 A35 A36 A37 A38 ;A41 A42 A43 A44 A45 A46 A47 A48;..../
    A51 A52 A53 A54 A55 A56 A57 A58 ;A61 A62 A63 A64 A65 A66 A67 A68; A71 A72 A73 A74 A75 A76 A77 A78; A81 A82 A83 A84 A85 A86 A87 A88 ])

%solve(det(A), 'E')
im=imag(det(A))
re=real(det(A));
f=sqrt(im.^2+re.^2);

please tell me there is a effective algothim to solve this...
thank you

Subject: find rhe root a complcated equation

From: Steven_Lord

Date: 17 Nov, 2010 15:12:01

Message: 2 of 3



"george veropoulos" <veropgr@yahoo.gr> wrote in message
news:ic063g$pat$1@fred.mathworks.com...
> Dear friends. I m trying to solve a complicated equation with the
> matlab (find the roots).
> I construct a functio of this equation....
> function f=energy(x)
> syms x;

You just overwrote your input with the symbolic variable x. Don't. Get rid
of this SYMS call.

> digits(3);

Remove this line too.

> global V0;
> evjoule=1.602*10.^(-19);
>
> % length in m D=3*10.^(-9);
> L=40*10.^(-9);
> L1=9*10.^(-9);
> V0=0.858*evjoule;
> %V0 is 60% of energy gap
> %GaAs in region 1 3 5
> %InAs in region 2 and 4
> m_0=9.109*10.^(-34);%free electron mass m1_star=0.067.*m_0;
> m2_star=0.027.*m_0;
> m3_star=0.067.*m_0;
> m4_star=0.027.*m_0;
> m5_star=0.067.*m_0;
> h_bar=6.626*10.^(-34);% in J sec
> k_1=(2.*m1_star./h_bar.^2).^0.5.*(x-V0).^0.5;
> k_2=(2.*m2_star./h_bar.^2).^0.5.*x.^0.5;
> k_3=(2.*m3_star./h_bar.^2).^0.5.*(x-V0).^0.5;
> k_4=(2.*m4_star./h_bar.^2).^0.5*x.^0.5;
> k_5=(2.*m5_star./h_bar.^2)^0.5*(x-V0).^0.5;
> A11=-exp(i.*k_2.*(D+L));
> A12=0;
> A13=0;
> A14=0;
> A15=exp(-i.*k_1.*(D+L));
> A16=exp(i.*k_2.*(D+L));
> A17=0;
> A18=0;
> A21=(i.*k_2./m2_star).*exp(i.*k_2.*(D+L));
> A22=0;
> A23=0;
> A24=0;
> A25=(i.*k_1./m1_star)*exp(-i.*k_1.*(D+L));
> A26=(-i.*k_2./m2_star)*exp(-i.*k_2.*(D+L));
> A27=0;
> A28=0;
> A31=exp(i.*D.*k_2);
> A32=-exp(-i.*k_4.*D);
> A33=0;
> A34=0;
> A35=0;
> A36=exp(-i.*k_2.*D);
> A37=-exp(-i.*k_3.*D);
> A38=0;
> A41=(i.*k_2./m2_star).*exp(i.*k_2.*D);
> A42=(i.*k_3./m3_star).*exp(i.*k_3.*D);
> A43=0;
> A44=0;
> A45=0;
> A46=-(i.*k_2./m2_star).*exp(-i.*k_2.*D);
> A47=(i.*k_3./m3_star)*exp(-i.*k_3.*D);
> A48=0;
> A51=0;
> A52=exp(-i.*k_3.*D);
> A53=-exp(-i.*k_4.*D);
> A54=0;
> A55=0;
> A56=0;
> A57=exp(i.*k_3.*D);
> A58=-exp(i.*k_4.*D);
> A61=0;
> A62=(i.*k_3./m3_star)*exp(-i.*k_3.*D);
> A63=-(i.*k_4./m4_star)*exp(-i.*k_4.*D);
> A64=0;
> A65=0;
> A66=0;
> A67=-(i.*k_3./m3_star)*exp(i.*k_3.*D);
> A68=-(i.*k_4./m4_star)*exp(i.*k_4.*D);
> A71=0;
> A72=0;
> A73=exp(-i.*k_4.*(D+L1));
> A74=exp(-i.*k_5.*(D+L));
> A75=0;
> A76=0;
> A77=0;
> A78=exp(i.*k_4.*(D+L1));
> A81=0;
> A82=0;
> A83=(i.*k_4./m4_star).*exp(-i.*k_4.*(D+L1));
> A84=-(i.*k_5./m5_star).*exp(-i.*k_5.*(D+L1));
> A85=0;
> A86=0;
> A87=0;
> A88=-(i.*k_4./m4_star).*exp(D+L1);
> A=vpa([A11 A12 A13 A14 A15 A16 A17 A18 ;A21 A22 A23 A24 A25
> A26 A27 A28 ;A31 A32 A33 A34 A35 A36 A37 A38 ;A41 A42 A43 A44
> A45 A46 A47 A48;..../
> A51 A52 A53 A54 A55 A56 A57 A58 ;A61 A62 A63 A64 A65 A66
> A67 A68; A71 A72 A73 A74 A75 A76 A77 A78; A81 A82 A83 A84 A85
> A86 A87 A88 ])

When you remove the line "syms x" above, remove the VPA here as well.

> %solve(det(A), 'E')
> im=imag(det(A))
> re=real(det(A));
> f=sqrt(im.^2+re.^2);
>
> please tell me there is a effective algothim to solve this...

Now you can use FZERO on this. See the help for FZERO for a description of
its syntax. If you need further help, please explain specifically what's
going wrong in the newsgroup (please do NOT email me directly.)

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: find rhe root a complcated equation

From: george veropoulos

Date: 18 Nov, 2010 16:55:25

Message: 3 of 3

"Steven_Lord" <slord@mathworks.com> wrote in message <ic0rc2$5sd$1@fred.mathworks.com>...
>
>
> "george veropoulos" <veropgr@yahoo.gr> wrote in message
> news:ic063g$pat$1@fred.mathworks.com...
> > Dear friends. I m trying to solve a complicated equation with the
> > matlab (find the roots).
> > I construct a functio of this equation....
> > function f=energy(x)
> > syms x;
>
> You just overwrote your input with the symbolic variable x. Don't. Get rid
> of this SYMS call.
>
> > digits(3);
>
> Remove this line too.
>
> > global V0;
> > evjoule=1.602*10.^(-19);
> >
> > % length in m D=3*10.^(-9);
> > L=40*10.^(-9);
> > L1=9*10.^(-9);
> > V0=0.858*evjoule;
> > %V0 is 60% of energy gap
> > %GaAs in region 1 3 5
> > %InAs in region 2 and 4
> > m_0=9.109*10.^(-34);%free electron mass m1_star=0.067.*m_0;
> > m2_star=0.027.*m_0;
> > m3_star=0.067.*m_0;
> > m4_star=0.027.*m_0;
> > m5_star=0.067.*m_0;
> > h_bar=6.626*10.^(-34);% in J sec
> > k_1=(2.*m1_star./h_bar.^2).^0.5.*(x-V0).^0.5;
> > k_2=(2.*m2_star./h_bar.^2).^0.5.*x.^0.5;
> > k_3=(2.*m3_star./h_bar.^2).^0.5.*(x-V0).^0.5;
> > k_4=(2.*m4_star./h_bar.^2).^0.5*x.^0.5;
> > k_5=(2.*m5_star./h_bar.^2)^0.5*(x-V0).^0.5;
> > A11=-exp(i.*k_2.*(D+L));
> > A12=0;
> > A13=0;
> > A14=0;
> > A15=exp(-i.*k_1.*(D+L));
> > A16=exp(i.*k_2.*(D+L));
> > A17=0;
> > A18=0;
> > A21=(i.*k_2./m2_star).*exp(i.*k_2.*(D+L));
> > A22=0;
> > A23=0;
> > A24=0;
> > A25=(i.*k_1./m1_star)*exp(-i.*k_1.*(D+L));
> > A26=(-i.*k_2./m2_star)*exp(-i.*k_2.*(D+L));
> > A27=0;
> > A28=0;
> > A31=exp(i.*D.*k_2);
> > A32=-exp(-i.*k_4.*D);
> > A33=0;
> > A34=0;
> > A35=0;
> > A36=exp(-i.*k_2.*D);
> > A37=-exp(-i.*k_3.*D);
> > A38=0;
> > A41=(i.*k_2./m2_star).*exp(i.*k_2.*D);
> > A42=(i.*k_3./m3_star).*exp(i.*k_3.*D);
> > A43=0;
> > A44=0;
> > A45=0;
> > A46=-(i.*k_2./m2_star).*exp(-i.*k_2.*D);
> > A47=(i.*k_3./m3_star)*exp(-i.*k_3.*D);
> > A48=0;
> > A51=0;
> > A52=exp(-i.*k_3.*D);
> > A53=-exp(-i.*k_4.*D);
> > A54=0;
> > A55=0;
> > A56=0;
> > A57=exp(i.*k_3.*D);
> > A58=-exp(i.*k_4.*D);
> > A61=0;
> > A62=(i.*k_3./m3_star)*exp(-i.*k_3.*D);
> > A63=-(i.*k_4./m4_star)*exp(-i.*k_4.*D);
> > A64=0;
> > A65=0;
> > A66=0;
> > A67=-(i.*k_3./m3_star)*exp(i.*k_3.*D);
> > A68=-(i.*k_4./m4_star)*exp(i.*k_4.*D);
> > A71=0;
> > A72=0;
> > A73=exp(-i.*k_4.*(D+L1));
> > A74=exp(-i.*k_5.*(D+L));
> > A75=0;
> > A76=0;
> > A77=0;
> > A78=exp(i.*k_4.*(D+L1));
> > A81=0;
> > A82=0;
> > A83=(i.*k_4./m4_star).*exp(-i.*k_4.*(D+L1));
> > A84=-(i.*k_5./m5_star).*exp(-i.*k_5.*(D+L1));
> > A85=0;
> > A86=0;
> > A87=0;
> > A88=-(i.*k_4./m4_star).*exp(D+L1);
> > A=vpa([A11 A12 A13 A14 A15 A16 A17 A18 ;A21 A22 A23 A24 A25
> > A26 A27 A28 ;A31 A32 A33 A34 A35 A36 A37 A38 ;A41 A42 A43 A44
> > A45 A46 A47 A48;..../
> > A51 A52 A53 A54 A55 A56 A57 A58 ;A61 A62 A63 A64 A65 A66
> > A67 A68; A71 A72 A73 A74 A75 A76 A77 A78; A81 A82 A83 A84 A85
> > A86 A87 A88 ])
>
> When you remove the line "syms x" above, remove the VPA here as well.
>
> > %solve(det(A), 'E')
> > im=imag(det(A))
> > re=real(det(A));
> > f=sqrt(im.^2+re.^2);
> >
> > please tell me there is a effective algothim to solve this...
>
> Now you can use FZERO on this. See the help for FZERO for a description of
> its syntax. If you need further help, please explain specifically what's
> going wrong in the newsgroup (please do NOT email me directly.)
>
> --
> Steve Lord
> slord@mathworks.com
> To contact Technical Support use the Contact Us link on
> http://www.mathworks.com
Hi Dear Steve
thank very much!!
the code is running !
i have an other question there a other statement for det?

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us