I have a question out of sheer curiosity. How is multiplication of large numbers implemented in MATLAB ? Is it Karatsuba,Toom-3, Fürer or something entirely different ?
C = A . * B multiplies arrays A and B by multiplying corresponding elements. The sizes of A and B must be the same or be compatible. If the sizes of A and B are compatible, then the two arrays implicitly expand to match each other.
* is matrix multiplication while . * is elementwise multiplication. In order to use the first operator, the operands should obey matrix multiplication rules in terms of size. Show activity on this post.
More Answers (1)Use Symbolic Math Toolbox. Be careful not to perform computations in double that result in values greater than flintmax and then convert the results to sym. Convert exact quantities to sym and perform the calculations symbolically.
MATLAB matches all characters in the name exactly except for the wildcard character * , which can match any one or more characters.
If you are interested in the algorithm for computing for example 139676498390139139676498390676498390*8745566554641239676498390676498390
, then this is what happens:
double
in IEEE® Standard 754
doubles
can only accurately represent integers of up to 2^53-1
(check documentation of bitmax
function) (~10^15
, while your numbers are on the order of 10^35
).Have a look at this example code:
>> a=139676498390139139676498390676498390;
>> num2str(a)
ans =
139676498390139141600015724509659136
which is clearly not exactly the value you assigned to a
- only the first 16 digits match.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With