Linear Approximation 2

This is sequence to my previous problem .

Make sure you attempt it first to get familiar with the terms.

Approx the value of f ( 4 ) f(4) using step size of 0.2 0.2 , given you know the following regard a function f f -

f ( 2 ) = 4 f(2) = 4

and

f ( x ) = 2 × x 7 f'(x) = 2 \times x - 7

Round off your answer to 2 2 decimal digits.

For example, if your answer is 1.4567 1.4567 you should write it as 1.46 1.46 .

Good Luck!


The answer is 1.6.

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.

1 solution

Lokesh Sharma
Apr 1, 2014

Python Solution:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
def dervf(x):
    '''
    Returns derviative of f at x
    '''
    return 2*x - 7

def linearApprox_helper(a, fa, step):
    '''
    Given value of f at any point a,
    it approximates the value of f at a + step
    '''
    return fa + step * dervf(a)

def linearApprox(stop, step):
    '''
    Approx value of f(stop)
    given the value the step size as step
    '''
    a = 2 # start value = 2
    fa = 4 # equivalent to f(a) = 4
    while a < stop:
        fa = linearApprox_helper(a, fa, step)
        a += step
    return fa

print linearApprox(4, 0.2)

I also solved using Microsoft Excel :)

Rhoy Omega - 6 years, 4 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...