How to set up the bisection method with variable unknowns?

2 views (last 30 days)
Hi, all
I have a question about iteration with variable unknowns.
I've gotten a matrix of Xi = [ 0.2 3 4 7 9 10 2 3 4 3.4] (example) ( known matrix)
I would like to determine a matrix of Xi+1 which is unknown.
By using bisection method, I have known the torlence = 1e-3 which is equal to sqrt( symsum(Xi-Xi+1)^2) / sqrt( symsum(Xi+1)^2).
  2 Comments
Samatha Aleti
Samatha Aleti on 29 Jan 2020
Hi,
Bisection method is used to find the roots of polynomial equations. Can I know the polynomial that you are trying to solve? What is Xi here?
Wai Keung lin
Wai Keung lin on 2 Feb 2020
Thx you for your attendtion, Samatha.
Sorry to lately reply.
Here the code I have constructed. Generally, the iteration function works.
But I have two more question,
  1. Can it be simply?
  2. Actually, I would like to set the tolerence which is equal to sqrt( [T(iter+1)-T(iter)].^2/T(iter).^2). But I know the code cannot recall the previous records with using while loop. I'm kind of struggling it. ^0^
tolerance=1.0e-3;
maxiter=50;
iter=0;
T_idesirable = 0.03;
T_bdesirable =0.03;
ci_inner=zeros(maxiter,1);
ci_inner(1)=max(cofd(Innerelem));
ci_boundary=zeros(maxiter,1);
ci_boundary(1)=max(cofd(Boundaryelem));
%..............
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
while abs(deltaTi_Total)/Ti_Total>tolerance && iter<maxiter
iter=iter+1;
ci_inner(iter)=ci_inner(iter-1)*T_idesirable/min(Ti(Innerelem));
ci_boundary(iter)=ci_boundary(iter-1)*T_bdesirable/min(Ti(Boundaryelem));
cofdi=ones(nelem,1)
for ielem=1:nelem
cofdi(Innerelem)=ci_inner(iter)*elemmatrix(Innerelem)
cofdi(Boundaryelem)=ci_boundary(iter)*elemmatrix(Boundaryelem)
end
Ki = zeros(npoin*3,npoin*3);
for ielem = 1:nelem
%...compute element stiffness
ki =cofdi(ielem)*[ 1 0 0 -1 0 0;...
0 1 0 0 -1 0;...
0 0 1 0 0 -1;...
-1 0 0 1 0 0;...
0 -1 0 0 1 0;...
0 0 -1 0 0 1];
ki
%...add element contribution to global stiffness
gpos = eldofs(ielem,:);
Ki(gpos,gpos) = Ki(gpos,gpos) + ki;
end
%%%................................................
%%%.........
ellengthi = sqrt( (xi2-xi1).^2+(yi2-yi1).^2+(zi2-zi1).^2 );
for ielem=1:nelem
if ellengthi(ielem) < 0
error('Error in Length')
end
end
Ti=zeros(nelem,1);
for ielem=1:nelem
Ti(ielem) = ellengthi(ielem) * cofdi(ielem);
end
Ti_subTotal = zeros(nelem,1);
for ielem=1:nelem
Ti_subTotal(Innerelem)=elemmatrix(Innerelem).*T_idesirable.^2;
Ti_subTotal(Boundaryelem)=elemmatrix(Boundaryelem).*T_bdesirable.^2;
end
Ti_Total = sqrt( sum(Ti_subTotal,1) );
deltaT= zeros(nelem,1);
for ielem=1:nelem
deltaT(Innerelem) = (Ti(Innerelem)-T_idesirable).^2;
deltaT(Boundaryelem) = (Ti(Boundaryelem)-T_bdesirable).^2;
end
deltaTi_Total = sqrt( sum(deltaT,1));
residual_vec=zeros(maxiter,1);
residual_vec(iter)=deltaTi_Total/Ti_Total;

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!