How to get Matlab to solve an equation involving log(x) and a constant*x on LHS and log of a vector on RHS?
Show older comments
syms cell
A=0.079;
B=6*10^-9;
C=3.5*10^-10;
R=37;
Is=260;
I=111;
solve('3.5*10^-10*(50-37)*cell-2.5*2*cell^3+19*2.5*cell^2+58*2.5*(cell-1)-2.5 - log((260/213)/(1-(260/213)))+log(6*10^-9)+0.079*(50-37)',cell)
# My function is
C*(50-R)*Cell - 2.5lnCell= ln((Is/I)/((1-Is)/I)) - ln B - A*(50-R)
# here A, B and C are constants.. and I have to evaluate Cell from various values of I (* Please Note that I and R will be column vectors*), but this is the simplest form it can get solved to..
# I tried taylor series and got the simplified polynomial upto 3rd degree written in the code above and tried the solve function in Matlab,
# but it doesnt give a precise answer.
It gives me something like this
0.010445769111979284562103573703606*i - 3.1376696917728734352799890792042
11.729473052830051198402521143474 - 0.0039054714002454279122938908075595*i
0.014351240512224712474397464511166*i + 0.90819663894282223687746793573033
Please help me with this problem. Thank you
Accepted Answer
More Answers (1)
Walter Roberson
on 9 Nov 2011
Filtering:
real_x = x(imag(x) == 0);
But going back to your original expression: you have
(Is/I)/((1-Is)/I)
where you indicate that "I" is a column vector.
If "I" was a scalar, then that would simplify to Is/(1-Is) [except when "I" was 0 or one of the infinities].
You have used algebraic notation such as 2.5lnCell in setting up your equation, so I have to ask whether you intend the expression to be calculated one value of "I" at a time (in which case that part would cancel), or are you intending the "/" operator there to signify MATLAB's mrdivide operator, which in the context would calculate a least-squares estimation ?
If the "I" values do indeed cancel then it becomes pointless to look for variations in Cell in terms of "I". On the other hand, the situation has a definite solution that can be expressed in terms of LambertW:
(5/2)*LambertW((2/5)*C*(-50+R)*exp((2/5)*ln*B+20*A-(2/5)*A*R)/(-Is/(-1+Is))^(2/5))/(C*(-50+R))
4 Comments
rasika
on 10 Nov 2011
rasika
on 10 Nov 2011
Walter Roberson
on 10 Nov 2011
With the revised equation, I get this, where k is an index in to the intensity and R vectors:
RootOf((7145833333*Intensity(k)*R(k)^3-893229166625000*Intensity(k)+53593749997500*Intensity(k)*R(k)-1071874999950*Intensity(k)*R(k)^2)*_Z^11+(-61250000000000000000*Intensity[k]*R(k)^2-153125000000000000000000*Intensity(k)+6125000000000000000000*Intensity(k)*R(k))*_Z^9-4550000000000000000000000000000*_Z^7*Intensity(k)+(1000000000000000000000000000000000000000*v*Intensity(k)-1000000000000000000000000000000000000000*Intensity(k)+260000000000000000000000000000000000000000*exp(-79/20+(79/1000)*R(k)))*_Z^5+1560000000000000000000000000000000-6000000000000000000000000000000*Intensity(k))^2
That is, con is the square of the zeros of the 11th degree polynomial given as RootOf(), with _Z being the variable that much be chosen so that the expression within RootOf() becomes 0.
*If* the values are such that floating point precision is not lost in any of the following expressions (snicker!) then this can be expressed in terms of the MATLAB numeric root finder as
con_values = roots([7145833333*Intensity(k)*(R(k)-50)^3, 0, -61250000000000000000*Intensity(k)*(R(k)-50)^2, 0, -4550000000000000000000000000000*Intensity(k), 0, 1000000000000000000000000000000000000000*(v*Intensity(k)-Intensity(k)+260*exp(-79/20+(79/1000)*R(k))), 0, 0, 0, 0, 1560000000000000000000000000000000 -6000000000000000000000000000000*Intensity(k)]) .^ 2;
However, it seems likely to me that you are in the range where double precision would not have enough resolution to calculate the values properly using roots()
Checking for real roots: those roots are precisely the roots for which the complex part is 0, so x(imag(x) == 0) *does* filter the vector x down to values that are not complex.
rasika
on 10 Nov 2011
Categories
Find more on Common Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!