# relative error graph

• Apr 24th 2010, 11:31 AM
emforny
relative error graph
can u pls solve this? i tried all what i know.

the elationship between the resistance R of the thermistor and the temperature is given by
(1/T)-1.129241*10^(-3)=2.341077*10^(-4)*log(R)+8.775468*10^(-8)*(log(R))^(3)

where T is in Kelvin and R is in ohms.
A thermistor error of no more than 0.01C is acceptable. To find the range of the
resistance that is within this acceptable limit at 19C , we need to solve
1/19.01+ 273.15=1.129241×10^(-3) + 2.341077×10^(−4)*ln(R) + 8.775468 × 10^(−8)* {ln(R)}^(3)
and
1/18.99 + 273.15= 1.129241× 10^(−3) + 2.341077 × 10^(−4) ln(R) + 8.775468 × 10^(−8) {ln(R)}^3
Use Newton’s method to find the resistance at 18.99C. Find the absolute relative
approximate error at the end of each iteration, and plot relative approximate error versus
iteration number.

clear all
clc
R=solve('(1/(18.99+273.15))-1.129241*10^(-3)=2.341077*10^(-4)*log(R)+8.775468*10^(-8)*(log(R))^(3)'); %gercek R degeri
Ri=3; tol=273.15+0.01; error=273.15+10;
k=1; a=1;

while error>=tol
f=1.129241*10^(-3)+2.341077*10^(-4)*log(Ri)+8.775468*10^(-8)*(log(Ri))^(3)-(1/(18.99+273.15));
df=((2.341077*10^(-4))/(Ri))+(8.775468*10^(-8)*3*(log(Ri))^2)/Ri;
Rnew=Ri-(f/df);
fnew=1.129241*10^(-3)+2.341077*10^(-4)*log(Rnew)+8.775468*10^(-8)*(log(Rnew))^(3)-(1/(18.99+273.15));
error=abs(fnew);
relativeerror=(error/R);
Ri=Rnew
k=k+1;
end
plot(k,relativeerror)

i wrote program this but i cant take the plot of all iteration what do u sugges??
• Apr 24th 2010, 10:26 PM
CaptainBlack
Quote:

Originally Posted by emforny
can u pls solve this? i tried all what i know.

the elationship between the resistance R of the thermistor and the temperature is given by
(1/T)-1.129241*10^(-3)=2.341077*10^(-4)*log(R)+8.775468*10^(-8)*(log(R))^(3)

where T is in Kelvin and R is in ohms.
A thermistor error of no more than 0.01C is acceptable. To find the range of the
resistance that is within this acceptable limit at 19C , we need to solve
1/19.01+ 273.15=1.129241×10^(-3) + 2.341077×10^(−4)*ln(R) + 8.775468 × 10^(−8)* {ln(R)}^(3)
and
1/18.99 + 273.15= 1.129241× 10^(−3) + 2.341077 × 10^(−4) ln(R) + 8.775468 × 10^(−8) {ln(R)}^3
Use Newton’s method to find the resistance at 18.99C. Find the absolute relative
approximate error at the end of each iteration, and plot relative approximate error versus
iteration number.

clear all
clc
R=solve('(1/(18.99+273.15))-1.129241*10^(-3)=2.341077*10^(-4)*log(R)+8.775468*10^(-8)*(log(R))^(3)'); %gercek R degeri
Ri=3; tol=273.15+0.01; error=273.15+10;
k=1; a=1;

while error>=tol
f=1.129241*10^(-3)+2.341077*10^(-4)*log(Ri)+8.775468*10^(-8)*(log(Ri))^(3)-(1/(18.99+273.15));
df=((2.341077*10^(-4))/(Ri))+(8.775468*10^(-8)*3*(log(Ri))^2)/Ri;
Rnew=Ri-(f/df);
fnew=1.129241*10^(-3)+2.341077*10^(-4)*log(Rnew)+8.775468*10^(-8)*(log(Rnew))^(3)-(1/(18.99+273.15));
error=abs(fnew);
relativeerror=(error/R);
Ri=Rnew
k=k+1;
end
plot(k,relativeerror)

i wrote program this but i cant take the plot of all iteration what do u sugges??

You would make a good start by simplifying your equations (by collecting all the constant terms for example)

CB
• Apr 25th 2010, 12:00 AM
emforny
Quote:

Originally Posted by CaptainBlack
You would make a good start by simplifying your equations (by collecting all the constant terms for example)

CB

clear all
clc
R=solve('0.0023=2.3411e-004*log(R)+8.7755e-008*(log(R))^(3)'); %gercek R degeri
Ri=3; tol=0.01; error=273.15+10;
k=1; a=1;

while error>=tol
f=0.0011+2.3411e-004*log(Ri)+8.7755e-008*(log(Ri))^(3)-0.0034;
df=(19891740993802833*log(Ri)^2)/(75557863725914323419136*Ri) + 4318567255096143/(18446744073709551616*Ri);
Rnew=Ri-(f/df);
fnew=1.129241*10^(-3)+2.341077*10^(-4)*log(Rnew)+8.775468*10^(-8)*(log(Rnew))^(3)-(1/(18.99+273.15));
error=abs(fnew);
relativeerror=(error/R);
Ri=Rnew
k=k+1;
plot(k,relativeerror)
end

like tihs??? i have to deliver this homework today i do all of these and i dont to take a lower grade i just cant make a plot the matlab
• Apr 25th 2010, 12:19 AM
CaptainBlack
It grates not to have you change this into decent code but try:

Code:

```clear all clc R=solve('0.0023=2.3411e-004*log(R)+8.7755e-008*(log(R))^(3)'); %gercek R degeri Ri=3; tol=0.01; error=273.15+10; k=1; a=1; RE=[]; while error>=tol     f=0.0011+2.3411e-004*log(Ri)+8.7755e-008*(log(Ri))^(3)-0.0034;     df=(19891740993802833*log(Ri)^2)/(75557863725914323419136*Ri)+ ...           4318567255096143/(18446744073709551616*Ri);     Rnew=Ri-(f/df);     fnew=1.129241*10^(-3)+2.341077*10^(-4)*log(Rnew)+ ---             8.775468*10^(-8)*(log(Rnew))^(3)-(1/(18.99+273.15));     error=abs(fnew);     relativeerror=(error/R);     RE=[RE,relative error];     Ri=Rnew     k=k+1;     %plot(k,relativeerror) end plot(RE)```
CB