# hermite.py def hermite (P,tipo=float): S=P[0]; lam1=S[0] if len(P)==1: return sviluppotipotaylor(S[1:],lam1,tipo=tipo) T=P[1]; lam2=T[0] if len(S)==1: return hermite(P[1:],tipo=tipo) if len(T)==1: return hermite([S]+P[2:],tipo=tipo) F=hermite([S[:-1]]+P[1:],tipo=tipo) G=hermite([S]+[T[:-1]]+P[2:],tipo=tipo) fattore=1/tipo(lam2-lam1) return pol1v(tipo,-lam1*fattore,fattore)*F+pol1v(tipo,lam2*fattore,-fattore)*G def sviluppotipotaylor (a,alfa,tipo=float): coeff=[]; fatt=tipo(1) for k,ak in enumerate(a): coeff.append(ak/fatt); fatt*=(k+1) f=pol1v(tipo,*coeff); xmenalfa=pol1v(tipo,-alfa,1) return f(xmenalfa)