CoCalc Public FilesPM_2_5 / wave_equation / worksheets / l_basis_array.sagewsOpen in with one click!
Authors: Mani Chandra, Balavarun P, Aman Abhishek Tiwari
%typeset_mode True
var('x, xi') x_nodes = [-1, 1] xi_LGL = [-1.0, \ -0.87174014851, \ -0.591700181433,\ -0.209299217902,\ 0.209299217902, \ 0.591700181433, \ 0.87174014851, \ 1.0] lobatto_weights = [0.03571428571429,\ 0.21070422714351,\ 0.34112269248350,\ 0.41245879465870,\ 0.41245879465870,\ 0.34112269248350,\ 0.21070422714351,\ 0.03571428571429]
(x\displaystyle x, ξ\displaystyle \xi)
#Assigning L_0 and L_1 as the lagrange basis polynomials. L_0 = ((xi - (xi_LGL[1])) / (xi_LGL[0] - xi_LGL[1]))\ * ((xi - (xi_LGL[2])) / (xi_LGL[0] - xi_LGL[2]))\ * ((xi - (xi_LGL[3])) / (xi_LGL[0] - xi_LGL[3]))\ * ((xi - (xi_LGL[4])) / (xi_LGL[0] - xi_LGL[4]))\ * ((xi - (xi_LGL[5])) / (xi_LGL[0] - xi_LGL[5]))\ * ((xi - (xi_LGL[6])) / (xi_LGL[0] - xi_LGL[6]))\ * ((xi - (xi_LGL[7])) / (xi_LGL[0] - xi_LGL[7])) L_1 = ((xi - (xi_LGL[0])) / (xi_LGL[1] - xi_LGL[0]))\ * ((xi - (xi_LGL[2])) / (xi_LGL[1] - xi_LGL[2]))\ * ((xi - (xi_LGL[3])) / (xi_LGL[1] - xi_LGL[3]))\ * ((xi - (xi_LGL[4])) / (xi_LGL[1] - xi_LGL[4]))\ * ((xi - (xi_LGL[5])) / (xi_LGL[1] - xi_LGL[5]))\ * ((xi - (xi_LGL[6])) / (xi_LGL[1] - xi_LGL[6]))\ * ((xi - (xi_LGL[7])) / (xi_LGL[1] - xi_LGL[7])) L_2 = ((xi - (xi_LGL[0])) / (xi_LGL[2] - xi_LGL[0])) \ * ((xi - (xi_LGL[1])) / (xi_LGL[2] - xi_LGL[1])) \ * ((xi - (xi_LGL[3])) / (xi_LGL[2] - xi_LGL[3])) \ * ((xi - (xi_LGL[4])) / (xi_LGL[2] - xi_LGL[4])) \ * ((xi - (xi_LGL[5])) / (xi_LGL[2] - xi_LGL[5])) \ * ((xi - (xi_LGL[6])) / (xi_LGL[2] - xi_LGL[6])) \ * ((xi - (xi_LGL[7])) / (xi_LGL[2] - xi_LGL[7])) L_3 = ((xi - (xi_LGL[0])) / (xi_LGL[3] - xi_LGL[0])) \ * ((xi - (xi_LGL[1])) / (xi_LGL[3] - xi_LGL[1])) \ * ((xi - (xi_LGL[2])) / (xi_LGL[3] - xi_LGL[2])) \ * ((xi - (xi_LGL[4])) / (xi_LGL[3] - xi_LGL[4])) \ * ((xi - (xi_LGL[5])) / (xi_LGL[3] - xi_LGL[5])) \ * ((xi - (xi_LGL[6])) / (xi_LGL[3] - xi_LGL[6])) \ * ((xi - (xi_LGL[7])) / (xi_LGL[3] - xi_LGL[7])) L_4 = ((xi - (xi_LGL[0])) / (xi_LGL[4] - xi_LGL[0])) \ * ((xi - (xi_LGL[1])) / (xi_LGL[4] - xi_LGL[1])) \ * ((xi - (xi_LGL[2])) / (xi_LGL[4] - xi_LGL[2])) \ * ((xi - (xi_LGL[3])) / (xi_LGL[4] - xi_LGL[3])) \ * ((xi - (xi_LGL[5])) / (xi_LGL[4] - xi_LGL[5])) \ * ((xi - (xi_LGL[6])) / (xi_LGL[4] - xi_LGL[6])) \ * ((xi - (xi_LGL[7])) / (xi_LGL[4] - xi_LGL[7])) L_5 = ((xi - (xi_LGL[0])) / (xi_LGL[5] - xi_LGL[0])) \ * ((xi - (xi_LGL[1])) / (xi_LGL[5] - xi_LGL[1])) \ * ((xi - (xi_LGL[2])) / (xi_LGL[5] - xi_LGL[2])) \ * ((xi - (xi_LGL[3])) / (xi_LGL[5] - xi_LGL[3])) \ * ((xi - (xi_LGL[4])) / (xi_LGL[5] - xi_LGL[4])) \ * ((xi - (xi_LGL[6])) / (xi_LGL[5] - xi_LGL[6])) \ * ((xi - (xi_LGL[7])) / (xi_LGL[5] - xi_LGL[7])) L_6 = ((xi - (xi_LGL[0])) / (xi_LGL[6] - xi_LGL[0])) \ * ((xi - (xi_LGL[1])) / (xi_LGL[6] - xi_LGL[1])) \ * ((xi - (xi_LGL[2])) / (xi_LGL[6] - xi_LGL[2])) \ * ((xi - (xi_LGL[3])) / (xi_LGL[6] - xi_LGL[3])) \ * ((xi - (xi_LGL[4])) / (xi_LGL[6] - xi_LGL[4])) \ * ((xi - (xi_LGL[5])) / (xi_LGL[6] - xi_LGL[5])) \ * ((xi - (xi_LGL[7])) / (xi_LGL[6] - xi_LGL[7])) L_7 = ((xi - (xi_LGL[0])) / (xi_LGL[7] - xi_LGL[0])) \ * ((xi - (xi_LGL[1])) / (xi_LGL[7] - xi_LGL[1])) \ * ((xi - (xi_LGL[2])) / (xi_LGL[7] - xi_LGL[2])) \ * ((xi - (xi_LGL[3])) / (xi_LGL[7] - xi_LGL[3])) \ * ((xi - (xi_LGL[4])) / (xi_LGL[7] - xi_LGL[4])) \ * ((xi - (xi_LGL[5])) / (xi_LGL[7] - xi_LGL[5])) \ * ((xi - (xi_LGL[6])) / (xi_LGL[7] - xi_LGL[6])) \
L_0.simplify_full() L_1.simplify_full() L_2.simplify_full() L_3.simplify_full() L_4.simplify_full() L_5.simplify_full() L_6.simplify_full() L_7.simplify_full()
3.35156250001ξ7+3.35156250001ξ6+3.86718750001ξ53.86718750001ξ41.0546875ξ3+1.0546875ξ2+0.0390624999999ξ0.0390624999999\displaystyle -3.35156250001 \, \xi^{7} + 3.35156250001 \, \xi^{6} + 3.86718750001 \, \xi^{5} - 3.86718750001 \, \xi^{4} - 1.0546875 \, \xi^{3} + 1.0546875 \, \xi^{2} + 0.0390624999999 \, \xi - 0.0390624999999
8.14072271825ξ77.09659483138ξ611.347477684ξ5+9.89205188146ξ4+3.33160871212ξ32.90429707348ξ20.124853746365ξ+0.108840023398\displaystyle 8.14072271825 \, \xi^{7} - 7.09659483138 \, \xi^{6} - 11.347477684 \, \xi^{5} + 9.89205188146 \, \xi^{4} + 3.33160871212 \, \xi^{3} - 2.90429707348 \, \xi^{2} - 0.124853746365 \, \xi + 0.108840023398
10.3581368289ξ7+6.12891144098ξ6+18.6833551584ξ511.054944637ξ48.6700371412ξ3+5.13006254948ξ2+0.34481881174ξ0.204029353468\displaystyle -10.3581368289 \, \xi^{7} + 6.12891144098 \, \xi^{6} + 18.6833551584 \, \xi^{5} - 11.054944637 \, \xi^{4} - 8.6700371412 \, \xi^{3} + 5.13006254948 \, \xi^{2} + 0.34481881174 \, \xi - 0.204029353468
11.3898137485ξ72.38387910961ξ624.032962502ξ5+5.03008025554ξ4+15.6735080469ξ33.280452976ξ23.0303592934ξ+0.63425183007\displaystyle 11.3898137485 \, \xi^{7} - 2.38387910961 \, \xi^{6} - 24.032962502 \, \xi^{5} + 5.03008025554 \, \xi^{4} + 15.6735080469 \, \xi^{3} - 3.280452976 \, \xi^{2} - 3.0303592934 \, \xi + 0.63425183007
11.3898137485ξ72.38387910961ξ6+24.032962502ξ5+5.03008025554ξ415.6735080469ξ33.280452976ξ2+3.0303592934ξ+0.63425183007\displaystyle -11.3898137485 \, \xi^{7} - 2.38387910961 \, \xi^{6} + 24.032962502 \, \xi^{5} + 5.03008025554 \, \xi^{4} - 15.6735080469 \, \xi^{3} - 3.280452976 \, \xi^{2} + 3.0303592934 \, \xi + 0.63425183007
10.3581368289ξ7+6.12891144098ξ618.6833551584ξ511.054944637ξ4+8.6700371412ξ3+5.13006254948ξ20.34481881174ξ0.204029353468\displaystyle 10.3581368289 \, \xi^{7} + 6.12891144098 \, \xi^{6} - 18.6833551584 \, \xi^{5} - 11.054944637 \, \xi^{4} + 8.6700371412 \, \xi^{3} + 5.13006254948 \, \xi^{2} - 0.34481881174 \, \xi - 0.204029353468
8.14072271825ξ77.09659483138ξ6+11.347477684ξ5+9.89205188146ξ43.33160871212ξ32.90429707348ξ2+0.124853746365ξ+0.108840023398\displaystyle -8.14072271825 \, \xi^{7} - 7.09659483138 \, \xi^{6} + 11.347477684 \, \xi^{5} + 9.89205188146 \, \xi^{4} - 3.33160871212 \, \xi^{3} - 2.90429707348 \, \xi^{2} + 0.124853746365 \, \xi + 0.108840023398
3.35156250001ξ7+3.35156250001ξ63.86718750001ξ53.86718750001ξ4+1.0546875ξ3+1.0546875ξ20.0390624999999ξ0.0390624999999\displaystyle 3.35156250001 \, \xi^{7} + 3.35156250001 \, \xi^{6} - 3.86718750001 \, \xi^{5} - 3.86718750001 \, \xi^{4} + 1.0546875 \, \xi^{3} + 1.0546875 \, \xi^{2} - 0.0390624999999 \, \xi - 0.0390624999999
diff(L_0).simplify_full() diff(L_1).simplify_full() diff(L_2).simplify_full() diff(L_3).simplify_full() diff(L_4).simplify_full() diff(L_5).simplify_full() diff(L_6).simplify_full() diff(L_7).simplify_full()
23.4609375001ξ6+20.109375ξ5+19.3359375001ξ415.46875ξ33.16406250001ξ2+2.109375ξ+0.0390624999999\displaystyle -23.4609375001 \, \xi^{6} + 20.109375 \, \xi^{5} + 19.3359375001 \, \xi^{4} - 15.46875 \, \xi^{3} - 3.16406250001 \, \xi^{2} + 2.109375 \, \xi + 0.0390624999999
56.9850590277ξ642.5795689883ξ556.73738842ξ4+39.5682075259ξ3+9.99482613636ξ25.80859414696ξ0.124853746365\displaystyle 56.9850590277 \, \xi^{6} - 42.5795689883 \, \xi^{5} - 56.73738842 \, \xi^{4} + 39.5682075259 \, \xi^{3} + 9.99482613636 \, \xi^{2} - 5.80859414696 \, \xi - 0.124853746365
72.5069578025ξ6+36.7734686459ξ5+93.4167757919ξ444.219778548ξ326.0101114236ξ2+10.260125099ξ+0.34481881174\displaystyle -72.5069578025 \, \xi^{6} + 36.7734686459 \, \xi^{5} + 93.4167757919 \, \xi^{4} - 44.219778548 \, \xi^{3} - 26.0101114236 \, \xi^{2} + 10.260125099 \, \xi + 0.34481881174
79.7286962395ξ614.3032746577ξ5120.16481251ξ4+20.1203210222ξ3+47.0205241407ξ26.560905952ξ3.0303592934\displaystyle 79.7286962395 \, \xi^{6} - 14.3032746577 \, \xi^{5} - 120.16481251 \, \xi^{4} + 20.1203210222 \, \xi^{3} + 47.0205241407 \, \xi^{2} - 6.560905952 \, \xi - 3.0303592934
79.7286962395ξ614.3032746577ξ5+120.16481251ξ4+20.1203210222ξ347.0205241407ξ26.560905952ξ+3.0303592934\displaystyle -79.7286962395 \, \xi^{6} - 14.3032746577 \, \xi^{5} + 120.16481251 \, \xi^{4} + 20.1203210222 \, \xi^{3} - 47.0205241407 \, \xi^{2} - 6.560905952 \, \xi + 3.0303592934
72.5069578025ξ6+36.7734686459ξ593.4167757919ξ444.219778548ξ3+26.0101114236ξ2+10.260125099ξ0.34481881174\displaystyle 72.5069578025 \, \xi^{6} + 36.7734686459 \, \xi^{5} - 93.4167757919 \, \xi^{4} - 44.219778548 \, \xi^{3} + 26.0101114236 \, \xi^{2} + 10.260125099 \, \xi - 0.34481881174
56.9850590277ξ642.5795689883ξ5+56.73738842ξ4+39.5682075259ξ39.99482613636ξ25.80859414696ξ+0.124853746365\displaystyle -56.9850590277 \, \xi^{6} - 42.5795689883 \, \xi^{5} + 56.73738842 \, \xi^{4} + 39.5682075259 \, \xi^{3} - 9.99482613636 \, \xi^{2} - 5.80859414696 \, \xi + 0.124853746365
23.4609375001ξ6+20.109375ξ519.3359375001ξ415.46875ξ3+3.16406250001ξ2+2.109375ξ0.0390624999999\displaystyle 23.4609375001 \, \xi^{6} + 20.109375 \, \xi^{5} - 19.3359375001 \, \xi^{4} - 15.46875 \, \xi^{3} + 3.16406250001 \, \xi^{2} + 2.109375 \, \xi - 0.0390624999999