Make LineRenderer from one Vector3 to another Vector3?

I made a graphing calculator and I want to connect the points that are spawned with a LineRenderer.

I have this function that I want call the line with:

void DrawLine(Vector3 a, Vector3 b) {
    // Code to draw line from a to b
}

I’ve read a lot about it, but I’m still really confused as to how to do it.

LineRenderer lr = GetComponent();
Color startColor = Color.green;
Color endcolor = Color.red;
float startLineWidth = 0.5f;
float endLineWidth = 2.0f;

Vector3 pos1;
Vector3 pos2;

lr.enabled = true;
	lr.SetVertexCount(2);
	lr.SetPosition(0, pos1);
	lr.SetPosition(1, pos2);
	lr.SetWidth(startLineWidth, endLineWidth );
	lr.SetColors(startColor, endcolor );