﻿ Asymptote Code

## Asymptote Code

Plotting the scaled Swiss-Knife polynomials.

import graph;
size(400,300,IgnoreAspect);

//-- SKPolynomial(n,x) / abs(SKPolynomial(n,irem(n,2)))

real p0(real x){ return (1)/1; }
real p1(real x){ return (x)/1; }
real p2(real x){ return (x^2-1)/1; }
real p3(real x){ return (x^3-3*x)/2; }
real p4(real x){ return (x^4-6*x^2+5)/5; }
real p5(real x){ return (x^5-10*x^3+25*x)/16; }
real p6(real x){ return (x^6-15*x^4+75*x^2-61)/61; }
real p7(real x){ return (x^7-21*x^5+175*x^3-427*x)/272; }
real p8(real x){ return (x^8-28*x^6+350*x^4-1708*x^2+1385)/1385; }
real p9(real x){ return (x^9-36*x^7+630*x^5-5124*x^3+12465*x)/7936; }
real p10(real x){return (x^10-45*x^8+1050*x^6-12810*x^4+62325*x^2-50521)/50521; }
real p11(real x){return (x^11-55*x^9+1650*x^7-28182*x^5+228525*x^3-555731*x)/353792;}

int l = -3, h = 3; real lwf = 2; bool odd = true;

if(odd)
{
draw(graph(p3,  l, h, 100, Hermite), red+lwf*linewidth());
draw(graph(p5,  l, h, 100, Hermite), blue+lwf*linewidth());
draw(graph(p7,  l, h, 100, Hermite), green+lwf*linewidth());
draw(graph(p9,  l, h, 100, Hermite), black+lwf*linewidth());
draw(graph(p11, l, h, 100, Hermite), magenta+lwf*linewidth());
ylimits(-8,8,Crop);

xaxis(Bottom,RightTicks(Label(fontsize(12)), new real[]{-3,-1.5,0,1.5,3}));
yaxis(Left,  LeftTicks( Label(fontsize(12)), new real[]{-8,-4,0,4,8}));

label("$\omega_n(x)\,;\ n=3,5,7,9,11$",(0,-10),  black+fontsize(11));
shipout("Odd scaled Swiss-Knife polynomials");
}
else
{
draw(graph(p2,  l, h, 100, Hermite), red+lwf*linewidth());
draw(graph(p4,  l, h, 100, Hermite), blue+lwf*linewidth());
draw(graph(p6,  l, h, 100, Hermite), green+lwf*linewidth());
draw(graph(p8,  l, h, 100, Hermite), black+lwf*linewidth());
draw(graph(p10, l, h, 100, Hermite), magenta+lwf*linewidth());
ylimits(-1.5,8,Crop);

xaxis(Bottom,RightTicks( Label(fontsize(12)),new real[]{-3,-1.5,0,1.5,3}));
yaxis(Left,  LeftTicks(  Label(fontsize(12)),new real[]{-8,-4,0,4,8}));

label("$\omega_n(x)\,;\ n=2,4,6,8,10$",(0,-2.7),  black+fontsize(11));
shipout("Even scaled Swiss-Knife polynomials");
}

The plots generated with this code are displayed here.