I have the following function:
u(x,t)=∞∑k=1v0Lλkcsin(λk)sin(λkxL)sin(λkctL)
and this equation whose solutions are the λk needed for the function above:
ελ=cot(λ)
How can I feed the solutions of this (not analytically solvable) equation into my function? If possible, I'd like to create a function u(x,t,ε) to create 3D plots. What I have found so far:
Clear[findRoots]
Options[findRoots] = Options[Reduce];
findRoots[gl_Equal, {x_, von_, bis_},
prec : (_Integer?Positive | MachinePrecision | Infinity) :
MachinePrecision, wrap_: Identity, opts : OptionsPattern[]] :=
Module[{work, glp, vonp,
bisp}, {glp, vonp, bisp} = {gl, von, bis} /.
r_Real :> SetPrecision[r, prec];
work = wrap@Reduce[{glp, vonp <= x <= bisp}, opts];
work = {ToRules[work]};
If[prec === Infinity, work, N[work, prec]]];
uk = (v0 L)/(lambdak c Sin[lambdak]) Sin[lambdak x/L] Sin[lambdak c t/L];
This function finds the roots in an interval manually defined since FindRoots
or NSolve
only finds one root. Removed the ε for a test:
lambdalist = x /. findroots[x == Cot[x], {x, 1, 100}];
This gives me a list like this to use:
{0.860334, 3.42562...}
Which works with my function
u[x_,t_,L_,c_,v0_] = Sum[uk, {lambdak, lambdalist}];
My question is:
Is it possible to add ε as a parameter or do I have to define it beforehand to find the values?
Comments
Post a Comment