qwerty9143
Technical User
Given two polynomials:
F1(x) = c1xn + c2xn-1 + ... + cnx + cn+1
F2(x) = β1xm + β2xm-1 + ... + βmx + βm+1
Write a fortran subroutine /function to add them, that is, F(x)= F1(x) + F2(x), when, n=m, n>m and n<m. Polynomials are added by adding the coefficients of the terms with the same exponent. Assume that the inputs to the subroutine/function are the vectors c=[c1 c2...cn cn+1] and β=[β1 β2...βm βm+1].
Check your script with the following data sets:
a) c = [43, 54, 55] and β = [77, 66, 88, 44, 33]
b) c = [11, 12, 13, 14] and β = [101, 102]; and
c) c = [1, 2, 3, 4] and β = [10, 20, 30, 40]
F1(x) = c1xn + c2xn-1 + ... + cnx + cn+1
F2(x) = β1xm + β2xm-1 + ... + βmx + βm+1
Write a fortran subroutine /function to add them, that is, F(x)= F1(x) + F2(x), when, n=m, n>m and n<m. Polynomials are added by adding the coefficients of the terms with the same exponent. Assume that the inputs to the subroutine/function are the vectors c=[c1 c2...cn cn+1] and β=[β1 β2...βm βm+1].
Check your script with the following data sets:
a) c = [43, 54, 55] and β = [77, 66, 88, 44, 33]
b) c = [11, 12, 13, 14] and β = [101, 102]; and
c) c = [1, 2, 3, 4] and β = [10, 20, 30, 40]