I want to get the answer with no approximation,
I have X=[25 24 23;27 8 11]
I want X.^23 without approximation,help me please.

답변 (3개)

Torsten
Torsten 2015년 7월 8일

1 개 추천

Apply Titus' answer under
to each element of X.
Best wishes
Torsten.

댓글 수: 3

Sakunrat Jaejaima
Sakunrat Jaejaima 2015년 7월 8일
편집: Sakunrat Jaejaima 2015년 7월 8일
Same applie ?
Torsten
Torsten 2015년 7월 8일
??
X.^23
is the same as
[x(1,1)^23 x(1,2)^23
x(2,1)^23 ...]
so apply the technique in my answer to the last time you asked this question to each single entry in your matrix.

댓글을 달려면 로그인하십시오.

bio lim
bio lim 2015년 7월 8일

0 개 추천

What do you mean by without approximation? Are you talking about scientific notations? If so, you can change the format using, format style.
X=[25 24 23;27 8 11];
format bank % I am guessing this is the format you want.
X.^23

댓글 수: 4

Sakunrat Jaejaima
Sakunrat Jaejaima 2015년 7월 8일
Ex. 25^23 without approximation .I want to be integer
bio lim
bio lim 2015년 7월 8일
편집: bio lim 2015년 7월 8일
X=[25 24 23;27 8 11];
% The longest digit
digit_number = floor(log10(X(2,1)^23));
output = var((X.^23), digit_number))
I don't have access to matlab right now, so check and comment if there is an error.
Sakunrat Jaejaima
Sakunrat Jaejaima 2015년 7월 10일
it error .
output = vpa((X.^23),digit_number);

댓글을 달려면 로그인하십시오.

Steven Lord
Steven Lord 2015년 7월 8일

0 개 추천

You will need to compute in higher precision than double. 25^23 is large enough that not all integers that are that large can be exactly represented.
25^23 > flintmax
In fact, 25^23 is so large that even 1,000,000 is negligible compared to it.
z1 = 25^23;
z2 = z1 + 1000000;
z1 == z2 % will return TRUE, this is NOT a bug!
Think of it as though you gave Bill Gates a $5 bill. He's so rich ($78.8 billion according to Wikipedia) that $5 doesn't change his net worth at all. [Contacting the necessary accountants to change his net worth would cost him more than the $5 you gave him!]
You can compute symbolically:
X = sym([25 24 23;27 8 11]);
X.^23
Or if you're doing this as part of computing 25^23 mod N for some value N, don't compute 25^23 first then compute MOD. That's the straightforward approach described on the "Modular exponentiation" Wikipedia page, but it breaks down when the quantity whose modulus you're taking gets too large. Instead apply one of the other techniques described on that page. For small exponents, the memory efficient method is easy to write; the right-to-left is a little more difficult, but using BITGET you can do it reasonably easily in MATLAB.

카테고리

도움말 센터File Exchange에서 Mathematics에 대해 자세히 알아보기

태그

질문:

2015년 7월 8일

댓글:

2015년 7월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by