Got Questions? Get Answers.
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:
Precision issues during semiconductor modeling

Subject: Precision issues during semiconductor modeling

From: Gideon Segev

Date: 16 Feb, 2011 19:27:04

Message: 1 of 5

Precision issues during semiconductor modeling
Hi,
I am writing a program that solves the semiconductor equations in one dimension.
The following code is a part of this program (the equations are taken from "Physics of Semiconductor Devices", Sze page 27):
clear all
close all
clc
 
% Dopant concentrations
Nd1=1e19;
Na1=0;
 
% Silicon intrinsic carrier concentration at 300K
nie=10818091652.6553;
% Equilibrium carrier concentration:
neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2+4*nie^2))/2;
peq1=nie^2/(neq1);
%Solution test:
t(1)=Na1+neq1-Nd1-peq1;
t(2)=-(peq1+Nd1-neq1-Na1);
t(3)=neq1-Nd1-peq1+Na1;
t(4)=-(peq1+Nd1-Na1-neq1);
display(t)

Which yields:
t =

  -11.7031 0 -11.7031 0

It can be easily shown that all entries in the variable t must be zero (even if the equations are wrong all the entries must have the exact same value). I assume that this is some kind of precision issue.
Does anyone have any ideas how to solve this issue?
I really need good precision in this calculation because the variable t will later be multiplied by very large numbers so small errors will have a dramatic effect on the solution. The solution should be compatible with bvp4c which will be used to solve the semiconductor differential equations.
Thanks a lot,
Gideon.

Subject: Precision issues during semiconductor modeling

From: Matt J

Date: 16 Feb, 2011 22:02:03

Message: 2 of 5

"Gideon Segev" wrote in message <ijh8e8$i0i$1@fred.mathworks.com>...
>
> % Equilibrium carrier concentration:
> neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2+4*nie^2))/2;
===============

Shouldn't this be

 neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2-4*nie^2))/2; %Note the sign of 4*nie^2



> I really need good precision in this calculation because the variable t will later be multiplied by very large numbers so small errors will have a dramatic effect on the solution.
==============

How much precision will you need? How large are the numbers to be multiplied with t?

Subject: Precision issues during semiconductor modeling

From: Gideon Segev

Date: 24 Mar, 2011 10:13:04

Message: 3 of 5

"Matt J" wrote in message <ijhhgr$em1$1@fred.mathworks.com>...
> "Gideon Segev" wrote in message <ijh8e8$i0i$1@fred.mathworks.com>...
> >
> > % Equilibrium carrier concentration:
> > neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2+4*nie^2))/2;
> ===============
>
> Shouldn't this be
>
> neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2-4*nie^2))/2; %Note the sign of 4*nie^2
>
>
>
> > I really need good precision in this calculation because the variable t will later be multiplied by very large numbers so small errors will have a dramatic effect on the solution.
> ==============
>
> How much precision will you need? How large are the numbers to be multiplied with t?

Thanks for the response.
The variable "t" from above can be multiplied by numbers in orders of up to 10^15.
Since in calculations such as this one I add numbers in order of 10^19 with numbers in the order of 10^2 (majority and minority carriers concentrations) I believe that 20 digits should be enough for the job.
I have tried using the symbolic toolbox (using functions like digits and vpa). This solves the problem to some extent but the computation time is quite impossible (two hours instead of seconds.
Thanks,
Gideon.

Subject: Precision issues during semiconductor modeling

From: John D'Errico

Date: 24 Mar, 2011 10:41:04

Message: 4 of 5

"Gideon Segev" wrote in message <imf5fg$9p9$1@fred.mathworks.com>...
> "Matt J" wrote in message <ijhhgr$em1$1@fred.mathworks.com>...
> > "Gideon Segev" wrote in message <ijh8e8$i0i$1@fred.mathworks.com>...
> > >
> > > % Equilibrium carrier concentration:
> > > neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2+4*nie^2))/2;
> > ===============
> >
> > Shouldn't this be
> >
> > neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2-4*nie^2))/2; %Note the sign of 4*nie^2
> >
> >
> >
> > > I really need good precision in this calculation because the variable t will later be multiplied by very large numbers so small errors will have a dramatic effect on the solution.
> > ==============
> >
> > How much precision will you need? How large are the numbers to be multiplied with t?
>
> Thanks for the response.
> The variable "t" from above can be multiplied by numbers in orders of up to 10^15.
> Since in calculations such as this one I add numbers in order of 10^19 with numbers in the order of 10^2 (majority and minority carriers concentrations) I believe that 20 digits should be enough for the job.
> I have tried using the symbolic toolbox (using functions like digits and vpa). This solves the problem to some extent but the computation time is quite impossible (two hours instead of seconds.
> Thanks,
> Gideon.

You don't have the choice of setting 20 digits of precision,
UNLESS you use the symbolic capabilities in MATLAB.

The resort of high precision is often the lazy way out. (This
said by someone who wrote the vpi toolbox, and now an
as yet unreleased long precision toolbox for floating point
arithmetic.) And since it is an option that fails to run in
sufficient time with vpa, it is a choice you don't really have.

Having said that, your problem must be far larger than
the example you have shown, as it takes only fractions
of a second to un in 120 digits of precision for me.
(This using my own toolbox.) Yes, there is a great deal
of subtractive cancellation, so the resultant vector t is
only zero for the first 100 digits.

John

Subject: Precision issues during semiconductor modeling

From: Roger Stafford

Date: 24 Mar, 2011 23:16:20

Message: 5 of 5

"Gideon Segev" wrote in message <ijh8e8$i0i$1@fred.mathworks.com>...
> Precision issues during semiconductor modeling
> Hi,
> I am writing a program that solves the semiconductor equations in one dimension.
> The following code is a part of this program (the equations are taken from "Physics of Semiconductor Devices", Sze page 27):
> clear all
> close all
> clc
>
> % Dopant concentrations
> Nd1=1e19;
> Na1=0;
>
> % Silicon intrinsic carrier concentration at 300K
> nie=10818091652.6553;
> % Equilibrium carrier concentration:
> neq1=(Nd1-Na1+sqrt((Na1-Nd1)^2+4*nie^2))/2;
> peq1=nie^2/(neq1);
> %Solution test:
> t(1)=Na1+neq1-Nd1-peq1;
> t(2)=-(peq1+Nd1-neq1-Na1);
> t(3)=neq1-Nd1-peq1+Na1;
> t(4)=-(peq1+Nd1-Na1-neq1);
> display(t)
>
> Which yields:
> t =
>
> -11.7031 0 -11.7031 0
>
> It can be easily shown that all entries in the variable t must be zero (even if the equations are wrong all the entries must have the exact same value). I assume that this is some kind of precision issue.
> Does anyone have any ideas how to solve this issue?
> I really need good precision in this calculation because the variable t will later be multiplied by very large numbers so small errors will have a dramatic effect on the solution. The solution should be compatible with bvp4c which will be used to solve the semiconductor differential equations.
> Thanks a lot,
> Gideon.
- - - - - - - - -
  As John has pointed out, having to use very high precision in a computation is often "the lazy way out". In your equations when you performed the subtraction "neq1-Nd1+Na1" in getting 't', that is placing a heavy burden on the computer when an equivalent sequence of operations would be far more accurate. As it stands it would be the very small difference between two extremely large quantities, a situation that is guaranteed to produce large relative round off errors, as you indeed found. The equivalent sequence, (as you are apparently aware,) is precisely the expression used to compute peq1, as can be shown by a common trick in algebra of "rationalizing the numerator", so you should never be attempting to do that kind of ugly subtraction when such an equivalent and more accurate method is available - not even as a test.

Roger Stafford

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