Issue with solving an expression using solve command

I am doing coding for my thesis in Cognitive Radio Systems. After a series of simplification and substitution I got following expression for R_new which is the function of t_new
R_new=29310*t_new - (740230637807590039*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1))/9007199254740992 + (553376302050334301*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(31*t_new^(1/2) - 2383690921325797/562949953421312))/2) - 1))/9007199254740992 + (2982482666894658895*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(26*t_new^(1/2) - 7691227197842525/2251799813685248))/2) - 1))/18014398509481984 + (6130259553882274789*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(32*t_new^(1/2) - 618966936424713/140737488355328))/2) - 1))/36028797018963968 + (2335679196965696725*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(25*t_new^(1/2) - 3661259950175195/1125899906842624))/2) - 1))/18014398509481984 + (495882660278870997*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(81*t_new^(1/2) - 1748195917190933/140737488355328))/2) - 1))/18014398509481984 + (380895376735944389*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(74*t_new^(1/2) - 6347298562227079/562949953421312))/2) - 1))/9007199254740992 + (4391076890295509843*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(35*t_new^(1/2) - 688099554704501/140737488355328))/2) - 1))/36028797018963968 + (2810001741580268983*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(37*t_new^(1/2) - 2936751867564147/562949953421312))/2) - 1))/36028797018963968 + (4247342785866851583*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(38*t_new^(1/2) - 6057857383874553/1125899906842624))/2) - 1))/18014398509481984 + (725857227364724213*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(27*t_new^(1/2) - 4029967247667347/1125899906842624))/2) - 1))/4503599627370496 + (4031741629223864193*2^(1/2)*pi^(1/2)*(erf((2^(1/2)*(39*t_new^(1/2) - 6242211032620389/1125899906842624))/2) - 1)*((10*t_new)/3 - 1))/36028797018963968 + (1660128906151002903*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(23*t_new^(1/2) - 3292552652683065/1125899906842624))/2) - 1))/9007199254740992 + (1573888443493807947*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(51*t_new^(1/2) - 8454454817717421/1125899906842624))/2) - 1))/36028797018963968 + (1617008674822405425*2^(1/2)*pi^(1/2)*((10*t_new)/3 - 1)*(erf((2^(1/2)*(24*t_new^(1/2) - 1738453150714565/562949953421312))/2) - 1))/9007199254740992
now I need to calculate the value of t_new, which can be solved by taking the derivative and setting it to zero for this I did
R_derivative= diff(R_new)
t=solve(R_derivative)
but I am getting following result
Warning: Explicit solution could not be found. In solve at 83 In algorithm_temp at 84
t =
[ empty sym ]
but when I solve R_new for t_new it will give exact value. why I can't solve R_derivative ?
thanks in advance !!

 Réponse acceptée

Walter Roberson
Walter Roberson le 3 Avr 2013

1 vote

Are you getting a symbolic solution for t_new from the R_new expression? One that is not expressed in terms of RootOf() ? I do not seem to be able to eliminate the RootOf(). If you are substituting in a numeric value for R_new then the solver would do a numeric solution rather than an exact solution.
The numeric solution for the differential is approximately 0.04082971273

13 commentaires

If
t=solve(R_new)
then I got the result as
t =
0.010311267847402536009590909191235*i - 0.012822346460427825769512705063589
if I further use eval as
t1=eval(t)
then I got the value as
t2 =
1.0183
And how you got that value 0.04082971273 ?? Is there any mistake that I had made in coding during calculation ?
Never eval() a symbolic expression. Likely you had a variable named "i" with value 100 at the time you eval()'d. The "i" in the symbolic expression represents the square root of negative 1.
The solution you get is not exact: it is a numeric solution corresponding to R_new = 0. You cannot get a closed-form algebraic ("exact") solution for the answer.
The value I gave of 0.0408<etc> is for the solution of R_derivative = 0, not for the solution of R_new = 0. R_new = 0 has no real-valued solutions
For any given value of R_new between approximately 1551 and 8789.714457, there are two corresponding t_new, one between 0 and 0.0408<etc> and the other between 0.0408<etc> and 0.2985<etc> . For larger real values of R_new there is only a single t_new greater than 0.2985<etc>
ok I also want solution of R_derivative=0 not of R_new=0. So how can I get the solution through coding ? and which value should I consider as you wrote above there are two values of t_new and how can I know it ?
The solution of R_derivative = 0 will have to be found by numeric approaches. It is the 0.04082971273 I indicated.
Rdfun = matlabFunction(diff(R_new, t_new));
initialguess = 1;
fzero(Rdfun, initialguess)
I am getting following error with your code
??? Error using ==> erf
Input must be real and full.
Error in ==>
Error in ==> fzero at 352
a = x - dx; fa = FunFcn(a,varargin{:});
Error in ==> algorithm_temp at 86
fzero(Rdfun, initialguess)
Oh yes, the numeric erf does not handle complex inputs. You will need to use the interval form of fzero to prevent t_new from going negative.
fzero(Rdfun, [0 realmax])
Again getting following error
??? Error using ==> fzero at 246
Function values at interval endpoints must be finite and real.
Error in ==> algorithm_temp at 84
fzero(Rdfun, [0 realmax])
Sorry, it appears that instead of realmax, you will need to use a number on the order of pi * 10^303 (approximately.) If you need to deal with larger t_new values than that, we are going to have to change tactics.
you mean I have to write code like below
Rdfun = matlabFunction(diff(R_miss_t, t_new))
fzero(Rdfun, [0 pi*10^303])
if yes then again I am getting the same error as
??? Error using ==> fzero at 246
Function values at interval endpoints must be finite and real.
Error in ==> algorithm_temp at 84
fzero(Rdfun, [0 pi*10^303])
sorry instead of R_miss_t it is R_new in above my comment
Ah, it appears that the interval you should use for that is [realmin realmax]
No with
fzero(Rdfun, [realmin realmax])
again getting same error :(
??? Error using ==> fzero at 246
Function values at interval endpoints must be finite and real.
Error in ==> algorithm_temp at 84
fzero(Rdfun, [realmin realmax])
I don't know. Try using [0.0001 100] as the interval.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by