Linear Approximation

Let's say want to computer the value of a function f ( x ) f(x) at x = 1 x = 1 but all we know about this function is this:

f ( x ) = f ( x ) f(x) = f'(x)

and

f ( 0 ) = 1 f(0) = 1

One way to do this to use linear approximation repeatedly with a defined step size (say h). The lesser will be the value of step, the better approximation we can have.

Let's take an example,

Let's use the step size of 0.5 0.5

Using, a step size of 0.5 0.5 or h = 0.5 h = 0.5 , we can first compute the value at f ( 0.5 ) f(0.5) and then at f(1) which we ultimately require.

Generally, linear approximation states:

f ( h ) f ( 0 ) + h . f ( 0 ) f(h) \approx f(0) + h.f'(0)

f ( 2 h ) f ( h ) + h . f ( h ) f(2h) \approx f(h) + h.f'(h)

f ( 3 h ) f ( 2 h ) + h . f ( 2 h ) f(3h) \approx f(2h) + h.f'(2h)

and this can go forever.

To approximate the value of f(1) using a step size of 0.5 0.5 that is for h = 0.5 h = 0.5 , we can do it like this:

First, we compute value of f f at 0.5 0.5 like this:

f ( 0.5 ) f ( 0 ) + 0.5 × f ( 0 ) = 1 + 0.5 × 1 = 1.5 f(0.5)\approx f(0) + 0.5 \times f'( 0) = 1 + 0.5 \times 1 = 1.5

Secondly, we can use the value of f f at 0.5 0.5 to computer f ( 1 ) f(1) like this:

f ( 1 ) f ( 0.5 ) + 0.5 × f ( 0.5 ) = 1.5 + 0.5 × 1.5 = 2.25 f(1) \approx f(0.5) + 0.5 \times f'(0.5) = 1.5 + 0.5 \times 1.5 = 2.25

Now, write a program to find the value of f ( 1 ) f(1) using a step size of 0.05 0.05 or h = 0.05 h = 0.05 with repeated linear approximations.

The approximation of f ( 1 ) f(1) using this program is:

2.673 2.663 2.663 2.653

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Michael Mendrin
Apr 3, 2014

f(20) is just (1+0.05)^20 = 2.6532977051444213..., no need to write a program. Indeed, as the step size -> 0, this value becomes e, since (1 + 1/n)^n = e for as n -> ∞

Of course, for other functions, it isn't as simple as this.

Tried to write a program in Java......but i am getting a really huge value as result.....what should be the correct programming logic for this?

Vaishnavi Gupta - 7 years, 2 months ago
Lokesh Sharma
Apr 1, 2014

Solution using Python:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def linearApprox(h):
    '''
    h: Step size for repeated linear approximation
        Returns: Approximated value of f(1) 
        '''
    res = 1

    for i in range(int(1/h)): # Runs the loop n number of times such that h*n = 1
        res = res + h*res

    return res

print linearApprox(0.05) 

Hahaha, Lokesh, I don't know the solution but the pic is really good... Cheers!!!

A Former Brilliant Member - 7 years, 2 months ago

Log in to reply

Yeah, I actually created the question just to show this picture. Cheers!!!

Lokesh Sharma - 7 years, 2 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...