# MAXIMA IS A SHIT

Oct 20th, 2021
654
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. kill(all);
2. numer:true;
3. fpprintprec:8;retprint:false;
4. P_0(x):=1;
5. P_1(x):=1-1.0*(1-x);
6. P_2(x):=1.0*(-3.0*(1-x)+1.5*(1-x)^2+1);
7. P_3(x):=1.0*(-6.0*(1-x)-2.5*(1-x)^3+7.5*(1-x)^2+1);
8. P_4(x):=1.0*(-10.0*(1-x)+4.375*(1-x)^4-17.5*(1-x)^3+22.5*(1-x)^2+1);
9. P_5(x):=1.0*(-15.0*(1-x)-7.875*(1-x)^5+39.375*(1-x)^4-70.0*(1-x)^3+52.5*(1-
10. x)^2+1);
11. P_6(x):=1.0*(-21.0*(1-x)+14.4375*(1-x)^6-86.625*(1-x)^5+196.875*(1-x)^4-
12. 210.0*(1-x)^3+105.0*(1-x)^2+1);
13. P_7(x):=1.0*(-28.0*(1-x)-26.8125*(1-x)^7+187.6875*(1-x)^6-519.75*(1-
14. x)^5+721.875*(1-x)^4-525.0*(1-x)^3+189.0*(1-x)^2+1);
15. P_8(x):=1.0*(-36.0*(1-x)+50.273437*(1-x)^8-402.1875*(1-x)^7+1313.8125*(1-
16. x)^6-2252.25*(1-x)^5+2165.625*(1-x)^4-1155.0*(1-x)^3+315.0*(1-x)^2+1);
17. P_9(x):=1.0*(-45.0*(1-x)-94.960937*(1-x)^9+854.64844*(1-x)^8-3217.5*(1-
18. x)^7+6569.0625*(1-x)^6-7882.875*(1-x)^5+5630.625*(1-x)^4-2310.0*(1-
19. x)^3+495.0*(1-x)^2+1);
20. Ps:[P_0, P_1, P_2, P_3, P_4, P_5, P_6, P_7, P_8, P_9];
21. Func(n,m,v):=block(
22.  index:n+1,
23.  h:%pi/m,buf:0,
24.  for i thru m-1 do buf:buf+v(i*h)*Ps[index](cos(i*h))*sin(i*h),
25.  return(buf*h * (2 * n + 1) / 2)
26. );
27. v(x):=sin(x)^2;
28. c:[];
29. for i thru 10 do(
30.  c:endcons(Func(i - 1, 2000, v), c)
31. );
32. R:1;
33. g(r,θ):=c[1]*P_0(θ)+c[2]*P_1(θ)*(r/R)+c[3]*P_2(θ)*(r/R)^2+c[4]*P_3(θ)*(r/R)^3
34. +c[5]*P_4(θ)*(r/R)^4
35.
36. +c[6]*P_5(θ)*(r/R)^5+c[7]*P_6(θ)*(r/R)^6+c[8]*P_7(θ)*(r/R)^7+c[9]*P_8(θ)*(r/R
37. )^8+c[10]*P_9(θ)*(r/R)^9;
38. u (r,x):=g(r,cos(x));
39. u(0,0); u(0,%pi);
40. u(R,0); u(R,%pi);
41. plot3d(u(x,y),[x,0,R],[y,0,%pi],[xlabel,"радиус - r"],
42.  [ylabel,"угол - θ"],[legend,false],[title,"z = u(r,θ)"]);
43. plot2d([u(r,0),u(r,%pi/4),u(r,%pi/2)],[r,0,1],[xlabel,"радиус - r"],
44.  [ylabel,"u(r,θ)"],[legend,"θ=0","θ=π/4","θ=π/2"]);
45. plot2d([u(0.5),u(0.75),u(1)],[θ,0,%pi],[xlabel,"угол θ"],
46.  [ylabel,"u(r=fix, θ)"],[legend,"r=0.5","r=0.75","r=1"]);
RAW Paste Data