You are on page 1of 2

Sure, let's go step by step:

1. **Analytical Solution:**
The first derivative of the function \( f(x) = 2 - e^{3x} \) can be found analytically. Let's denote it
as \( f'(x) \).
\[ f(x) = 2 - e^{3x} \]
\[ f'(x) = \frac{d}{dx}(2 - e^{3x}) = 0 - 3e^{3x} = -3e^{3x} \]

Now, evaluate \( f'(0) \):


\[ f'(0) = -3e^{3(0)} = -3e^0 = -3 \]

2. **Forward Finite Difference Method:**


Using the forward finite difference method, we approximate the derivative using the formula:
\[ f'(x) \approx \frac{f(x + h) - f(x)}{h} \]

Plug in the values:


\[ f'(0) \approx \frac{f(0 + 0.1) - f(0)}{0.1} \]
\[ f'(0) \approx \frac{f(0.1) - f(0)}{0.1} \]
\[ f'(0) \approx \frac{(2 - e^{3(0.1)}) - (2 - e^{3(0)})}{0.1} \]
\[ f'(0) \approx \frac{(2 - e^{0.3}) - (2 - 1)}{0.1} \]
\[ f'(0) \approx \frac{1 - e^{0.3}}{0.1} \]
\[ f'(0) \approx \frac{1 - e^{0.3}}{0.1} \approx -2.24956 \]

3. **Backward Finite Difference Method:**


Using the backward finite difference method, we approximate the derivative using the formula:
\[ f'(x) \approx \frac{f(x) - f(x - h)}{h} \]

Plug in the values:


\[ f'(0) \approx \frac{f(0) - f(0 - 0.1)}{0.1} \]
\[ f'(0) \approx \frac{(2 - e^{3(0)}) - (2 - e^{3(-0.1)})}{0.1} \]
\[ f'(0) \approx \frac{(2 - 1) - (2 - e^{-0.3})}{0.1} \]
\[ f'(0) \approx \frac{1 - (2 - e^{-0.3})}{0.1} \]
\[ f'(0) \approx \frac{e^{-0.3} - 1}{0.1} \approx -3.45186 \]

4. **Central Finite Difference Method:**


Using the central finite difference method, we approximate the derivative using the formula:
\[ f'(x) \approx \frac{f(x + h) - f(x - h)}{2h} \]

Plug in the values:


\[ f'(0) \approx \frac{f(0 + 0.1) - f(0 - 0.1)}{2(0.1)} \]
\[ f'(0) \approx \frac{(2 - e^{3(0.1)}) - (2 - e^{3(-0.1)})}{0.2} \]
\[ f'(0) \approx \frac{(2 - e^{0.3}) - (2 - e^{-0.3})}{0.2} \]
\[ f'(0) \approx \frac{e^{-0.3} - e^{0.3}}{0.2} \approx -3.00071 \]
5. **Relative Error:**
To calculate the relative error for each method, use the formula:
\[ \text{Relative Error (\%)} = \frac{| \text{Approximate Value} - \text{Exact Value} |}{| \
text{Exact Value} |} \times 100\% \]

| Method | Approximate Value | Exact Value | Relative Error (\%) |


|------------------------|-------------------|-------------|---------------------|
| Analytical Solution | -3 | -3 | 0.000% |
| Forward Difference | -2.24956 | -3 | 24.985% |
| Backward Difference | -3.45186 | -3 | 15.062% |
| Central Difference | -3.00071 | -3 | 0.0237% |

From the table, it's evident that the central finite difference method provides the closest
approximation to the exact value, with the least relative error.

You might also like