I need to evaluate the derivative of a function. My function looks like
approx[vector_, x_] := Sum[vector[[n]]*Basis[n - 1, x], {n, 1, Length[vector]}] and I'm defining my derivative like:
ddappx[vector_, x_] := D[approx[vector, x], {x, 2}] However if I evaluate it at a specific x I get an error:
General::ivar: 1 is not a valid variable. >> I searched enough to know that a solution when plotting this is to evaluate it first. Something about HoldAll and so on.
What I need to do is use it in a set of simultaneous equations. So I should be able to have:
Solve[{ddappx[{a,b}, 1]==0,ddappx[{a,b}, -1]==0},{a,b}] To solve for {a,b} by setting the 2nd derivative of approx ==0 at x=1 and x=-1. However I get the
General::ivar: 1 is not a valid variable. >> Errors again. Evaluating like
Solve[{Evaluate[ddappx[{a,b}, 1]]==0,Evaluate[ddappx[{a,b}, -1]]==0},{a,b}] isn't working.
so, any ideas?
cheers
EDIT: Having made the suggested change, that error is solved. However although evaluating approx works perfectly well, evaluating ddappx gives 0, no matter what I do. there is no error, just 0. I've added the whole code which goes in front just in case you think its relevant
diffeq[y_, x_] := y''[x] + y[x] f[x_] := Cos[2*x] Basis[n_, x_] := ChebyshevT[n, x] approx[vector_, x_] := Sum[vector[[n]]*Basis[n - 1, x], {n, 1, Length[vector]}] ddappx[vector_, x_] := Derivative[0, 2][approx][vector, x] ....
approx[{0, 0, 1, 1}, x] returns correctly:
-1 - 3 x + 2 x^2 + 4 x^3 ddappx[{0, 0, 1, 1, 1}, x] returns incorrectly:
0