How to resolve the algorithm Averages/Root mean square step by step in the Standard ML programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Averages/Root mean square step by step in the Standard ML 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 Standard ML programming language

Source code in the standard programming language

fun rms(v: real vector) = 
  let
    val v' = Vector.map (fn x => x*x) v
    val sum = Vector.foldl op+ 0.0 v'
  in
    Math.sqrt( sum/real(Vector.length(v')) )
  end;

rms(Vector.tabulate(10, fn n => real(n+1)));


  

You may also check:How to resolve the algorithm Terminal control/Dimensions step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Sleep step by step in the TXR programming language
You may also check:How to resolve the algorithm Number reversal game step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Humble numbers step by step in the Raku programming language
You may also check:How to resolve the algorithm Hello world/Graphical step by step in the X86 Assembly programming language