Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

117 lines (103 sloc) 3.141 kB
<!DOCTYPE html>
<html data-require="math matrix">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Scalar matrix multiplication</title>
<script src="../khan-exercise.js"></script>
<style>
#answer_area .row input[type=text] {
width: 40px;
margin-right: 5px;
}
#answer_area .row {
margin: 0;
}
</style>
</head>
<body>
<div class="exercise">
<div class="vars">
<var id="MAT_A">randRange(-2, 4, ROWS, COLS)</var>
<var id="SCALAR">randRange(-5, 5)</var>
<var id="OPERATION">"\\times"</var>
<var id="SOLN_MAT">
deepZipWith(2, function(a) {
return a * SCALAR;
}, MAT_A)
</var>
<var id="MAT_A_COLOR">BLUE</var>
<var id="SCALAR_COLOR">GREEN</var>
<var id="SOLN_MAT_COLOR">PINK</var>
<var id="PRETTY_MAT_A">
printSimpleMatrix(MAT_A, MAT_A_COLOR)
</var>
<var id="PRETTY_HINT_MAT">
printMatrix(function(a) {
var s = colorMarkup(SCALAR, SCALAR_COLOR);
var b = colorMarkup(a, MAT_A_COLOR);
return s + OPERATION + b;
}, MAT_A)
</var>
<var id="PRETTY_SOLN_MAT">
printSimpleMatrix(SOLN_MAT, SOLN_MAT_COLOR)
</var>
</div>
<div class="question">
<code>
\Large{
\color{<var>SCALAR_COLOR</var>}{<var>SCALAR</var>}
<var>OPERATION</var>
<var>PRETTY_MAT_A</var> = {?}
}
</code>
</div>
<div class="hints">
<div>
<p>To multiply a matrix by a number, multiply each item of the matrix by the number.</p>
<div>
<code>\Large{<var>PRETTY_HINT_MAT</var>}</code>
</div>
</div>
<div>
<p>Now, simplify:</p>
<div>
<code>\Large{<var>PRETTY_SOLN_MAT</var>}</code>
</div>
</div>
</div>
<div class="solution" data-type="multiple">
<p data-each="SOLN_MAT as row" class="row">
<span data-each="row as elem" class="sol">
<var>elem</var>
</span>
</p>
</div>
<div class="problems">
<div id="2x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">2</var>
</div>
</div>
<div id="2x3">
<div class="vars" data-apply="prependVars">
<var id="ROWS">2</var>
<var id="COLS">3</var>
</div>
</div>
<div id="3x1">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">1</var>
</div>
</div>
<div id="3x2">
<div class="vars" data-apply="prependVars">
<var id="ROWS">3</var>
<var id="COLS">2</var>
</div>
</div>
</div>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.