Math 112 Honors: MATLAB Assignment 2

TAYLOR SERIES AND POLYNOMIALS Due Date: April 18, 2011

The sample program below calculates 2nd and 4th degree Taylor polynomials for the function

$$f(x)=1/(1+x^2)$$

about the point

$$a=0.$$

The polynomials are plotted, together with the function, over the interval

$$[-1,1]$$

Contents

Sample program

Lines beginning with a percent sign (%) are comments construct Taylor polynomials.

figure(1);clf; %open figure one and clear any plots
x=[-1: .01:1];
y=(1+x.^2).^(-1);  %the function
P2=1-x.^2;         %the second-order Taylor polynomial (calculated by hand)
P4=1-x.^2+x.^4;    %the 4th order Taylor polynomial
% annotating the graph is always important
figure(1);clf; %open and clear the 1st figure
plot(x,y,x,P2,'--',x,P4,'-.')
legend('1/(1+x^2)','P_2','P_4')
xlabel('x')
title('The function and the 2^{nd} and 4^{th} order Taylor Polynomials')
figure(2);clf; %open and clear the 2nd figure
plot(x,abs(y-P2),x,abs(y-P4),'--') % abs is the absolute value
legend('|1/(1+x^2)-P_2|','|1/(1+x^2)-P_4|')
xlabel('x')
title('Errors in the two Taylor Polynomials')
% Program output:

New Matlab Idea

the Legend command generates a legend for your graph. If there are two curves in your graph, the legend command should consist of two strings (defined using single quotation marks). Note that the underscore ('_') is used to make subscripts and the caret ('^') is used to make superscripts. if you want to create a superscript with more than one character in it, enclose the superscripted text in braces ('{}')

For example, to type

$$e^{i x}$$

you would use the string 'e^{ix}'.

Variables used

Your assignment: Radiation from the Stars

A $blackbody$ is a system that absorbs all the radiation that falls on it. Proposed in the late 19th century, the Rayleigh-Jeans Law expresses the energy density of blackbody radiation of wavelength $\lambda$ as:

$$f(\lambda)=\frac{8\pi k T}{\lambda^4}$$

where $\lambda$ is measured in meters, $T$, temperature, in kelvins, and $k$ is the Boltzmann's constant. The Rayleigh-Jeans Law agrees with experiments for long wavelengths but disagrees drastically for short wavelengths. [The experiments show that $f(\lambda)\rightarrow 0$ as $\lambda \rightarrow 0^+$]. The Planck's Law (found by Max Planck in 1900) models the blackbody radiation better:

$$f(\lambda) = \frac{8\pi h c \lambda^{-5}}{e^{hc/(\lambda k T)} - 1}$$

where $\lambda$ is measured in meters, $T$ is the temperature measured in kelvins, $h =6.6262\times 10^{-34}$ J s is Planck's constant, $c=2.997925 \times 10^8$ m/s is the speed of light, and $k=1.3807 \times 10^{-23}$ J/K is the Boltzmann's constant.

I) Show that the Planck's Law models blackbody radiation better for short wavelengths.

II) Use a Taylor polynomial to show that Planck's Law gives approximately the same values as the Rayleigh-Jeans Law for long wavelengths. [Hint: expand the denominator of Planck's Law using Taylor series of $e^x$.]

III) Plot the Planck's Law using 2nd and 3rd degree Taylor polynomials when approximating the denominator along with the Planck's Law for $0<\lambda<4$ $\mu$m. Use $T=6000$ K (the temperature of the sun).

IV) Plot both laws on a same graph and comment on the similarities and differences. Use $T=6000$ K.

BONUS QUESTION: Read the Matlab help files on how to use the Symbolic Math Toolbox. This is a part of the program that can actually manipuate algebra and calculus expressions. Use the command taylor, to compute the first five terms in the Taylor series and repeat part (III).