Ads

NC week 9 task

 question 1: https://drive.google.com/file/d/1GkxX1g0cZgjZ64zb3QYHzLj-DaRC563K/view?usp=sharing

question 2:

Discuss why finding such a root is important in DSP.

Answer:

In Digital Signal Processing (DSP), many systems—especially filters—require precise tuning to achieve desired behavior. Parameters such as phase-shift coefficients must satisfy nonlinear equations that balance signal amplitude and phase delay.

In our case:

f(x)=xsin(x)1=0f(x) = x \sin(x) - 1 = 0

This equation models a condition where phase and amplitude are balanced. Solving it helps in:

  • Tuning filters for accurate signal timing.

  • Avoiding signal distortion by ensuring that the desired frequency components are correctly aligned.

  • Achieving optimal system stability and performance.

Question 3:

 Write a Python or C++ program to implement the Secant Method and display the

result.

code:

import math


# Define the function f(x)

def f(x):

    return x * math.sin(x) - 1


# Secant method implementation

def secant_method(x0, x1, tol=1e-6, max_iter=100):

    for i in range(max_iter):

        f_x0 = f(x0)

        f_x1 = f(x1)


        if f_x1 - f_x0 == 0:

            print("Denominator zero. Cannot proceed further.")

            return None


        # Compute the next approximation

        x2 = x1 - f_x1 * (x1 - x0) / (f_x1 - f_x0)


        # Check for convergence

        if abs(x2 - x1) < tol:

            print(f"Root found after iterations: x ≈ {x2:.4f}")

            return x2


        # Update variables

        x0, x1 = x1, x2


    print("Method did not converge within the maximum number of iterations.")

    return None


# Initial guesses (visual inspection or intuition)

x0 = 1.1

x1 = 1.2


# Call the function

root = secant_method(x0, x1)


Post a Comment

0 Comments