Meta-Calculator

Equation:

X name:

Y name:

X2Y:

Y2X:

In Geometron, everything is physical, everything is fractal, and everything is recursive. This means that when plotting on a computer the units are those of the computer screen, either pixels, inches, cm, or fraction of the screen or of the canvas. Mathematically if we are plotting a 2d curve, this formally is a function: $$f:\mathbb{R}\longmapsto [0,\mathrm{canvas width}] \times [0,\mathrm{canvas height}].$$ Technically, this is true in any language that plots on a computer. But in Geometron we must always do this explicitly, meaning that to plot a function we must find the maps that connect that function to a map of the above form always.

Also, following the law of Geometron that "everything is fractal", what this means in the case of plotting is that building a "generalize plotter" is never the goal--specificity to our task is paramount, and we can tailor the code and hardware as needed to satisfy that exact task.

As an example we shall now study the Lorentzian as it is called in physics, also known as the Witch of Agnesi.

To begin with we will define the curve by its simplest and most generic form in terms of an abstract "x" and "y": $$y = \frac{1}{1 + x^2}$$. To study the area under this curve we will evaluate the integral by substitution, with $$x \equiv \tan{\theta}$$ so that $$dx = (1 + \tan^2{\theta})d\theta$$ and $$\int \frac{dx}{1 + x^2} = \int \frac{(1 + \tan^2{\theta})d\theta}{(1 + \tan^2{\theta})} = \int d\theta = \theta = \arctan{x}$$ So that over all real numbers we get $$\int_{-\infty}^{\infty}\frac{dx}{1 + x^2} = \arctan{\infty} - \arctan{-\infty} = \pi$$ We can see by inspection that the peak is at x=0 and y=1. The full width half maximum of this, or the 3 dB point if we're working with waves is when $$\frac{1}{x^2 + 1} = \frac{1}{2}$$ or $$x^2 + 1 = 2$$ so the values are $\pm 1$. The area preserving(with unit area) function with variable width and peak position is $$f(x) = \frac{1}{\pi\gamma}\frac{\gamma^2}{(x - x_0)^2 + \gamma^2}$$
We will now consider how to put this on a canvas in html. The parameters are now a peak position in pixels(call this x0), a asymptotic y value in pixels(call this y0), a peak height in pixels(A), and a peak width in pixels ($\Gamma$). All this is complicated by the fact that in a canvas, vertical values are inverted relative to anything else in math. Perhaps the simplest way to deal with this is to let peak heights be negative by default and keep track of it that way. $$y(x) = y0 + A\frac{\Gamma^2}{(x-x_0)^2 + \Gamma^2}.$$ Now an important point must be raised: that pixels are usually not what matters and that how we plot things should be an aesthetic, nota mathematical decision. The numbers don't change by how we plot them, only our picture changes. So to start off, x0 should be canvas width/2. y0 should be canvas height - (some small fraction of canvas height). If we can guess what they are, A should then be about that same small fraction of canvas height, or maybe twice that. Perhaps 10 percent for the bottom and 20% for the top. And width of also 20%. So that $\Gamma$ is 0.2 times canvas width by default(then changed as the numbers change but this is a base point in parameter space).
The curve on the canvas consists of line segments between points. The number of points is the width + 1, and it's the same for x and y points. The number of segments is equal to the width(in pixels). One pixel is one point, for simplicity. So a for loop should run from zero to(not inclusive) width, making width number of segments between width+1 points. X values will simply be the index value and index value plus 1. Y values will be y(x) for those points.
for(var index = 0;index < width;index++){
	x1 = index;
	y1 = f(x);
	x2 = x1+1;
	y2 = f(x1+1);
	//draw a line from (x1,y1) to (x2,y2)
}

	
$\Gamma$ =
Next we must annotate this in a rational and controllable way. Namely the peak value, and full width half maximum must be marked in a way that looks good.
Other tasks:
Consider a series LRC resonator connected to a 50 Ohm line. $$Z = R + i\omega L + \frac{1}{i\omega C}$$ $$S_{11} = \frac{Z_0 - Z}{Z_0 + Z}$$

$$y = \frac{\Gamma^2}{(x-x_0)^2 + \Gamma^2}$$