clear all
close all
ni = 3e10;                                                          % the definition of ni
na = logspace( 6, 14 , 500);                         % creating the logoritmic array of Na using function
p= 0.5 * ( na +  sqrt(  na.^2  + 4*(ni^2)));  % calculating p (majority carriers)  into p array
n= (ni^2)./p;                                                      % calculating  n (minority carriers) into n array
figure;
loglog(na,p,'b');                                           % plotting p - na (logoritmic)
hold on;                                                           % duh
loglog(na,na, 'k');                                        % plotting na - na (logoritmic) as refrence line for the approximation p=Na
hold on;                                                           % duh
loglog(na,ni, 'k');                                        % plotting na - ni (logoritmic) as refrence line for the approximation n=p=ni
hold on;                                                           % duh
loglog(na, n , 'r');                                        % plotting n - na (logoritmic)