All problems
Variation of Parameters Step
Problem
For y'' + y = f(x) with fundamental solutions y1 = cos(x) and y2 = sin(x), variation of parameters gives u1' = -y2*f / W and u2' = y1*f / W, where W = 1.
Given the value f_value = f(x) at the point x, return [u1', u2'] = [-sin(x)*f_value, cos(x)*f_value].
Hint
The Wronskian of cos and sin is 1, which simplifies the formulas.
Test cases
case 1
in: [1,0]
expected: [0,1]
case 2
in: [1,1.5707963267948966]
expected: [-1,0]
case 3
in: [2,3.141592653589793]
expected: [0,-2]
case 4
in: [3,0.5235987755982988]
expected: [-1.5,2.598076211353316]
Starter codePython
def variation_step(f_value, x):
# Return [u1_prime, u2_prime]
# Your code here
pass4 test cases · run your code against them in the editor