calculate tension by raphson newton in matlab

2 visualizaciones (últimos 30 días)
RMK1291
RMK1291 el 4 de Jul. de 2020
Comentada: RMK1291 el 5 de Jul. de 2020
hello every body I have code to calculate tension with inputs
cross-section = 2.432
Modulus of Elasticity=770000
co=0.0000189
t=10
s=15000
w=0.85
and the intial approximation=1000
with this valus I should have tention =1263
but the value I get it so small
clc;
close all;
clear all ;
syms x ;
A=input('Enter cross section Area : ');
co=input('Enter coeffi of expantion : ');
E=input('Enter Moduluse of Elasticity : ');
W=input('Enter weight of one meter : ');
s=input('Enter rulling span: ');
t=input('Enter t : ');
f=@(x)x^3- x^2*((A*E)*(co*t+(W^2*s^2/24*3819^2))-3819)-(W^2*s^2*A*E/24); %Enter the Function here
g=diff(f(x)); %The Derivative of the Function
n=input('Enter the number of decimal places:');
epsilon = 5*10^-(n+1);
x0 = input('Enter the intial approximation:');
for i=1:100
f0=vpa(subs(f(x),x,x0)); %Calculating the value of function at x0
f0_der=vpa(subs(g,x,x0)); %Calculating the value of function derivative at x0
y=x0-f0/f0_der; % The Formula
err=abs(y-x0);
if err<epsilon %checking the amount of error at each iteration
break
end
x0=y;
end
fprintf('The Root is : %f \n',y);
fprintf('No. of Iterations : %d\n',i);
  1 comentario
Alan Stevens
Alan Stevens el 5 de Jul. de 2020
Editada: Alan Stevens el 5 de Jul. de 2020
You haven't got either your function or your data quite right. As it stands your cubic function, f(x), has a single real root at x = 1.85*10^20 (You can find this using Matlab's roots function)
Are you sure all the units of all your variables are consistent?.

Iniciar sesión para comentar.

Respuestas (1)

John D'Errico
John D'Errico el 5 de Jul. de 2020
Editada: John D'Errico el 5 de Jul. de 2020
You have indicated these coefficients, although I worry there may be issues, because of the use of lower versus upper case W, etc.
But this is a CUBIC polynomial. I would use roots or solve, but really, I fear the problem is you have a mistake somewhere in the parameters. Using a Newton method to solve for the roots of a cubic polynomial may be the wrong idea (unless it is indicated as part of your homework assignment), because there is not even any assurance you will find the correct root. When a tool is a available to give you all the roots, then I would use it.
But first, let us look at the polynomial and its coefficients. I'll do this all symbolically and numerically, to learn what is happening.
A = 2.432;
E = 770000;
co = 0.0000189;
t = 10;
s = 15000;
W = 0.85;
syms x
P = x^3- x^2*((A*E)*(co*t+(W^2*s^2/24*3819^2))-3819)-(W^2*s^2*A*E/24)
P =
x^3 - 184996171323809955840*x^2 - 6494315519999999/512
The coefficients are clearly a bit strange.
When I use roots on these coefficients, I see:
roots([1,-184996171323809955840,0,-6494315519999999/512])
ans =
1.85e+20
0
0
So roots tells me there is a root out at 1.85e20, but also a double root near zero. If I use solve to tell me the complete story, now I understand what happened to your Newton solve.
vpa(solve(P),25)
ans =
- 1.853138791764258719098609e-28 - 0.0002618486514794448919516663i
- 1.853138791764258719098609e-28 + 0.0002618486514794448919516663i
184996171323809955840.0
So there is a complex conjugate pair of roots near x==0. But the polynomial has such extreme coefficients that roots becomes confused, and the Newton method also gets lost.
There is not any root around 1000. NOT EVEN CLOSE. So Newton's method essentially found a root at/near zero. The problem is not in your Newton's method code, but in the polynomial coefficients themselves.
As such, if you think there should be a root near 1000, then you have either the wrong polynomial, or the wrong set of parameters - probably the wrong units on some parameter.
I have no idea what is the material involved here. But I will hazard a guess the problem lies in your units. Since we are not even told what this problem is intended to model, I will not try to guess which of your parameters are in error. I suppose I could do a units investigation of that formula, to decide if it makes sense. (Actually, I did try to make some sense of that you have written, but it is a bit confusing.) Even for that, I would need to know what some of the parameters are intended to mean. Is "rulling span" intended to denote a length? What is the material involved?
  1 comentario
RMK1291
RMK1291 el 5 de Jul. de 2020
Thank you so much to your attention sir
I have attached picture of steps I have made it in the equation with this first code I made it before above
and the inputs and the value of tention is from certified company
clc;
close all;
clear all ;
syms x ;
A=input('Enter cross section Area : ');
H0=4.5* A ;
co=input('Enter coeffi of expantion : ');
E=input('Enter Moduluse of Elasticity : ');
W=input('Enter weight of one meter : ');
s=input('Enter rulling span: ');
t0=input('Enter t0 : ');
t=input('Enter t : ');
f=@(x)x^3-(x^2)*((-H0+(co*A*E)*(t-t0))+(W^2*s^2*A*E/24*H0^2))-(W^2*s^2*A*E/24); %Enter the Function here
g=diff(f(x)); %The Derivative of the Function
n=input('Enter the number of decimal places:');
epsilon = 5*10^-(n+1);
x0 = input('Enter the intial approximation:');
for i=1:100
f0=vpa(subs(f(x),x,x0)); %Calculating the value of function at x0
f0_der=vpa(subs(g,x,x0)); %Calculating the value of function derivative at x0
y=x0-f0/f0_der; % The Formula
err=abs(y-x0);
if err<epsilon %checking the amount of error at each iteration
break
end
x0=y;
end
fprintf('The Root is : %f \n',y);
fprintf('No. of Iterations : %d\n',i);

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by