1

So, after 10 years of wanting to study the book that Ramanujan relied upon for a lot of his early strides in mathematics, it's 2012, and the book is finally online.

To celebrate, I want to go through each of the propositions using my command line, finding a way to interact with each one.

In octave syntax, first one is a^2 - b^2 = (a-b) * (a+b)

That's familiar from algebra, of course.

For now, I just want to be able to make a picture of this difference of squares.

I've looked at gnuplot, and it doesn't seem to be designed to do simple geometric shapes.

NB: I don't want to plot the function f(x, y) = x^2 - y^2. I want to draw two squares of a given size in different colors, one inside the other, to illustrate the difference of squares graphically.

What I'd like to be able to do is type something like

$plotsquare --center origin --colors=black,gray black=8x8 gray=3x3 -q -o plot.png

'black' being an 8x8 square, 9 being a 9x9 square; the gray square inside the black square illustrates the difference of squares.

Does anything like that exist?

2
  • Do you mean something like this: echo "set term png; splot x**2 - y**2 with pm3d" | gnuplot > plot.png
    – Thor
    Commented May 13, 2012 at 14:21
  • nope, i 'm not interested in plotting the function. i'm interested in drawing two squares in two colors, the lesser inside the perimeter of the greater one. so i amended the question to emphasize this.
    – ixtmixilix
    Commented May 13, 2012 at 16:51

1 Answer 1

1

Maybe you haven't found the right options to use in gnuplot. I was able to get the graph:

gnuplot> f(x,y) = (x-y)*(x+y)
gnuplot> set contour base
gnuplot> set cntrparam levels discrete 0.0
gnuplot> unset surface
gnuplot> set table 'curve.dat'
gnuplot> splot f(x,y)
gnuplot> unset table
gnuplot> set surface drawn
gnuplot> plot 'curve.dat' with lines

Play around with the options to get the type of plot you wish.

1
  • I'm not interested in the function at all; sorry. Please see edited question and comment above.
    – ixtmixilix
    Commented May 24, 2012 at 23:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .