Fminsearch: Multiple non-linear equations with four variables
4 views (last 30 days)
Show older comments
I have a question about how to use fminsearch to solve multiple non-linear equations with four unknown variables. In the equations, nu = 1,2; mu =1,2; delta_nu and A_mu are four variables to be figured out. Other parameters are known. I have written MATLAB codes to find delta_mu through searching the minimum values of (delta_1)^2 + (delta_2)^2, given some initial values of delta_1 and delta_2. But I'm not sure whether the outputs are reliable. Is there any other way to evaluate multiple functions? I know that only one function is easy, but for multiple functions, I don't know whether it is better evaluate two functions at the same time, and then get the average values of X(unknown variables). Thank you for anyone interesting in this question.

clear all;
% Input delta BCS theory superconducting gap
delta0=1;
BCS_Delta = 1.74 * delta0 .* (1 - T/Tc).^(0.5);
Input_delta_1 = 1.74 * delta0 .* (1 - T/Tc).^(1/2)./(2 * pi * T)/1.1;
Input_delta_2 = 1.74 * delta0 .* (1 - T/Tc).^(1/2)./(2 * pi * T)/2.1;
% % fminsearch
for n = 1:length(T)
delta =[Input_delta_1(n),Input_delta_2(n)];
[delta_one(:,n),fval_one]=fminsearch(@(delta)f1(delta,n1,lambda,LambdaTilde,T(n),Tc),delta,optimset('TolX',1e-1,'TolFun',1e-2));
end
delta_1 = delta_one(1,:);
delta_2 = delta_one(2,:);
% Compare delta
figure(1)
plot(T/Tc,delta_1,'o',T/Tc,delta_2,'o',T/Tc,Input_delta_1,'-',T/Tc,Input_delta_2,'-')
hold on
xlabel('T/T_c','FontSize',18)
ylabel('\delta(T)','FontSize',18)
legend('\delta_1(T)','\delta_2(T)','Input \delta_1(T)','Input \delta_2(T)')
set(gca, 'FontSize', 18)
set(get(gca,'XLabel'),'Fontsize',20)
set(get(gca,'YLabel'),'Fontsize',20)
%Input Delta
Input_Delta_10 = 2 * pi * T .* Input_delta_1;
Input_Delta_20 = 2 * pi * T .* Input_delta_2;
%superconducting gap
Delta_1 = 2 * pi * T .* delta_1;
Delta_2 = 2 * pi * T .* delta_2;
figure(2)
plot(T/Tc,Delta_1,'o',T/Tc,Delta_2,'o',T/Tc,Input_Delta_10,T/Tc,Input_Delta_20,T/Tc,BCS_Delta,'LineWidth',2)
hold on
xlabel('T/T_c','FontSize',18)
ylabel('\Delta(T)','FontSize',18)
legend('\Delta_1(T)','\Delta_2(T)','Input \Delta_1(T)','Input \Delta_2(T)','BCS \Delta(T)')
set(gca, 'FontSize', 18)
set(get(gca,'XLabel'),'Fontsize',20)
set(get(gca,'YLabel'),'Fontsize',20)
% % superfluid density
for i = 1:length(delta_1)
for n = 1:2000
rho_1(i,n) = (delta_1(i))^2 * ((delta_1(i))^2 + (n - 1/2)^2 )^(-1.5);
rho_2(i,n) = (delta_2(i))^2 * ((delta_2(i))^2 + (n - 1/2)^2 )^(-1.5);
end
rho1(i) = sum(rho_1(i,:));
rho2(i) = sum(rho_2(i,:));
end
rho = gamma * rho1 + (1-gamma) * rho2;
figure(3)
plot(T/Tc, rho1, T/Tc, rho2, T/Tc, rho,'LineWidth',2)
legend('\rho_1','\rho_2','\rho')
xlabel('T/T_c')
ylabel('\rho = \lambda^2(0)/ \lambda^2(T)')
set(gca, 'FontSize', 18)
set(get(gca,'XLabel'),'Fontsize',20)
set(get(gca,'YLabel'),'Fontsize',20)
%f1 function
function f = f1(delta,n1,lambda,LambdaTilde,T,Tc)
n2=1-n1;
lambda11 = lambda(1);
lambda12 = lambda(2);
lambda21 = lambda(3);
lambda22 = lambda(4);
delta_1 = delta(1);
delta_2 = delta(2);
for k=1:100
A11(k) = 1/(k-0.5) - 1/sqrt((delta_1)^2 + (k-0.5)^2);
A22(k) = 1/(k-0.5) - 1/sqrt((delta_2)^2 + (k-0.5)^2);
end
A1= sum(A11);
A2= sum(A22);
f = ( n1 * lambda11 * delta_1 * (1/LambdaTilde + log(Tc/T) - A1) + n2 * lambda12 * delta_2 * (1/LambdaTilde + log(Tc/T) - A2) - delta_1)^2 ...
+( n1 * lambda21 * delta_1 * (1/LambdaTilde + log(Tc/T) - A1) + n2 * lambda22 * delta_2 * (1/LambdaTilde + log(Tc/T) - A2) - delta_1)^2;
1 Comment
jgg
on 10 Jan 2016
Edited: jgg
on 10 Jan 2016
I'm not clear what you are trying to find. You say your variables are nu = 1,2; mu =1,2; delta_nu and A_mu; this doesn't make sense to me. Aren't \mu and \nu indices? And doesn't this imply that A_\mu is just a number you already know since \delta_\mu is not one of the variables you don't know?
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!