University of Florida/Egm6341/s10.Team2/HW1

From testwiki
Jump to navigation Jump to search

Problem 1

Problem Statement

Find limx0ex1x and plot graph of the function for x[0,1]

Solution

This limit cannot be performed directly since it yields 00 form. So, the L'Hôpitals Rule technique must be used:

L'Hôpitals Rule States:

limxcf(x)g(x)=limxcf(x)g(x)

as long as f and g are functions that are differentiable on an open interval (a,b) which contains c, except at c itself.

Applying this technique the following is found:

f(x)=ex1f(x)=ex

g(x)=xg(x)=1

limx0ex1x=limx0ex1=e0=1

Graph of x (on X-axis) versus ex1x (on Y-axis)

File:Egm6341.s10.Team2.hw1Problem1.jpg

MATLAB Code:

To generate the graph for x vs ex1x

for i=1:1000
x=((i-1)/1000);
y=(exp(x)-1)/x;
plot(x,y);
hold on;
end


Solution for problem 1: Guillermo Varela 19:41, 27 January 2010 (UTC) and Srikanth Madala 19:41, 27 January 2010 (UTC)

Proofread problem 1: Guillermo Varela 19:41, 27 January 2010 (UTC) and Srikanth Madala 19:41, 27 January 2010 (UTC)

Problem 2

Problem Statement

Pg. 2-3, Find Pn(x) and Rn+1(x) of ex

Solution

The Taylor's series expansion for any function f(x) can be expressed as follows:

f(x)=Pn(x)+Rn+1(x) where

Pn(x)=f(x0)+(xx0)1!f(x0)+.....+(xx0)nn!fn(x0)

Rn+1(x)=1n!x0x(xt)nfn+1(t)dt

If f(x) is considered to be ex, then by using the above expansion, Pn(x) becomes:

Pn(x)=ex0+(xx0)1!ex0+(xx0)22!ex0+.....+(xx0)nn!ex0

Let x0=0, then:

Pn(x)=e0+x1!e0+x22!e0+.....+xnn!e0=1+x1!+x22!+...........+xnn!

Similarly, Rn+1(x) becomes:

Rn+1(x)=1n!t=x0=0t=x(xt)netdt

Using Integral mean value theorem (IMVT):

Rn+1(x)=eξxn!0x(xt)ndt=eξxn!xn+1n+1=xn+1 eξxn+1!

where ξx lies in [0,x]


Solution for problem 2: Srikanth Madala 19:41, 27 January 2010 (UTC)

Proofread problem 2: Egm6341.s10.team2.patodon 04:21, 21 February 2010 (UTC)

Problem 3

Problem Statement

Pg. 3-3.

f(x)=sin(x)g(x)=sin(xπ2)=cos(x)

Plot f and g

 xϵ[0,π]

Find Infinity norm of

i)f(x)

ii)g(x)

iii)f(x)g(x)

Solution

The Infinity norm is defined as follows:

f(.)=max|f(x)|

Using this definition the following is identified:

i) sin(x)=1

ii) cos(x)=1

iii) sin(x)+cos(x)=1.4142

File:Problem3.jpg


Solution for problem 3: Guillermo Varela

Problem 4

Problem Statement

Pg 5-1.

Prove the Integral Mean Value Theorem (IMVT) p. 2-3 for w(.) non-negative. i.e  w0

Solution

We have the IMVT as

abf(x)w(x)dx=f(ξ)abw(x)dx

For a given function f(x) Let m be the minimum of the function and M be the maximum of the same function

Then we know that, mf(x)M

multiplying the inequality throughout by w(x)0 and integrating between [a,b] we get:

abm.w(x)dxabf(x).w(x)dxabM.w(x)dx

mabw(x)dxabf(x).w(x)dxMabw(x)dx

writing abw(x)=I, we get

mIabf(x)w(x)dxMI

It is seen that when w(x) = 0, the result is valid. Consider the case when w(x) > 0

dividing throughout by I

m1Iabf(x)w(x)dxM

From the Intermediate Value Theorem, we know that there exists ξ[a,b] such that

f(ξ)=1Iabf(x)w(x)dx

i.e

f(ξ)abw(x)dx=abf(x)w(x)dx

Hence Proved


Solution for problem 4: --Egm6341.s10.team2.niki 23:22, 20 February 2010 (UTC)

Proofread problem 4:

Problem 5

Problem Statement

Pg. 5-1. Use the integral mean value theorem (IMVT) to show eq. 5 P. 2-2 yields the equation 1 of pg. 2-3.

Solution

File:Egm6341.S10.Team2.Problem5.JPG


Solution for problem 5: Jiang Pengxiang

Proofread problem 5: Srikanth Madala 19:41, 27 January 2010 (UTC)

Problem 6

Problem Statement

Pg. 5-3. Repeat integration by parts to reveal

(xx0)22!f(2)(x0)+(xx0)33!f(3)(x0)

Plus the remainder.

Next, Assume eq. 4 and 5 of Pg. 2-2 are true, do integration by parts once more.

Solution

From Meeting 5 lecture notes:

f(x)=f(x0)+x0xf(1)(t)dt

Integration by parts yields:

f(x)=f(x0)+xx01!f(1)(x0)+x0x(xt)f(2)(t)dt

Performing integration by parts on the integral in the above result:

x0x(xt)f(2)(t)dt=x0xuv=[uv]x0xuv=[(txt22)(f(2))(t)]x0xx0x(txt22)(tf(3)(t))dt=(x22)(f(2)(x))(x0xx022)(f(2)(x0))x0x(txt22)(tf(3)(t))dt=(x22)(f(2)(x))+(x022)(f(2)(x0))(x0x)f(2)(x0)x0x(txt22)(tf(3)(t))dt=x0x(x22)(f(3)(t))dt+x0xf(2))(x0)


Solution for problem 6: Egm6341.s10.team2.patodon 04:15, 21 February 2010 (UTC)

Proofread problem 6: Guillermo Varela

Problem 7

Problem Statement

Pg. 6-1

 f(x)=sin(x)  xϵ[0,π]

Construct Taylor Series of f(.) around x0π4 for n=0,1,...,10 and plot for each n.

Solution

The Taylor's series expansion for any function f(x) can be expressed as follows:

f(x)=Pn(x)+Rn+1(x) where

Pn(x)=f(x0)+(xx0)1!f(x0)+.....+(xx0)nn!fn(x0)

Rn+1(x)=1n!x0x(xt)nfn+1(t)dt

If f(x) is considered to be sinx, n=10 and x0=π4, then by using the above expansion, Pn(x) and Rn+1(x) becomes:

P10(x)=sinπ4+[(xπ4)1!cosπ4][(xπ4)22!sinπ4][(xπ4)33!cosπ4]+[(xπ4)44!sinπ4]+.....+[(xπ4)1010!f10(π4)]

where f10(π4)=sin(π4) (Please see the below Matlab code for more elaborate expansion)

R11(x)=110!t=π4t=x(xt)10f11(t)dt

where f11(t)=cos(t) (Please see the below Matlab code for more elaborate expansion)

MATLAB Code:

To generate the equation for Pn(x)

p=0
for n = 0:10
syms x;
syms z;
f=sin(z);
g=diff(f,n);
z=(pi/4);
p=p+(((x-(pi/4))^n)/factorial(n))*g;
end

p=

sin(z)+(x-1/4*pi)*cos(z)-1/2*(x-1/4*pi)^2*sin(z)-1/6*(x-1/4*pi)^3*cos(z)+1/24*(x-1/4*pi)^4*sin(z)+1/120*(x-1/4*pi)^5*cos(z)-1/720*(x-1/4*pi)^6*sin(z)-1/5040*(x-1/4*pi)^7*cos(z)+1/40320*(x-1/4*pi)^8*sin(z)+1/362880*(x-1/4*pi)^9*cos(z)-1/3628800*(x-1/4*pi)^10*sin(z);


To generate the equation for Rn+1(x)

>> syms t
>> syms x
>> f=sin(x);
>> r= (1/factorial(10))*int(((x-t)^10)*diff(f,11),t,(pi/4),x);
>> r

r =

-1301357606610903/51946031311566097350656*cos(x)*(x^11-1/4194304*pi^11)+1301357606610903/4722366482869645213696*x*cos(x)*(x^10-1/1048576*pi^10)-6506788033054515/4722366482869645213696*x^2*cos(x)*(x^9-1/262144*pi^9)+19520364099163545/4722366482869645213696*x^3*cos(x)*(x^8-1/65536*pi^8)-19520364099163545/2361183241434822606848*x^4*cos(x)*(x^7-1/16384*pi^7)+27328509738828963/2361183241434822606848*x^5*cos(x)*(x^6-1/4096*pi^6)-27328509738828963/2361183241434822606848*x^6*cos(x)*(x^5-1/1024*pi^5)+19520364099163545/2361183241434822606848*x^7*cos(x)*(x^4-1/256*pi^4)-19520364099163545/4722366482869645213696*x^8*cos(x)*(x^3-1/64*pi^3)+6506788033054515/4722366482869645213696*x^9*cos(x)*(x^2-1/16*pi^2)-1301357606610903/4722366482869645213696*x^10*cos(x)*(x-1/4*pi)


To generate the graph for x vs y=f(x)=Pn(x)+Rn+1(x); where x[0,π]

z=pi/4;
for i= 1:1:1000
x = ((i-1)/1000)*pi;
p=sin(z)+(x-1/4*pi)*cos(z)-1/2*(x-1/4*pi)^2*sin(z)-1/6*(x-1/4*pi)^3*cos(z)+1/24*(x-1/4*pi)^4*sin(z)+1/120*(x-1/4*pi)^5*cos(z)-1/720*(x-1/4*pi)^6*sin(z)-1/5040*(x-1/4*pi)^7*cos(z)+1/40320*(x-1/4*pi)^8*sin(z)+1/362880*(x-1/4*pi)^9*cos(z)-1/3628800*(x-1/4*pi)^10*sin(z);
r=-1301357606610903/51946031311566097350656*cos(x)*(x^11-1/4194304*pi^11)+1301357606610903/4722366482869645213696*x*cos(x)*(x^10-1/1048576*pi^10)-6506788033054515/4722366482869645213696*x^2*cos(x)*(x^9-1/262144*pi^9)+19520364099163545/4722366482869645213696*x^3*cos(x)*(x^8-1/65536*pi^8)-19520364099163545/2361183241434822606848*x^4*cos(x)*(x^7-1/16384*pi^7)+27328509738828963/2361183241434822606848*x^5*cos(x)*(x^6-1/4096*pi^6)-27328509738828963/2361183241434822606848*x^6*cos(x)*(x^5-1/1024*pi^5)+19520364099163545/2361183241434822606848*x^7*cos(x)*(x^4-1/256*pi^4)-19520364099163545/4722366482869645213696*x^8*cos(x)*(x^3-1/64*pi^3)+6506788033054515/4722366482869645213696*x^9*cos(x)*(x^2-1/16*pi^2)-1301357606610903/4722366482869645213696*x^10*cos(x)*(x-1/4*pi)
y=p+r;
plot(x,y);
hold on;
end


Solution for problem 7: Srikanth Madala 19:41, 27 January 2010 (UTC)

Proofread problem 7: Egm6341.s10.team2.patodon 04:22, 21 February 2010 (UTC)

Problem 8

Problem Statement

Pg. 6-5

I=01expx1xdx

Use 3 methods to find In:

1) Taylor Series Expansion, Fn 2) Composite Trapezoidal Rule 3) Composite Simpson Rule

for n=2,4,8 ... until the error is of order 106

Solution 1

1)Taylor Series Expansion

The goal is to perform the following integration,

I=01expx1xdx

The problem with this is that it is an indefinite integral, which must be rewritten in another way in order to analyze it. The method discussed here will be Taylor Series Expansion or McClaurin Series Expansion. The function can be rewritten as follows:

The Taylor Series Expansion for expx

expx=j=0xjj!=1+j=1xjj!

expx1=1+j=1xjj!1=j=1xjj!

expx1x=j=1xj1j!=f(x)

Using this new definition for the function one can then integrate it directly as follows:

I=01j=1nxj1j!dx

Integrating this for a value of n=2 yields the following:

I=01j=1n=2xj1j!dx

I=01x01!+x12!dx=[x]01+[x24]01=1+14=1.25

For n=4:

I=01x01!+x12!+x23!+x34!dx=[x]01+[x24]01+[x318]01+[x496]01=1+14+118+196=1.3160

The percent difference between the actual value of the integral (1.3179022) and the estimated value is found by:

|estimateactualactual|×100%=|1.251.31790221.3179022|×100%=5.15%

The following are the results for other values of n until the error is reduced to the power of 106

Template:Center topTaylor SeriesTemplate:Center bottom
n Estimated Value Percent Difference
n=2 1.2500000 5.152294305
n=4 1.3159722222 0.146443171
n=8 1.3179018152 2.91949E-05
n=16 1.3179021515 3.68355E-06
n=32 1.3179021515 3.68355E-06

Matlab Code used to generate the values for the table:

    function I =taylor(n)
    i=1;
    Itot=0;
    It=0;
    while i<=n
       if i==1
          Itot=1;
       else
            It=1/(factorial(i)*i);
       end
    Itot=Itot+It;
    i=i+1;
    end
    I=Itot;

Solution 2

2)Composite Trapezoidal Rule The formula used to analyze the integral for a function using the composite trapezoidal rule is as follows:

abF(x)dx=(ba)f(x0)+2i=1n1f(xi)+f(xn)2n

It is also necessary to state the following, using L'Hopitals Rule

lim0expx1x=1

For n=2 the integration is approximated as follows:

01expx1xdx

x(1)=.5x(2)=1

I=(10)f(x0)+2f(x1)+f(x2)4=(1)1+(2×1.2974)+1.71834=1.328

The error is calculated by comparing it to the results obtained using the Taylor Series expansion, as follows:

Error=|TrapezoidalValueTaylorValue||TaylorValue|×100%=|1.3281.3179|1.3179×100%=.7664%

This table displays the results for similar values:

Template:Center topComposite Trapezoidal RuleTemplate:Center bottom
n Estimated Value Percent Difference
n=2 1.3282917278 0.788338301
n=4 1.3205046195 0.197466812
n=8 1.3185530869 0.049388101
n=16 1.3180649052 0.012345774
n=32 1.3179428411 0.003083775
n=64 1.3179123240 0.000768187
n=128 1.3179046946 0.000189284
n=256 1.3179027872 4.45585E-05
n=512 1.3179023104 8.37696E-06
n=1024 1.3179021912 6.68424E-07

Matlab Code used to generate the values for the estimates:

    function I=ctrapz(n)
    i=0;
    Itot=0;
    It=0;
    It2=0;
    h=0;
    while i<=n
       if i==0
          Itot1=1;
       else if i<n
            h=1/n;
            It(i)=2*valu(h*i);
           else
               It2=valu(1);
           end
       end
    Itot=Itot1+sum(It)+It2;
    i=i+1;
    end
    I=Itot/(2*n);
    function F= valu(x);
    F=(exp(x)-1)/x;

Solution 3

The Composite Simpson's Rule

The rule is defined as follows:

In=(ba)f(x0+4i=1,3,5..n1f(xi)+2j=2,4,6...n2f(xj)+f(xn)3n

Using this definition the following is found:

Template:Center topComposite Simpson's RuleTemplate:Center bottom
n Estimated Value Percent Error
n=2 1.318008666 0.00807842
n=4 1.317908917 0.00050965
n=8 1.317902576 2.85304E-05
n=16 1.317902178 1.66813E-06

The Following MATLAB code was used to generate the values:

    function I = simpb(a,b,w)
    q=1;
    i=a;
    n=0;
    Sum=0;
    c=0;
    while n<w
        n=2^q;
        h=(a+b)/n;
    while i<=b
        fx=(exp(i)-1)/(i);
        if i==a
            Sum=1;
        else if i==b
                Sum=Sum+fx;
            else if i==(b-h)
                    Sum=Sum+(4*fx);
                else if rem(c,2)==0
                        Sum=Sum+(2*fx);
                    else
                        Sum=Sum+(4*fx);
                    end
                end
            end
        end
        c=c+1;
        i=i+h;
    end
    n
    In=Sum*(h/3);
    I=In;
    i=a;
    c=0;
    q=q+1;
    Sum=0;
    end

By Comparing all of the methods one is able to conclude that the most efficient method to numerically integrate was the composite Simpson's rule.


Solution for problem 8: Guillermo Varela

Problem 9

Problem Statement

Pg. 7-1

[𝐞𝐱𝟏]x=1x[ex1]=f(x)

1) Expand expx in Taylor Series w/ remainder:

R(x)=(x0)n+1(n+1)!exp[ζ(x)]

2) Find Taylor Series Expansion and Remainder of f(x). eq. 4 of p 6-3.

Solution

Given:

Pn(x)=f(x0)+(xx0)1!f(1)(x0)+...+(xx0)nn!f(n)(x0)

[equation 4 p 2-2]

R(x)=(x0)n+1(n+1)!exp[ζ(x)]

[equation 1 p 2-3]

Part 1

Pn(x)=ex0+(xx0)1!ex0+...+(xx0)nn!ex0

for the case that x0=0, we get,

Pn(x)=1+(x)1!+...+(x)nn!

Pn(x) =j=0xjj!

Using equation 1 p 2-3, we get the remainder as

Rn+1(x)=(xx0)n+1(n+1)!f(n+1)(ζ(x))

for x0=0, we get

Rn+1(x)=(x)n+1(n+1)!f(n+1)(ζ(x))

finally, f(x)=ex=j=0xjj!+(x)n+1(n+1)!f(n+1)(ζ(x))=j=0xjj!+(x)n+1(n+1)!e(ζ(x))

Part 2

f(x)=1x[ex1]

ex=j=0xjj!=1+x1!+x22!+...+xnn!

[ex1]=x1!+x22!+...+xnn!

dividing both sides by x we get,

[ex1]x=f(x)=j=1xj1j!

and remainder becomes

Rn+1(x)=(x)n(n+1)!f(n+1)(ζ(x))

since x0=0, we have

Rn+1(x)=(x)n(n+1)!f(n+1)(ζ(x) where ζ(x))ϵ[0,x]

Finally,

f(x)=[ex1]x=j=1xj1j!+(x)n(n+1)!f(n+1)(ζ(x))=j=1xj1j!+(x)n(n+1)!e(ζ(x))


Solution for problem 9: Egm6341.s10.team2.niki 23:23, 20 February 2010 (UTC)

Proofread problem 9:

Problem 10

Problem Statement

P. 8-2.

Use eq. 2 of pg. 8-2 to obtain eq. 1 of Pg. 7-1.

Solution

File:Egm6341.s10.Team2.Problem10Hw1.JPG


Solution for problem 10: Jiang Pengxiang

Proofread problem 10: Srikanth Madala 19:41, 27 January 2010 (UTC)

Problem 11

Problem Statement

P. 8-3

show eq. 4 is equal to eq. 2 by expanding eq. 4.

Solution

Equation 2:

p2(xj)=f(xj)

Equation 4:

p2(xj)=i=02ϑi(xj)f(xi)Forj=0,1,2

Performing summation:

p2(xj)=i=02ϑi(xj)f(xi)=ϑ0(xj)f(x0)+ϑ1(xj)f(x1)+ϑ2(xj)f(x2)

Definition of Kronecker delta Meeting 8 Notes :

ϑi(xj)=δij={1i=j0ij

Therefore,

ϑi(xj)f(xi)=0Forij

ϑi(xj)f(xi)=f(xi=j)Fori=j

For j=0,1,or2, two of the three terms resulting from the summation over index-j are negated. Since two of the terms will have i where ij and therefore ϑi(xj) equal to 0 for those two terms and ϑi(xj) equal to 1 for the remaining one term where i=j.

Thus,

p2(xj)=f(xj)


Solution for problem 11:
Egm6341.s10.team2.patodon 04:16, 21 February 2010 (UTC)

Proofread problem 11:

Contributing Authors

--Niki Nachappa Chenanda Ganapathy 16:20, 27 January 2010 (UTC)

--Guillermo Varela 19:23, 27 January 2010 (UTC)

--Srikanth Madala 19:41, 27 January 2010 (UTC)

--Patrick O'Donoughue 20:12, 27 January 2010 (UTC)

--Jiang Pengxiang 21:13, 27 January 2010 (UTC)<br/

Template:Center topProblem AssignmentsTemplate:Center bottom
Problem Solution Proofread
Problem 1 SM GV
Problem 2 SM PO
Problem 3 GV NN
Problem 4 NN JP
Problem 5 JP SM
Problem 6 P0 GV
Problem 7 SM PO
Problem 8 GV NN
Problem 9 NN JP
Problem 10 JP SM
Problem 11 PO GV