# Solving equation by mathematica and Finding value of b in an equation

I have an equation and I have tried solving it to find values of b but it doesn't give me any values

The equation that I have tried to solve is :

ArcTan[1/d*Sqrt[(a+b)/(1-b)]]-(Vi/h)*Integrate[Sqrt[(1+(x/h)^2)^(-1)],{x,(h/2)*Log[b],0}]+(Pi/4)+m*Pi=0

I tried on it as following:

a = 0; m = 0; c = 0.98; d = c - (a*(1 - c));
bValue = Table[FindRoot[ArcTan[1/d*Sqrt[(a+b)/(1-b)]]-(Vi/h)*Integrate[Sqrt[(1+(x/h)^2)^(-1)],{x,(h/2)*Log[b],0}]+(Pi/4)+m*Pi,{b,0.5}], {Vi, 0.8, 5.0, 0.1}];
bValues = Re[b /. bValue]
bValuesList = Transpose[{Join[{b}, bValues]}]
bGrid = Grid[bValuesList, Frame -> All]
vValues = Table[i, {i, 0, 20, 0.1}]
vValuesList = Transpose[{Join[{V}, vValues]}]
vGrid = Grid[vValuesList, Frame -> All]

## 2 Answers

Clear["Global*"]

Evaluate the integral once

int = Assuming[0 < b < 1,
Integrate[Sqrt[(1 + (x/h)^2)^(-1)], {x, (h/2)*Log[b], 0}]]

(* -h ArcSinh[Log[b]/2] *)

a = 0; m = 0; c = 98/100; d = c - (a*(1 - c));

expr[Vi_, b_] = ArcTan[1/d*Sqrt[(a + b)/(1 - b)]] -
(Vi/h)*int + (Pi/4) + m*Pi;

root[Vi_?NumericQ] :=
NSolveValues[{expr[Vi, b] == 0, 0 < b < 1}, b][[1]]

EDIT: Or use

root[Vi_?NumericQ] := b /.
FindRoot[expr[Vi, b] == 0, {b, 0.3}]

viList = {4/5, 2, 4, 8};

Plot[Evaluate@
Table[Tooltip[expr[Vi, b],
StringForm["Vi = `", Vi]], {Vi, viList}],
{b, 0, 1},
AxesLabel -> {b, HoldForm@expr[Vi, b]},
Epilog -> {Red, AbsolutePointSize[4],
Tooltip[Point[pt = {root[#], 0}], pt[[1]]] & /@ viList},
PlotLegends -> Placed[
LineLegend[viList, LegendLabel -> Vi],
{.7, .3}]]

step = 0.4; (* change to desired granularity *)

Grid[
Prepend[
Table[{Vi, root[Vi]}, {Vi, 0.8, 8, step}],
{Vi, b}],
Frame -> All]

• I tried your way to solve the equation but it does not give me as you have written here Commented Aug 17, 2022 at 15:45
• If you copy and pasted my code and it didn't work, there must be a difference with Mma versions, presumably with NSolveValues. I used v13.1, what version are you using? Commented Aug 17, 2022 at 19:07
• yes i think the problem on NSolveValues , the version is 11.2 Commented Aug 18, 2022 at 4:17
• Then use root[Vi_?NumericQ] := b /. FindRoot[expr[Vi, b] == 0, {b, 0.3}] Commented Aug 18, 2022 at 5:05
• ArcTan[1/dSqrt[(a+b)/(1-b)]]-(Vi/h)*Integrate[Sqrt[(1+(x/h)^2)^(-1)-b],{x,(h/2)*Log[b],0}]+(Pi/4)+mPi=0 .... there is an eddit in the equation can you see it please?! Commented Aug 19, 2022 at 14:37

Change the integration variable x to xdh=x/h , in this way parameter h dissappears

eq = ArcTan[1/d*Sqrt[(a + b)/(1 - b)]] - (Vi/h)*Integrate[Sqrt[(1 + (xdh)^2)^(-1)], {xdh,(1/2)*Log[b], 0}] h + (Pi/4) +m*Pi

ConturPlot shows possible real solutions {Vi,b}

pic=ContourPlot[0 == eq, {Vi, .8, 5}, {b, 0.0, .6}, FrameLabel -> {Vi, b}]

List of solutions found:

pic[[1, 1]][[1]]
(*{{0.8, 0.0416416},{0.804065,0.0422764},
{0.807732,0.0428571}, {0.8375,0.0477974},
{0.838872, 0.0480182},...}*)

Alternatively try direct solution NSolve

sol[Vi_] := {Vi, b} /. NSolve[{0 ==eq[[1]], 0 < b < 1}, b][[1]]
Table[sol[Vi], {Vi, .8, 5, .1}]
• why when i put a=100 it doesn't give me any result ?! Commented Aug 18, 2022 at 4:18
• Perhaps no real solution exists for a==100. Try to visualize with Plot3D[eq, {b, 0, 1}, {Vi, 0.8, 5}] Commented Aug 18, 2022 at 5:48
• I have used Plot3D before but it does not work, if it is does not have real solution and just imaginary ones how i can get the figure for the real part of the solutions?! Commented Aug 18, 2022 at 14:32
• Plot3D[eq,...] shows a surface depending on b,Vi. If surface only shows points <0 there is no real solution! Commented Aug 18, 2022 at 14:39
• Restart your kernel and evaluate my code. Now Plot3D[eq, {b, 0, 1}, {Vi, 0.8, 5}] should show a surface? Commented Aug 18, 2022 at 14:58