1

Numerical Gradient Descent

Unsolved
Calculus
Optimization

Difficulty: 3 | Problem written by zeyad_omar
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

Gradient descent is an iterative method used to reach the moodel weights that make the model achieve the highest train accuracy, but it is sometimes difficult to differentiate the cost function (error function), so we use another numerical technique:

This is called a "check" because it is used to check if the gradient descent calculations are done right or not.

In this problem you are required to implement a gradient descent check given the value x and the delta t/ 

We are differentiating the funtion ex

Sample Input:
<class 'int'>
x: 0
<class 'float'>
t: 0.00000001

Expected Output:
<class 'float'>
0.999999993922529

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Veniam voluptatem perferendis omnis sit, laboriosam ullam quod vero corrupti earum explicabo esse, nesciunt aspernatur sed necessitatibus neque quas unde recusandae natus, ab amet possimus quas voluptatem. Quia consequuntur sint, eum voluptatibus debitis id cupiditate vero necessitatibus commodi ducimus quibusdam maxime sunt, fugit dolorem itaque pariatur distinctio blanditiis incidunt nostrum sequi aliquid quibusdam, aperiam praesentium expedita repudiandae non nam ducimus saepe accusantium beatae. Deleniti pariatur fugit?

Quia quas odit placeat tempora excepturi animi ab deleniti vel in, officiis quae nam, similique excepturi nihil itaque blanditiis, dolores omnis in perferendis, esse minus cum. Nulla expedita quisquam iure cupiditate possimus nemo, enim ipsam nemo alias quod dolorum dolor, commodi vitae praesentium repudiandae quos architecto ad? Similique facere autem quae possimus adipisci delectus ab quis animi, atque est eaque omnis tenetur minima ea. Voluptas quisquam illo fugit accusamus dicta commodi est dolorum voluptate, eveniet itaque magnam, necessitatibus quo architecto laudantium labore nostrum odit sed et beatae incidunt dolor, porro neque expedita unde praesentium cupiditate suscipit, perspiciatis rem quo libero similique amet accusamus laborum non nemo culpa voluptatem?

Eum velit atque illo nisi unde et pariatur sequi, perspiciatis consequatur esse consectetur?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)