# Newton's method - problems in calculating alpha value

2 views (last 30 days)
Aryo Aryanapour on 30 Dec 2021
Commented: Aryo Aryanapour on 5 Jan 2022
clear
clc
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
x0 = 280;
eps = 0.4;
c_s = 5.67*10^(-8);
s1 = 0.250;
s2 = 0.015;
lamda1 = 0.35;
lamda2 = 22.7;
Tw_1 = 1200;
T_l = 10;
Tw_1 = 1200+273.15;
T_l = 10+273.15;
lambda_L = 25.12;
betha = 3.543;
v = 144.0;
L = 7;
g = 9.81;
Pr = 0.7095;
func = @(x) eps * c_s * x^4 + (alpha_k + 1/(s1/lamda1+s2/lamda2)) * x - ((1/(s1/lamda1+s2/lamda2)) * Tw_1 + alpha_k * T_l);
diff = @(x) 4 * eps * c_s * x^3 + (alpha_k + 1/(s1/lamda1+s2/lamda2));
xsol = newton_raphson(func, diff, x0)
function xsol = newton_raphson(func, diff, x0)
%UNTITLED Summary of this function goes here
% Detailed explanation goes here
x(1) = x0;
maxiter = 200;
tol = 10^(-5);
lambda_L = 25.12;
betha = 3.543;
v = 144.0;
L = 7;
g = 9.81;
Pr = 0.7095;
T_l = 10;
for i = 1:maxiter
if diff(x(i)) < tol
fprintf('Pitfall hast occured a better initial guess\n');
return;
end
x(i+1) = x(i) - func(x(i))/diff(x(i));
abs_error(i+1) = abs((x(i+1)-x(i))/x(i+1))*100;
Gr = (g*L.^3*betha*(x(i+1)-T_l))/v;
Ra = Gr*Pr;
alpha_k = ((0.825+(0.387*Ra^1/6)/(1+(0.492/Pr)^9/16)^8/27)^2)*lambda_L/L;
if abs(x(i+1) - x(i)) < tol
fprintf('The Root has converged at x = %.10f\n', x(i+1));
else
fprintf('Iteration no: %d,current guess x = %.10f, error = %.5f', i, x(i+1), abs_error(i+1));
end
end
xsol = x(end);
alpha_k
end
In this code, alpha_k is no longer constant, but changes with temperature. I have to calculate Gr as a function of the temperature and then re-calculate alpha_k with Gr. At the end, the x value or xsol must be calculated using the alpha_k. Unfortunately the alpha_k cannot be calculated for me. Can you see why
Thanks so much
Jan on 30 Dec 2021
"the alpha_k cannot be calculated for me" - please explain with details, what the problem is.
You do get an error message, so please post it to make it as easy as possible to solve the problem.

Jan on 30 Dec 2021
In the lines:
func = @(x) eps * c_s * x^4 + (alpha_k + 1/(s1/lamda1+s2/lamda2)) * x - ...
((1/(s1/lamda1+s2/lamda2)) * Tw_1 + alpha_k * T_l);
diff = @(x) 4 * eps * c_s * x^3 + (alpha_k + 1/(s1/lamda1+s2/lamda2));
"alpha_k" is not defined. When the functions are executed the first time:
function xsol = newton_raphson(func, diff, x0)
...
if diff(x(i)) < tol
...
end
alpha_k is not defined also. This is exactly what the error message should tell you.
Aryo Aryanapour on 5 Jan 2022
Jan