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

Programming Exercises

Create a program to optimize a mathematical function using the optim function.

Hard

Problem Statement

Create a program to optimize a mathematical function using the optim function.

Sample Input

Function: f(x) = (x[1] - 3)^2 + (x[2] - 4)^2

Sample Output

Optimized Result: x = 3 , y = 4

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure optimize_function <- function() { # 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[1] - 3)^2 + (x[2] - 4)^2
Expected Output
Optimized Result: x = 3 , y = 4