How to solve an equation with an array of constant parameters?
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I am trying to solve equation xlogx=e where x is the variable and e is a real constant. e can take many (say 10000) values which are stored in an array e_arr. I want to return an array of numerical solutions with each element corresponding to an element of e_arr. Of course, I can construct a string 'x*log2(x)= - 0.1' for example for each of the element of e_arr, but is there any way to call solve (or vpasolve) function with vector input for the constant parameter e? Could you please help me with this, assuming you are given an array, say, e_arr=[-0.1, -0.54, -0.32, ... ..., -0.79, -0.6]? Thanks a lot. PS: the log function has base 2 and x takes values in [0.0, 1.0].
0 Commenti
Risposta accettata
Ridwan Alam
il 6 Dic 2019
Modificato: Ridwan Alam
il 6 Dic 2019
syms x e
>> eqns = x*log2(x)==e
eqns =
(x*log(x))/log(2) == e
>> S= solve(eqns,x)
S =
(e*log(2))/lambertw(0, e*log(2))
>> e=[-0.1, -0.54, -0.32, -0.79, -0.6];
>> subs(S)
ans =
[ -log(2)/(10*lambertw(0, -log(2)/10)), -(27*log(2))/(50*lambertw(0, -(27*log(2))/50)), -(8*log(2))/(25*lambertw(0, -(8*log(2))/25)), -(79*log(2))/(100*lambertw(0, -(79*log(2))/100)), -(3*log(2))/(5*lambertw(0, -(3*log(2))/5))]
4 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Calculus in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!