randRange( 2, 10 )
randRangeNonZero( -10, 10 )
randRange( 2, 10 )
randRangeNonZero( 2, 10 )
fractionReduce( D - B, A - C )
(function() {
if ( ( D - B ) / ( A - C) > 0 ) {
return "<code>"
+ "x = "
+ fractionReduce( -1 * abs( D - B ), abs( A - C ) )
+ "\\text{ or }"
+ "x = "
+ fractionReduce( abs( D - B ), abs( A - C ) )
+ "</code>";
} else {
return "No solution";
}
})()
(function() {
var choices = [];
for ( var i = 0; i < 4; i++ ) {
var choice = "<code>";
var nOffset = randRange( 1, 10 );
var dOffset = randRangeExclude( 1, 10, [ C - A ] );
if ( D - B + nOffset === 0 ) {
choice += "x = 0";
} else {
choice += "x = "
+ fractionReduce( -1 * abs( D - B + nOffset ), abs( A - C + dOffset ) )
+ "\\text{ or }"
+ "x = "
+ fractionReduce( abs( D - B + nOffset ), abs( A - C + dOffset ) );
}
choice += "</code>";
choices.unshift( choice );
}
if ( ( D - B ) / ( A - C ) > 0 ) {
choices.shift();
choices.unshift( SOLUTION );
choices = shuffle( choices );
choices.push( "No solution");
} else {
choices = shuffle( choices );
choices.push( SOLUTION );
}
return choices;
})()
Solve for x
:
A|x| + B = C|x| + D
SOLUTION
Subtract C|x|
from both sides:
(A|x| + B) - C|x| = (C|x| + D) - C|x|
A - C|x| + B = D
B > 0 ? "Subtract" : "Add" abs(B)
B > 0 ? "from" : "to" both sides:
(A - C|x| + B) + -B = D + -B
A - C|x| = D - B
Divide both sides by A - C
.
\frac{A - C|x|}{A - C} = \frac{D - B}{A - C}
Simplify.
|x| = SIMPLIFIED
Subtract A|x|
from both sides:
(A|x| + B) - A|x| = (C|x| + D) - A|x|
B = C - A|x| + D
D > 0 ? "Subtract" : "Add" abs(D)
D > 0 ? "from" : "to" both sides:
B + -D = (C - A|x| + D) + -D
B - D = C - A|x|
Divide both sides by C - A
.
\frac{B - D}{C - A} = \frac{C - A|x|}{C - A}
Simplify.
SIMPLIFIED = |x|
Thus, the correct answer is SOLUTION
.
The absolute value cannot be negative. Therefore, there is no solution.