Kevin Donnelly later wrote:
No, he's already done the coursework, which involved plotting actual results by hand - he's in year 4 secondary, so least squares would be a bit beyond them! The above is for the conclusions part, where he wants to say something like "if you change a, b might change as follows". He can just extrapolate the curve manually on the graph paper, but I thought there might be something that could do that more neatly.
Depends what you mean by "neatly". If he's doing it by hand
anyway, then simply drawing a longer line with the ruler
is just as neat as the line he drew in the first place!
However, if you're looking for an approach which in some
sense calculates the extrapolation, rather than simply draws
it (so if "neater" in the sense of "cleaner"), then you are
entering the territory of least squares and all that!
That being said, when it comes to drawing graphs and diagrams
in the midst of nicely formatted text, don't ignore what's
been available in Linux (and indeed Unix) since the year dot
(which in the case of Unix is 1970). Namely the 'groff' package,
which is what's used for producing the formatted man pages,
but is capable of much much fancier stuff than that.
As an example (which makes use of the 'pic' component of groff),
oriented towards your query:
1. Make a text file containing the data on resistance (col 1)
and voltage (col 2) as follows:
50 4.9
55 5.5
60 5.6
65 7.0
70 6.9
75 7.6
80 7.9
85 8.5
90 8.7
95 9.1
100 10.0
and call this file "data.txt" (only the above numbers, and
no blank lines).
2. Make a text file containing the following text:
.LP
Here is my graph of Voltage versus Resistance.
.PS
circrad=0.5
yscale=5
start=1
define blob {
circle radius circrad at ($1,$2*yscale)
}
x0=0 ; y0=0; x1=0; y1=0
define lines {
if start then {
x0=$1 ; y0=$2*yscale ; x1=x0; y1=y0
start=0
} else {
x0=x1 ; y0=y1 ; x1=$1 ; y1=$2*yscale
line from (x0,y0) to (x1,y1)
}
}
.PE
.PS 4i
copy "data.txt" thru blob
copy "data.txt" thru lines
line from (0,0) to (150,0) "" "" "" "" "" "\fBResistance\fP"
for i=0 to 15 do {
r=10*i
line from (r,0) to (r,-0.2*yscale)
"" "" sprintf("%.0f",r) at end of last line
}
line from (0,0) to (0,16*yscale)
for i=0 to 8 do {
v=2*i
line from (0,v*yscale) to (-2,v*yscale)
sprintf("%.0f ",v) rjust at end of last line
}
line invis from (-15,0) to (-15,16*yscale) "\fBVoltage\fP" aligned
dashwid=2
line dashed from (0,0.2*yscale) to (150,14.7*yscale)
.PE
.sp 3
.LP
The dashed line was drawn by eye through the experimental data.
It can be used for extrapolation.
However, it does not go through the origin, which it should!
and call this file "physics_ex.tr"
3. Now, on any Linux system, execute the command
groff -p physics_ex.tr > physics_ex.ps
and you will have a PostScript file with a very nice diagram in it.
If you want neat, this gives you neat!
The key to the plotting of the data points is the "copy thru"
command, which in its first instance plots the points from the data
file, and in the second instance draws the lines joining the points.
Then there's a dashed line through two points which the student
could have read off from graph paper having drawn a line by eye
with a ruler.
All the rest is furniture.
The above may look formidable at first sight, but it's not nearly
as bad as it looks when you get down to it (provided you get the
syntax right). In fact, it's not a hundred miles from the good
old Turtle Graphics which some of us might remember!
In the past I've used this sort of thing with schoolchildren.
For example with a 14-year-old who was by no means a mathemtician,
and had been set a project task of designing a cut cardboard
shape which was to be folded into a box with a lid, with folding
tabs to glue the whole thing together.
Once I'd set up the basic framework on similar lines to the above,
the rest was a matter of choosing the numbers so as to produce
a good result, and the child progressively caught on to the
idea of using numbers (x,y) for the position of a point, and
then to composing the elements of an object using such points
(i.e. the rectangles for the sides and lid etc., and trapezoidal
shapes for the folding tags, and putting these in the right
positions); so in fact picked up a bit of coordinate geometry
on the side!
Best wsihes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding)