How do I assign a variable/function to a line?

So, I finally made a graph to make a line with 2 points and now I want to make it a function so that I can use it more conveniently, but when I try putting parenthesis() around the graph, it throws me an error. Then I try to put it in a piecewise expression{} with the condition being ‘1=1’ [so that it will always work], it does not throw me an error, but now when I try to run the function, it instead outputs me a number.

Am I doing this the wrong way, and there is another way, or is it that it is not possible?

I think it depends on what you want to do. For example, if you just want to graph lines based on a set of points, you can turn your P1 and P2 into lists of points like P1 = [(2,3),(4,0)]. This will apply your equation to each point in the lists in turn.

I was actually asking that I’ve got a graph, let’s say (for simplicity), a parabola. Now I want to be able to make a function so that when i run it, it gives out the graph.

If I understand you correctly, I think the problem is that a function can only return things like numbers, lists, and points, but not an equation. But you can almost always use those tools to do what you want. Can you provide a graph with a starter and then some more details about what you want it to do? There may be another approach to accomplish your goal.

Oh, wait. I get it now. I can make a function for usually y like:

f(x,a_1,a_2) = x+(a_1).x

And if you do:

f(x, v_1, v_2)

It will make a graph with y bieng the value.
For good measure, add y = to the start.