How to resolve the algorithm Averages/Pythagorean means step by step in the Futhark programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Averages/Pythagorean means step by step in the Futhark programming language
Table of Contents
Problem Statement
Compute all three of the Pythagorean means of the set of integers 1 through 10 (inclusive). Show that
A (
x
1
, … ,
x
n
) ≥ G (
x
1
, … ,
x
n
) ≥ H (
x
1
, … ,
x
n
)
{\displaystyle A(x_{1},\ldots ,x_{n})\geq G(x_{1},\ldots ,x_{n})\geq H(x_{1},\ldots ,x_{n})}
for this set of positive integers.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Averages/Pythagorean means step by step in the Futhark programming language
Source code in the futhark programming language
fun arithmetic_mean(as: [n]f64): f64 =
reduce (+) 0.0 (map (/f64(n)) as)
fun geometric_mean(as: [n]f64): f64 =
reduce (*) 1.0 (map (**(1.0/f64(n))) as)
fun harmonic_mean(as: [n]f64): f64 =
f64(n) / reduce (+) 0.0 (map (1.0/) as)
fun main(as: [n]f64): (f64,f64,f64) =
(arithmetic_mean as,
geometric_mean as,
harmonic_mean as)
You may also check:How to resolve the algorithm Strip a set of characters from a string step by step in the Go programming language
You may also check:How to resolve the algorithm Unicode variable names step by step in the LiveCode programming language
You may also check:How to resolve the algorithm Loops/Wrong ranges step by step in the PL/I programming language
You may also check:How to resolve the algorithm Colour pinstripe/Display step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm String prepend step by step in the Red programming language