[Question]
  [
Let \$R, C\$ be positive integers and let \$0 < s \leq 1\$. Consider the \$R \times C\$ **matrix** \$\mathbf M\$ defined as
\begin{equation}
M(i,j) = \frac{\mathrm{mod}\,(j, i^s)}{R^s}, \quad i = 1, \ldots, R, \quad j = 1, \ldots, C
\end{equation}
where \$\,\mathrm{mod}\,\$ denotes the [modulo operation](https://en.wikipedia.org/wiki/Modulo_operation): for \$a,b > 0\$ not necessarily integer, \$\mathrm{mod}\,(a,b) = c\$ if and only if \$0 \leq c < b\$ and \$a = b\cdot k + c\$ with \$k\$ integer.
Note that \$0 \leq M(i,j) < 1\$.
The matrix \$\mathbf M \$ can be displayed as an image, where the value of each entry determines the color of a pixel, using a **colormap** to translate numbers between \$0\$ and \$1\$ into colors. The simplest colormap is to directly consider each number as grey intensity, with \$0\$ corresponding to black and \$1\$ to white.
As an example, \$R=500\$, \$C=800\$, \$s=0.8\$ with the grey colormap give the following image:
![](https://i.stack.imgur.com/F4hSM.png)
# The challenge
Given two positive integers \$100 \leq R, C \leq 2000 \$ and a number \$0 < s \leq 1\$, display the above defined matrix \$\mathbf M\$ as an image. You can use any colormap of your choice, not necessarily consistent across images, as long as it satisfies the very lax requirements described next.
# Colormap requirements
1. At least \$16\$ different colours.
2. Reasonably gradual changes between adjacent colours.
3. The first and last colours should be clearly different.
Although the terms *reasonably gradual* and *clearly different* are somewhat subjective, this is not likely to be a contentious point. The sole purpose of these requirements is to prevent abuse. If your programming language offers a default colormap, it is most likely fine. If it doesn't, using grey is probably the shortest option.
# Additional rules
* **Graphical output** is required, with output being [flexible](https://codegolf.meta.stackexchange.com/questions/9093/default-acceptable-image-i-o-methods-for-image-related-challenges) as usual.
* The image should have the correct **orientation**, with \$M(1,1)\$ corresponding to the upper-left corner.
* The image should have the **aspect ratio** given by \$R\$ and \$C\$. That is, each entry of \$\mathbf M\$ should correspond to a square pixel.
* If the image is output by displaying it on the screen, it is not necessary that each screen pixel corresponds to an image pixel. That is, the **display scaling is flexible** (but the aspect ratio should be kept).
* **Auxiliary elements** such as axis labels, grid lines or a white frame are not required, but are allowed.
* [Programs or functions](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet) are accepted. [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* Shortest code in bytes wins.
# Test cases
Each of the following uses a different colormap, to illustrate some possibilities (and not incidentally to produce lively pictures).
| Inputs: `R`, `C`, `s` | Output |
| --- | --- |
| `500`, `800`, `0.8` |  |
| `600`, `1000`, `0.7` |  |
| `800`, `800`, `0.9` |  |
| `500`, `900`, `1` |  |
| `700`, `1200`, `0.6` |  |
| `200`, `250`, `0.3` |  |
 
  
[Answer]
# [Haskell](https://www.haskell.org/), 131 bytes
```
f=fromIntegral
u=unwords.map show
a%b|a>b=(a-b)%b|1<2=a
(r#c)s="P2":u[c,r,99]:[u[round$f j%(f i**s)/f r**s*99|j<-[1..c]]|i<-[1..r]]
```
[Try it online!](https://tio.run/##Jc27CoMwGEDh3acIXiARTVUoqJjuhRYKHSVDvKRqNcofg4vvboVO59tOJ/S3HcfjkEzCPN3V2n5AjJZhRm0zNJpOYkG6mzdLeNUubhXDIqzI6bhImLAwODXRzH4ldm7KOoAgy3hemhJmoxpXosHDEvW@r8lFIjjrZ9k@FGEZU1pzvvd/AufHJHrFzt8TLWZ9r/BQyEX4GjlpRCKaHj8 "Haskell – Try It Online")
`(r#c)s` returns the lines of a PGM file.
After writing it like this, I learned I could probably just return a matrix of float values but I don't think that's very interesting.
[![enter image description here](https://i.stack.imgur.com/gHlbo.png)](https://i.stack.imgur.com/gHlbo.png)
[Answer]
# [J](http://jsoftware.com/), 51 bytes
```
load'viewmat'
1 :'[:viewmat(|~^&u)"0~/&(1+i.)%u^~['
```
[Try it online!](https://tio.run/##y/r/Pyc/MUW9LDO1PDexRJ3LUMFKPdoKytWoqYtTK9VUMqjTV9Mw1M7U01QtjauLVv//HwA "J – Try It Online")
A J adverb, which uses the library function `viewmat` to do all the heavy lifting -- we merely need to construct the matrix values.
Assuming the adverb has been assigned to `f`, called like:
```
500 (0.8 f) 800
```
## 500 800 0.8
[![500 800 0.8](https://i.stack.imgur.com/x8dqZ.jpg)](https://i.stack.imgur.com/x8dqZ.jpg)
## 200 250 0.3
[![200 250 0.3](https://i.stack.imgur.com/JcHKg.jpg)](https://i.stack.imgur.com/JcHKg.jpg)
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 39 bytes
```
sImage@Array[Mod[#2,#^s]&,{##}]/#^s&
```
[Try it online!](https://tio.run/##y00syUjNTSzJTE78n2b7v/j9pIWeuYnpqQ6ORUWJldG@@SnRykY6ynHFsWo61crKtbH6QLba/4CizLwSh7RoAz2L2GhTAwMdCwOD2P8A "Wolfram Language (Mathematica) – Try It Online")
Input `[s][R, C]`.
[![Test cases run in Mathematica](https://i.stack.imgur.com/XQRf5.png)](https://i.stack.imgur.com/XQRf5.png)
[Answer]
# [K (oK) + `iKe`](https://github.com/JohnEarnest/ok), 61 bytes
```
{w::y;h::x;p::pow[;z];,(;gray;+_255*((p 1+!h)!\:/:1+!w)%p w)}
```
[Try it online!](https://johnearnest.github.io/ok/ike/ike.html?key=xhQWqes_)
Shortened heavily and made to work with the help of JohnE and coltim at [the k tree.](https://chat.stackexchange.com/rooms/90748/the-k-tree)
A function which takes input as `R, C, s`.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~116~~ ~~114~~118 bytes
-2 thanks to some basic pointers from hyper-neutrino  
+4 to correct an off-by-one error, thanks Tipping Octopus
```
from matplotlib.pylab import*
def M(R,C,s):
 imshow([[j%i**s/R**s for j in range(1,C+1)]for i in range(1,R+1)]);show()
```
Fairly straightforward, my first code golf attempt so I may be missing something easily golfable. Executes nested list comprehension inside the imshow() to immediately create image. Needs the show() to actually display the image.
## 700, 1200, 0.6
[![700, 1200, 0.6](https://i.stack.imgur.com/RVkqV.png)](https://i.stack.imgur.com/RVkqV.png)
[Answer]
# JavaScript + HTML, 156 bytes
```
(R,C,s)=>{for((w=x=>document.write(x))`<table cellspacing=0>`,i=0;i++<R;)for(w`<tr>`,j=0;j<C;)w(`<td bgcolor=#${((++j%i**s*16/R**s|0)*273).toString(16)}>`)}
```
* -7 bytes by Shaggy
```
; (function run() {
f=
(R,C,s)=>{for((w=x=>document.write(x))`<table cellspacing=0>`,i=0;i++<R;)for(w`<tr>`,j=0;j<C;)w(`<td bgcolor=#${((++j%i**s*16/R**s|0)*273).toString(16)}>`)}
R = /*R{*/500/*}*/;
C = /*C{*/800/*}*/;
s = /*s{*/0.8/*}*/;
document.write(`
<div style="margin-bottom: 10px;">
  <label> R = <input id="inputR" type="number" step="1" value="${R}" oninput="UpdateJS()" /></label><br />
  <label> C = <input id="inputC" type="number" step="1" value="${C}" oninput="UpdateJS()" /></label><br />
  <label> s = <input id="inputS" type="number" step="0.01" value="${s}" oninput="UpdateJS()" /></label><br />
  <form action="${location.href}" method="post">
    <input id="inputJs" type="hidden" name="js" />
    <input type="hidden" name="css" />
    <input type="hidden" name="html" />
    <input type="hidden" name="console" value="false" />
    <input type="hidden" name="babel" value="false" />
    <button type="submit">Draw</button>
  </form>
</div>
`)
f(R, C, s);
UpdateJS = function () {
  R = inputR.value;
  C = inputC.value;
  s = inputS.value;
  js = `; (${run}());`
    .replace(/\/\*R\{\*\/.*?\/\*\}\*\//, `/*R{*/${R}/*}*/`)
    .replace(/\/\*C\{\*\/.*?\/\*\}\*\//, `/*C{*/${C}/*}*/`)
    .replace(/\/\*s\{\*\/.*?\/\*\}\*\//, `/*s{*/${s}/*}*/`);
  inputJs.value = js;
};
UpdateJS();
}());
```
[Answer]
# [R](https://www.r-project.org/), 66 bytes
```
function(R,C,s)cat('P2',C,R,99,(99*outer(1:C,(1:R)^s,`%%`))%/%R^s)
```
[Try it online!](https://tio.run/##K/pfkJNfmp6RmhKflpmak2L7P600L7kkMz9PI0jHWadYMzmxREM9wEgdyAnSsbTU0bC01MovLUkt0jC0ctYBEkGaccU6CaqqCZqaqvqqQXHFmmhGapgaGOhYALGeheZ/AA "R – Try It Online")
I kinda think that [pajonk's answer](https://codegolf.stackexchange.com/a/231106/95126) is close to the shortest possible using [R](https://www.r-project.org/)'s built-in graphics... so here's a completely different approach, which actually turns-out to be 4 bytes shorter...
Outputs the contents of a greyscale [PGM file](https://en.wikipedia.org/wiki/Netpbm#PGM_example). At least on my laptop using Apple's 'Preview' program, the newline characters separating lines appear to be superfluous.
Here's Preview's display of the the output of `ploughed_field(500,800,.8)`:
[![enter image description here](https://i.stack.imgur.com/cGvef.png)](https://i.stack.imgur.com/cGvef.png)
[Answer]
# Python 3, 90 73 bytes
```
from pylab import*;ion()
def M(R,C,s):imshow(-~r_[:C]%c_[1:R+1]**s/R**s)
```
Heavily based on Danica's answer, I would have commented but I have 0 reputation.
Shorter import statement
`ion()` to show instead of `;show()`
`arange` (from `numpy.arange`) array approach for faster performance and fewer bytes
remove def function indent
```
   from pylab import* 
   ion()
   def M(R,C,s):imshow((arange(C)+1)%(arange(R)+1)[:,None]**s/R**s)
```
Thanks to ovs this shortens to 74 bytes
And a `-~` trick removes 1 byte from `r_[1:C+1]`
[Answer]
# [R](https://www.r-project.org/), ~~84~~ 70 bytes
*-14 bytes thanks to [@Dominic](https://codegolf.stackexchange.com/users/95126/dominic-van-essen)*
```
function(R,C,s)image(outer(1:C,(R:1)^s,`%%`)/R^s,c=rainbow(64),as=R/C)
```
[Try it online!](https://tio.run/##DcZLCoAgEADQ0wgzMKRCRQiuvIEHiEwyXKTgh45vLR68MoIeoSffYk5gyVDF@Lj7gtzbVUAqQ2CVxL3SwdiB3P7zuriYzvzCOiO5qi03OAIsQtD2E9OG4wM "R – Try It Online")
[Try it on rdrr.io with graphical output](https://rdrr.io/snippets/embed/?code=f%3D%0Afunction(R%2CC%2Cs)image(outer(1%3AC%2C(R%3A1)%5Es%2C%60%25%25%60)%2FR%5Es%2Cc%3Drainbow(64)%2Cas%3DR%2FC)%0Af(500%2C800%2C0.8))
[Answer]
# [Red](http://www.red-lang.org), 137 bytes
```
func[r c s][i: make image! to[]as-pair c r k: 0
repeat y r[repeat x c[i/(k: k + 1): to 1.1.1 to[](to 1 x %(y ** s)/(r ** s)* 255)]]?(i)]	
```
`f 500 800 0.8`
[![enter image description here](https://i.stack.imgur.com/JFB48.png)](https://i.stack.imgur.com/JFB48.png)
]