HW3 - >%HW3 >%Gen Li >%2.4.4 >%a >%i > format short g >...

Info icon This preview shows pages 1–7. Sign up to view the full content.

>> %HW3 >> %Gen Li >> %2.4.4 >> %a >> %i >> format short g >> x=10^(-8) x = 1e-08 >> g=(sqrt(1+x^2)-1)/(x^2) g = 0 >> %The result is not zero but so close to zero. MATLAB cannot display that number. >> %ii >> %The function is 1/(sqrt(1+x^2)+1) >> %b >> h=x*(sqrt(1+x^2)-x) >> %i >> x=10^100; >> h=x*(sqrt(1+x^2)-x) h = 0 >> %ii >> x=realmax; >> h=x*(sqrt(1+x^2)-x) h = Inf >> %iii >> x=10^100000 x = Inf >> h=x*(sqrt(1+x^2)-x) h =
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

NaN >> %iv >> %The function is x/(sqrt(1+x^2)+x) >> %2.4.9 >> f1=sqrt(x)*(sqrt(x+1)-sqrt(x)); >> f2=exp(3*x/2)*(sqrt(cosh(x)-sqrt(sinh(x)))); >> f3=x*(log(x+1)-log(x)); >> x=10; >> disp([f1 f2 f3]) 1.0e+08 * 0.0000 3.4143 0.0000 >> x=100000; >> disp([f1 f2 f3]) 0.5000 NaN 1.0000 >> x=10^1000000; >> disp([f1 f2 f3]) NaN NaN NaN >> x=1.00000000000000001; >> disp([f1 f2 f3]) 0.4142 3.0364 0.6931 >> x=inf >> disp([f1 f2 f3]) NaN NaN NaN >> %2.5.4 >> %a >> s=num2str(pi) s = 3.1416 >> class(s) ans = char >> %b >> s=num2str(pi,3) s = 3.14 >> s=num2str(pi,5)
Image of page 2
s = 3.1416 >> s=num2str(pi,10) s = 3.141592654 >> %c >> s=num2str(4/3,1) s = 1 >> s=num2str(4/3,5) s = 1.3333 >> s=num2str(4/3,10) s = 1.333333333 >> %2.6.2 >> %a >> x=pi^3/2 x = 15.5031 >> %no,pi^(3/2) >> %b >> y=e^3 Undefined function or variable 'e'. >> %no,exp(3) >> %c >> x=ln(7) Undefined function 'ln' for input arguments of type 'double'. >> %no,log(7) >> %d >> y=tan(30) y = -6.4053
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

>> %no,tand(30) >> %e >> y=tan 30 y=tan 30 | Error: Unexpected MATLAB expression. >> y=tan30 >> %no,tan(30) >> %f >> x=1 x = 1 >> y=sin(2)*x y = 0.9093 >> %no,sin(2*x) >> %g >> y=sin^2(x) y=sin^2(x) | Error: Unbalanced or unexpected parenthesis or bracket.
Image of page 4
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

Image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.
  • Spring '15
  • Ozg
  • matlab, Expression, Equals sign, NaN NaN NaN

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern