Nothing
p <- c(sample(1:3, 1), sample(1:5, 1)) q <- c(sample((p[1] + 1):5, 1), sample(1:5, 1)) d <- abs(p - q) sol <- round(c(sum(d), sqrt(sum(d^2)), max(d)), digits = 3)
Given two points $p = (r p[1]
, r p[2]
)$ and
$q = (r q[1]
, r q[2]
)$ in a Cartesian coordinate system:
The distances are visualized below in green ($d_1$), red ($d_2$), and blue ($d_\infty$).
par(mar = c(4, 4, 1, 1)) plot(0, type = "n", xlim = c(0, 6), ylim = c(0, 6), xlab = "x", ylab = "y") grid(col = "slategray") if(d[1] >= d[2]) { lines(c(p[1], q[1]), c(q[2], q[2]) - 0.05, lwd = 2, col = "darkblue") } else { lines(c(p[1], p[1]) - 0.05, c(p[2], q[2]), lwd = 2, col = "darkblue") } lines(rbind(p, q), lwd = 2, col = "darkred") lines(c(p[1], p[1], q[1]), c(p[2], q[2], q[2]), lwd = 2, col = "darkgreen") points(rbind(p, q), pch = 19) text(rbind(p, q), c("p", "q"), pos = c(2, 4))
r p[1]
- r q[1]
| +
|r p[2]
- r q[2]
| = r sol[1]
$.r p[1]
-
r q[1]
)^2 + (r p[2]
- r q[2]
)^2} = r sol[2]
$.r p[1]
-
r q[1]
|, |r p[2]
- r q[2]
|) = r sol[3]
$.extype: cloze
exsolution: r sol[1]
|r sol[2]
|r sol[3]
exclozetype: num|num|num
exname: Distances
extol: 0.01
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.