We are concerned with the arithmetic of solutions to ordinary or partial nonlinear differential equations which are algebraic in the indeterminates and their derivatives. We call these solutions D-algebraic functions, and their equations are algebraic (ordinary or partial) differential equations (ADEs). The general purpose is to find ADEs whose solutions contain specified rational expressions of solutions to given ADEs. For univariate D-algebraic functions, we show how to derive an ADE of smallest possible order. In the multivariate case, we introduce a general algorithm for these computations and derive conclusions on the order bound of the resulting algebraic PDE. Using our accompanying Maple software, we discuss applications in physics, statistics, and symbolic integration.