NumberDecompose

NumberDecompose[x,{u1,,un}]

returns a list of coefficients {c1,,cn} of a decomposition of the number x in the basis {u1,,un}.

Details

  • The basis {u1,,un} must be a list of nonincreasing positive numbers.
  • The result has the same length of the basis, even if the initial coefficients are zero.
  • The coefficients {c1,,cn-1} are integers, but cn will be exact or not depending on the precision of x and the basis elements.
  • NumberDecompose[x,units] for negative x is equivalent to -NumberDecompose[-x,units].

Examples

open allclose all

Basic Examples  (2)

Decompose an amount of money in different denominations:

Decompose an amount of seconds in days, hours, minutes, and seconds:

Scope  (3)

Decompose an exact number using a basis of exact numbers:

Decompose an exact numeric quantity using an exact basis:

Use inexact numbers:

Decompose a negative number:

This is equivalent to the negative of the decomposition of its absolute value:

Applications  (2)

Decompose an amount of United States dollars in the available banknote denominations:

Decompose an amount of Bahamian dollars in the available banknote denominations:

Properties & Relations  (7)

The result of NumberDecompose is a list of non-negative numbers for a positive input:

The result is a list of nonpositive numbers for a negative input:

NumberCompose is the inverse of NumberDecompose:

DMSList is a special case of NumberDecompose:

The length of the result equals the length of the basis:

For integers, NumberDecompose returns the last solution found by FrobeniusSolve:

IntegerDigits is equivalent to NumberDecompose for an adequate choice of basis of units:

IntegerDigits with a MixedRadix specification performs a NumberDecompose operation:

Wolfram Research (2015), NumberDecompose, Wolfram Language function, https://reference.wolfram.com/language/ref/NumberDecompose.html.

Text

Wolfram Research (2015), NumberDecompose, Wolfram Language function, https://reference.wolfram.com/language/ref/NumberDecompose.html.

CMS

Wolfram Language. 2015. "NumberDecompose." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NumberDecompose.html.

APA

Wolfram Language. (2015). NumberDecompose. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NumberDecompose.html

BibTeX

@misc{reference.wolfram_2024_numberdecompose, author="Wolfram Research", title="{NumberDecompose}", year="2015", howpublished="\url{https://reference.wolfram.com/language/ref/NumberDecompose.html}", note=[Accessed: 14-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_numberdecompose, organization={Wolfram Research}, title={NumberDecompose}, year={2015}, url={https://reference.wolfram.com/language/ref/NumberDecompose.html}, note=[Accessed: 14-November-2024 ]}