I have the following function:
$$u(x,t)=\sum_{k=1}^\infty\frac{v_0 L}{\lambda_k c \sin\left(\lambda_k\right)}\sin\left(\frac{\lambda_kx}{L}\right)\sin\left(\frac{\lambda_kct}{L}\right)$$
and this equation whose solutions are the $\lambda_k$ needed for the function above:
$$\varepsilon\lambda=\cot\left(\lambda\right)$$
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,\varepsilon)$ 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 $\varepsilon$ 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 $\varepsilon$ as a parameter or do I have to define it beforehand to find the values?
Interpolation
on it, giving anInterpolatingFunction
$u(x,t,\epsilon)$ as you desired. $\endgroup$TensorProduct
instead, which ought to reduce computation time by an order of magnitude or so. $\endgroup$