Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Create a program to implement the Newton-Raphson method for finding roots of a function.

Hard

Problem Statement

Create a program to implement the Newton-Raphson method for finding roots of a function.

Sample Input

Function: f(x) = x^3 - 2x - 5
 Derivative: f'(x) = 3x^2 - 2
 Initial Guess: x0 = 2

Sample Output

Root: 2.0946

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
newton_raphson <- function(f, f_prime, x0, tol) { # Your logic here } # Call the function
Log in or sign up to run or submit your code.Log inSign up
Input
Function: f(x) = x^3 - 2x - 5
 Derivative: f'(x) = 3x^2 - 2
 Initial Guess: x0 = 2
Expected Output
Root: 2.0946