Desmos, 207 characters
Try it online!
Organized for readability
Code:
<input 1>
<input 2>
<input 3>
a=ans_0
b=ans_1
c=ans_2
m=-(a+b)/2 #Parenthesises placed here to show that addition occurs before addition; they don't appear in actual graph
d=-((a-m)^2-c)
l=[a,a+m,(a+m)^2,(a+m)^2+d]
l_1=[b,b+m,(b+m)^2,(b+m)^2+d]
(-1,[0,-1,-2,-3])
(0,[0,-1,-2,-3])
(1,[0,-1,-2,-3])
(4,0)
(4,-1)
(4,-2)
(4,-3)
#LABELS (From higher to lower)
${l}
=
${l_1}
(given)
(${m})
(`^2`)
(${d})
Explanation:
a
and b
are the starting numbers, and c
is the target number. Like my other programs, ans_n
correspond to the line number, acting as inputs.
m
is the midpoint of a
and b
. The reason that it is subtracted from a
and b
is so that they become equidistant from 0. NOTE: m
is negative simply for formatting the proof; simply treat it as a positive and that all operations involving it are subtractions.
d
is simply the distance between c
and (a-m)^2
. The squaring ensures that the term is positive, making both sides of the equation equal to each other. From there, the distance is added on to the result, making both sides of the equation equal to c
.
l
and l_1
are lists. This is used to provide the labels. From left to right, the terms in the lists are as follows: the input, the input minus m
, the square of (the input minus m
), and the square of (the input minus m
) plus d
.
The first point, (-1,[0,-1,-2,-3])
, uses ${l}
as a label. The list within the point creates multiple copies of the point at those y values, and the label uses the corresponding value from l
to make it have the corresponding value on the graph. For example, (-1,0)
would have a
as its label. Likewise, the third point, (1,[0,-1,-2,-3])
, would use l_1
to produce its labels in a similar manner. The second point, however, would simply have the label be =
.
Point (4,0)
has the label (given)
, which is self explanatory.
Point (4,-1)
has the label (${m})
, which uses m
to produce the label of (m)
.
Point (4,-2)
has the label (`^2`)
. The backticks are used to format the ^2
as a square and not as ^2
.
Point (4,-3)
has the label (${d})
, which uses d
to produce the label of (d)
.
a=b
as input you can always do the stepsa=b;2a=2b (*2); a-b=b-a (-(a+b));a^2-2ab+b2=a^2-2ab+b2 (^2)
. Sometimes you can do faster but there is not much reason to do anything more complex than(*2)->(-(a+b))->(^2)
. \$\endgroup\$