cubic spline program
program: quadspline:=proc(x::Vector,y::Vector,t::name) local n,k,S,j,eq,tt,s; n:=LinearAlgebra:-Dimensions(x)-1; for k from 1 to n do s[k]:=a[k]*(t-x[k])^2+b[k]*(t-x[k])+c[k]; end do; j:=0; for k from 1 to n do j:=j+1; eq[j]:=subs(t=x[k],s[k])=y[k]; j:=j+1; eq[j]:=subs(t=x[k+1],s[k])=y[k+1]; end do; for k from 1 to n-1 do j:=j+1; eq[j]:=subs(t=x[k+1],diff(s[k],t))=subs(t=x[k+1],diff(s[k+1],t)); end do; j=j+1; eq[j]:=subs(t=x[1],diff(s[1],t,t))=2; tt:=solve({seq(eq[j],j=1..4*n)},{seq(a[j],j=1..n),seq(b[j],j=1..n),seq(c[j],j=1..n)}); assign(tt); S:=piecewise(seq(op([t>=x[k] and t<=x[k+1],s[k]]),k=1..n)); return S; end proc
its the last problem on there
i keep getting that error message
did you open the pdf?
what pdf?
scroll all the way to the bottom to see the error message
({seq(eq[j],j=1..4*n)},{seq(a[j],j=1..n),seq(b[j],j=1..n),seq(c[j],j=1..n)}) strange parentheses here
yep I think it's that line...
i dont think so, thats is exactly how the prof. has it on his version of the program. What i want to know is what that error is
can't plot a, b,c etc
it's not passing the values it solved for but the names of the constants instead.
Join our real-time social learning platform and learn together with your friends!