# How to assign the roots of transcendental equation into an equation

Firstly, I'm going to find the roots of transcendental equation then assign the roots into an equation to solve it. However, I don't know how to ask Mathematica to assign the roots into the equation.

β = {0.01, 0.1, 1, 10, 100};k=0.5;

eqn = Table[α[n]*BesselJ[1, α[n]] == BesselJ[0, α[n]] *β[[n]], {n, 1, 5}];
roots = Table[FindRoot[eqn[[n]], {α[n], 1}], {n, 1, 5}]


The output which are the roots of given transcendental equation:

a1 is the equation that I need to assign the roots then I want to get the summation of a1. This is where I stuck because I don't know how to ask Mathematica to assign the roots that I got previously into equation a1 then find the summation of a1 as in the table below.

a1 = (BesselJ[0, k α[n]]^2 + BesselJ[1, k α[n]]^2) BesselY[1, k α[n]]^2;

find[m_] := Sum[a1, {n, 1}]

lst = Join[{{"β", "α[n]", "a1"}},Table[{β[[n]], roots[[n, 1, 2]], find[n]}, {n, 1, 5}]];
Grid[lst, Dividers -> All]


This table below is what I expected to get however for the summation of a1 I'm not able to solve it.

• Your code contains syntax errors. Please copy and paste it into a notebook and see for yourself. In the definition of find[m_] the variable m does not appear on the right hand side. The question is also not very clear. Are you familiar with /.? See this tutorial for example. Commented Dec 8, 2022 at 17:14
• Hi. My bad, I already corrected the syntax error and tried.
– Aifa
Commented Dec 9, 2022 at 0:36

## 2 Answers

Note that when you compute roots, you don't make any assignments to α[n]. That means that, if it just sees α[n] by itself, Mathematica doesn't know anything about which α[n] gets assigned to which value—so a1 and in turn find can't use those values. All of the information regarding the assignment of α[n] to values is in roots.

What I would do is actually just make a1 a function (note: it's not an equation!) taking in some argument alpha, then map it across your list of values, and Accumulate (which is the list of partial sums of the given list).

Clear[a1];
a1[α_] := (BesselJ[0, k α]^2 + BesselJ[1, k α]^2) BesselY[1, k α]^2

listOfAlphaSums = Accumulate[a1 /@ roots[[All,1,2]]]

lst = Join[{{"\[Beta]", "\[Alpha][n]", "a1"}},
Transpose[{\[Beta], roots[[All, 1, 2]], listOfAlphaSums}]];

Grid[lst, Dividers -> All]


Note the switch to Transpose, since they're all lists now, and this has the same effect.

In the above, we follow your approach of using Part ([[ ... ]]) to extract the values on the rhs's. But as an aside, to use rules in more generality, check out /. (ReplaceAll). If you use /. with a list of rules, it will produce a single outcome. However, if you use it with a list of list of rules, like roots, it will produce a list of outcomes, one for each list of rules in the list.

• Thank you so much :)
– Aifa
Commented Dec 12, 2022 at 2:56
Clear["Global*"]

α[β_?NumericQ] := Module[{a},
a /. FindRoot[a*BesselJ[1, a] == BesselJ[0, a] β, {a, 1}]]

β = 10^Range[-2, 2];

α /@ β

(* {0.141245, 0.441682, 1.25578, 2.1795, 2.3809} *)

Show[
LogLinearPlot[α[b], {b, 0.01, 100},
PlotRange -> All],
ListPlot[{#, α[#]} & /@ β,
PlotStyle -> Red,
ScalingFunctions -> {"Log", None}],
AxesOrigin -> {Log[8*^-3], 0}]
`