# Numerically solving transcendental equation for a range of values

I'm new to Mathematica, and I'm trying to solve for corresponding Ef values for a range of T values in the transcendental equation: p = n + Nd.

hbar = 6.5821*10^-16

m0 = 9.109*10^(-31);

mn = 1.1;

mp = 0.5;

ionizeE = 45 *0.001;

Eg = 1.11

Ed = Eg - ionizeE

nd = 10^15*0.01

kb = 8.6173*10^-5;

p[T] = 2*((mp*kb*T)/(2*\[Pi]*hbar^2))^(3/2)*Exp[Ef/(kb*T)]

n[T] = 2*((mn*kb*T)/(2*\[Pi]*hbar^2))^(3/2)*Exp[(Eg - Ef)/(kb*T)]

Nd[T] = nd*(1 + Exp[(Ef - Ed)/(kb*T)])

I attempted to do the following but this clearly doesn't work. Any help in the right direction is much appreciated! Thank you so much.

f[T_] := Ef /. FindRoot[p[T] /. {T -> {50, 1000}} == n[T] /. {T -> {50, 1000}} + Nd[T] /. {T -> {50, 1000}}, {Ef, T}]

• To numerically solve for Ef and T you need to provide numeric values for \[HBar] and kb Commented May 20, 2022 at 5:56
• @BobHanlon Thanks for pointing that out, I just tried putting the values for them, but it still gives me the same error. FindRoot::srect: Value T in search specification {Ef,T} is not a number or array of numbers. ReplaceAll::reps: {FindRoot[p[T]/. {Rule[<<2>>]}==n[T]/. {T->{<<2>>}}+Nd[T]/. {T->{50,1000}},{Ef,T}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. Commented May 20, 2022 at 6:32
• Edit your question to include the values. Commented May 20, 2022 at 6:34
• @BobHanlon Just did. Commented May 20, 2022 at 6:38
• Note that the exact value for hbar is QuantityMagnitude@ UnitConvert[Quantity[1, "ReducedPlanckConstant"], "SI"] Commented May 20, 2022 at 17:21

Clear["Global*"]

ℏ = 65821*10^-20;
m0 = 9109*10^(-34);
mn = 11/10;
mp = 1/2;
ionizeE = 45/1000;
Eg = 111/100;
Ed = Eg - ionizeE;
nd = 10^13;
kb = 86173*10^-9;

p[T_] = 2*((mp*kb*T)/(2*π*ℏ^2))^(3/2)*Exp[Ef/(kb*T)];

n[T_] = 2*((mn*kb*T)/(2*π*ℏ^2))^(3/2)*Exp[(Eg - Ef)/(kb*T)];

Nd[T_] = nd*(1 + Exp[(Ef - Ed)/(kb*T)]);

eqn = p[T] == n[T] + Nd[T] // Simplify;

sol[T_?NumericQ] :=
Ef /. FindRoot[eqn, {Ef, 29/50}, WorkingPrecision -> 20]

Plot[sol[T], {T, 5, 1000},
WorkingPrecision -> 20] // Quiet
`

• Thank you so much! Commented May 20, 2022 at 7:33