TensorTonicTensorTonic
Problems
Study PlansProjectsInterviewPricingFeedback
Study Plan
Estimate a Scalar Derivative
Calculus
Easy

Estimate the derivative of a scalar polynomial using a forward difference. The Python list coefficients stores terms in ascending power order:

f(x)=∑k=0n−1ckxk.f(x)=\sum_{k=0}^{n-1}c_kx^k.f(x)=k=0∑n−1​ck​xk.

Here nnn is the coefficient count, kkk is the power, ckc_kck​ is its coefficient, and xxx is the evaluation point. For the supplied positive step hhh, the estimated slope is

f(x+h)−f(x)h.\frac{f(x+h)-f(x)}{h}.hf(x+h)−f(x)​.

Return a three-item tuple of Python floats in this order: the polynomial value at x, its value at x plus h, and the forward-difference slope.

Loading visualization...

Examples

Input: coefficients=[5.0,-4.0,3.0], x=3.0, h=0.001

Output: (20.0,20.014003,14.003)

Explanation: The polynomial is 3x² - 4x + 5, and the forward difference is close to its derivative value 14 at x=3.

Input: coefficients=[7.0], x=-2.0, h=0.1

Output: (7.0,7.0,0.0)

Input: coefficients=[-1.0,2.0], x=-3.0, h=0.25

Output: (-7.0,-6.5,2.0)

Hint 1

reversed visits coefficients from the highest power to the constant term.

Hint 2

float converts a NumPy scalar to a Python float.

Requirements

  • Use 64-bit floating-point arithmetic; NumPy is available.
  • Use the supplied forward step without replacing it with another derivative formula.
  • Leave the coefficient list unchanged.

Constraints

  • coefficients is a nonempty list of finite numbers.
  • x is a finite number.
  • h is a finite positive number.
  • Every evaluated value and returned slope must be finite.
Try Similar Problems
Measure Scalar Expression PartialsEasyCheck a Product-Chain GradientMediumApply Local Vector-Jacobian RulesEasyCreate a Multiplication Value NodeEasyCreate an Addition Value NodeEasyBackpropagate Through a Scalar NeuronMediumTopologically Sort a Computation DAGMediumAccumulate Shared-Path GradientsMediumSecond-Order Partial DerivativesEasyBasic AutogradEasyDerivatives of Common Activation FunctionsEasyJacobian of a Vector-Valued PolynomialEasy

Accepts: array

Accepts: number

Accepts: number

You must run your code first.

Estimate a Scalar Derivative

Calculus
Easy

Estimate the derivative of a scalar polynomial using a forward difference. The Python list coefficients stores terms in ascending power order:

f(x)=∑k=0n−1ckxk.f(x)=\sum_{k=0}^{n-1}c_kx^k.f(x)=k=0∑n−1​ck​xk.

Here nnn is the coefficient count, kkk is the power, ckc_kck​ is its coefficient, and xxx is the evaluation point. For the supplied positive step hhh, the estimated slope is

f(x+h)−f(x)h.\frac{f(x+h)-f(x)}{h}.hf(x+h)−f(x)​.

Return a three-item tuple of Python floats in this order: the polynomial value at x, its value at x plus h, and the forward-difference slope.

Loading visualization...

Examples

Input: coefficients=[5.0,-4.0,3.0], x=3.0, h=0.001

Output: (20.0,20.014003,14.003)

Explanation: The polynomial is 3x² - 4x + 5, and the forward difference is close to its derivative value 14 at x=3.

Input: coefficients=[7.0], x=-2.0, h=0.1

Output: (7.0,7.0,0.0)

Input: coefficients=[-1.0,2.0], x=-3.0, h=0.25

Output: (-7.0,-6.5,2.0)

Hint 1

reversed visits coefficients from the highest power to the constant term.

Hint 2

float converts a NumPy scalar to a Python float.

Requirements

  • Use 64-bit floating-point arithmetic; NumPy is available.
  • Use the supplied forward step without replacing it with another derivative formula.
  • Leave the coefficient list unchanged.

Constraints

  • coefficients is a nonempty list of finite numbers.
  • x is a finite number.
  • h is a finite positive number.
  • Every evaluated value and returned slope must be finite.
Try Similar Problems
Measure Scalar Expression PartialsEasyCheck a Product-Chain GradientMediumApply Local Vector-Jacobian RulesEasyCreate a Multiplication Value NodeEasyCreate an Addition Value NodeEasyBackpropagate Through a Scalar NeuronMediumTopologically Sort a Computation DAGMediumAccumulate Shared-Path GradientsMediumSecond-Order Partial DerivativesEasyBasic AutogradEasyDerivatives of Common Activation FunctionsEasyJacobian of a Vector-Valued PolynomialEasy

Accepts: array

Accepts: number

Accepts: number

You must run your code first.