A partial derivative treats every variable but one as a constant.
What to build
Print both partial derivatives of f(x, y) = a·x² + b·x·y + c·y² at a point.
Requirements
- Read a, b, c, x and y from one line.
- Compute ∂f/∂x and ∂f/∂y with the rules for derivatives.
- Print each as a whole number.
Input
One line with five whole numbers: a, b, c, x, y.
Output
Two lines: df/dx V and df/dy W, with V and W whole numbers.
Constraints
All numbers are between -100 and 100.
Example
Input:
1 0 3 1 2
Output:
df/dx 2
df/dy 12
Why it works
When only x moves, the term c·y² is constant and b·x·y behaves like (b·y)·x. That gives 2a·x + b·y. The same thinking for y gives b·x + 2c·y.
Examples
1 0 3 1 2
df/dx 2 df/dy 12
2 1 1 3 -1
df/dx 11 df/dy 1
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
For f = a·x² + b·x·y + c·y², treat y as a constant to get ∂f/∂x = 2a·x + b·y.
Hint 2
By the same rule, ∂f/∂y = b·x + 2c·y.
Hint 3
All numbers are whole, so print whole numbers.
Solution
Show one correct solution (try it yourself first)
a, b, c, x, y = [int(v) for v in input().split()]
print("df/dx", 2 * a * x + b * y)
print("df/dy", b * x + 2 * c * y)
▶ Open this solution in the compiler, then press Visualize to watch it run step by step