How to resolve the algorithm Averages/Root mean square step by step in the Common Lisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Averages/Root mean square step by step in the Common Lisp programming language
Table of Contents
Problem Statement
Compute the Root mean square of the numbers 1..10.
The root mean square is also known by its initials RMS (or rms), and as the quadratic mean. The RMS is calculated as the mean of the squares of the numbers, square-rooted:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Averages/Root mean square step by step in the Common Lisp programming language
Source code in the common programming language
(loop for x from 1 to 10
for xx = (* x x)
for n from 1
summing xx into xx-sum
finally (return (sqrt (/ xx-sum n))))
(defun root-mean-square (numbers)
"Takes a list of numbers, returns their quadratic mean."
(sqrt
(/ (apply #'+ (mapcar #'(lambda (x) (* x x)) numbers))
(length numbers))))
(root-mean-square (loop for i from 1 to 10 collect i))
You may also check:How to resolve the algorithm Miller–Rabin primality test step by step in the Maxima programming language
You may also check:How to resolve the algorithm JortSort step by step in the Wren programming language
You may also check:How to resolve the algorithm Assertions step by step in the Brat programming language
You may also check:How to resolve the algorithm Guess the number step by step in the LOLCODE programming language
You may also check:How to resolve the algorithm First class environments step by step in the Perl programming language