more precision,a problem occured..

Which command of matlab can I use so that my variables have more precision?? Because I want to apply the Jacobi method at the Hilbert matrix,but the determinant is zero,because of the limits number of digits...

回答(2 个)

Unless you use numbers in the Symbolic Toolbox or perhaps one of John D'Errico's File Exchange programs, there is no matlab command to use more than the 53-bit precision of matlab's double precision floating point numbers.
However, at the Wikipedia site
http://en.wikipedia.org/wiki/Hilbert_matrix
you will find an explicit formula for the elements of the inverse of the Hilbert matrix which might allow you to use ordinary 'double' numbers in applying the Jacobi method (as shown at:
http://en.wikipedia.org/wiki/Jacobi_method.)

7 个评论

Which numbers of the Symbolic Toolbox or from John D'Errico's File Exchange programs could I use??
Do you mean that I have to use this formula:
??
Yes, that is the formula I was referring to. You can use nchoosek to find the values of those binomial coefficients if you make the first argument a scalar, not a vector. You will have some rather large values in the elements of H inverse, so they may still give you trouble if the size of H is overly large.
evi
evi 2013-12-1
编辑:evi 2013-12-1
I wrote the code and I got an infinite loop :o ..And if I use a command,as you said before,will there also exist problems for big numbers??
The Symbolic Toolbox can handle numbers up to about 10^10000 I think.
"I wrote the code and I got an infinite loop :o" How did you manage to do that? Could we see the code that did this?
About big numbers, yes, I already warned you about size of those binomial coefficients if your Hilbert matrix is too large.
evi
evi 2013-12-1
编辑:evi 2013-12-1
And which command of the Symbolic Toolbox could I use?
I wrote it again,like that: B{i}{j}=((((-1)^(i+j))*(i+j-1))*(nchoosek(250+i-1,250-j))*(nchoosek(250+j-1,250-i))*(((nchoosek(i+j-2,i-1)))^2))
and this is the result I get: ??? Error using ==> nchoosek at 24 The second input has to be a non-negative integer...
To get negative values for your second input to 'nchoosek' would require an i or j out of the [1,250] range. How large did you allow them to get?
That however is not your main difficulty. The number n = 250 is way too large to be used with 'double' floating point. I advise you to use symbolic toolbox numbers which can be very large indeed. I won't undertake to tell you how to do that. You have to devote some time to reading your manuals to know how to make use of them. It requires some considerable study.

请先登录,再进行评论。

Symbolic toolbox:
Each expression is
syms i j n
(-1).^(i+j) .* (i+j-1) .* nchoosek(n+i-1, n-j) .* nchoosek(n+j-1, n-i) .* nchoosek(i+j-2, i-1).^2
So I suspect you could then use
N = 250;
n = sym(N);
H_1 = sym(zeros(N,N));
for I = 1 : N
i = sym(i);
for J = 1 : N
j = sym(J);
H_1(I,J) = (-1).^(i+j) .* (i+j-1) .* nchoosek(n+i-1, n-j) .* nchoosek(n+j-1, n-i) .* nchoosek(i+j-2, i-1).^2;
end
end
If you ever wanted to convert it from symbolic numbers to decimal numbers, apply double() to it -- but expect round off and maybe overflow as well, if you do that.

4 个评论

I ran the code you sent me and I get this message:
??? Undefined function or method 'lt' for input arguments of type 'sym'.
Error in ==> nchoosek at 23
if ~isscalar(k) || k < 0 || ~isreal(k) || k ~= round(k)
What could I do now??
But,even if it works with this formula,the determinant will be zero yet..Do I not have to use more precision??? :/
I found this:
We demonstrate the use of hardware floats. Hilbert matrices are notoriously ill-conditioned: the computation of the determinant is subject to severe cancellation effects. The following results, both with HardwareFloats as well as with SoftwareFloats, are marred by numerical roundoff:
A := linalg::hilbert(15):
float(numeric::det(A, Symbolic)),
numeric::det(A, HardwareFloats),
numeric::det(A, SoftwareFloats)
.By using this,will I have more precision??If yes,how could I use this??
Note that the code you show her is for running inside MuPAD, not MATLAB directly. See evalin(symengine) and feval(symengine) for information on how you can invoke it from MATLAB.
It appears that you are somehow invoking the numeric nchoosek rather than the symbolic one. Please try some of the examples shown at http://www.mathworks.com/help/symbolic/nchoosek.html and see what happens

请先登录,再进行评论。

提问:

evi
2013-11-30

Community Treasure Hunt

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

Start Hunting!

Translated by