Another way to write equation of the line passing through two points? [closed]












2












$begingroup$


I am trying to write equation of the line passing through two points pA={1, -3} and pB={-33, -1} in the form x+17 y+50=0. I tried



{pA, pB} = {{1, -3}, {-33, -1}};
u = pB - pA;
m = {x, y};
v = m - pA;
d = Det[{u, v}];
w = {Coefficient[d, x], Coefficient[d, y]};
k = GCD[Coefficient[d, x], Coefficient[d, y]];
If[w[[1]] != 0, n = Sign[w[[1]]] w/k,
If[w[[2]] != 0, n = Sign[w[[2]]] w/k]];
TraditionalForm[Expand[n.v]] == 0


I got




x+17 y+50==0




Is there another way to write it?










share|improve this question











$endgroup$



closed as unclear what you're asking by march, José Antonio Díaz Navas, m_goldberg, Bob Hanlon, Sumit Nov 22 '18 at 19:46


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


















  • $begingroup$
    Write or solve?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:39










  • $begingroup$
    @Kuba Write the equation of the line passing through two points.
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:43






  • 1




    $begingroup$
    Isn't 17 x-y-20==0 already in that form?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:51










  • $begingroup$
    Yes. My question is "is there another way to write the equation in that form?"
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:53






  • 1




    $begingroup$
    You can multiply sides by a constant but I fail to see how it is a Mathematica question.
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:58
















2












$begingroup$


I am trying to write equation of the line passing through two points pA={1, -3} and pB={-33, -1} in the form x+17 y+50=0. I tried



{pA, pB} = {{1, -3}, {-33, -1}};
u = pB - pA;
m = {x, y};
v = m - pA;
d = Det[{u, v}];
w = {Coefficient[d, x], Coefficient[d, y]};
k = GCD[Coefficient[d, x], Coefficient[d, y]];
If[w[[1]] != 0, n = Sign[w[[1]]] w/k,
If[w[[2]] != 0, n = Sign[w[[2]]] w/k]];
TraditionalForm[Expand[n.v]] == 0


I got




x+17 y+50==0




Is there another way to write it?










share|improve this question











$endgroup$



closed as unclear what you're asking by march, José Antonio Díaz Navas, m_goldberg, Bob Hanlon, Sumit Nov 22 '18 at 19:46


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


















  • $begingroup$
    Write or solve?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:39










  • $begingroup$
    @Kuba Write the equation of the line passing through two points.
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:43






  • 1




    $begingroup$
    Isn't 17 x-y-20==0 already in that form?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:51










  • $begingroup$
    Yes. My question is "is there another way to write the equation in that form?"
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:53






  • 1




    $begingroup$
    You can multiply sides by a constant but I fail to see how it is a Mathematica question.
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:58














2












2








2





$begingroup$


I am trying to write equation of the line passing through two points pA={1, -3} and pB={-33, -1} in the form x+17 y+50=0. I tried



{pA, pB} = {{1, -3}, {-33, -1}};
u = pB - pA;
m = {x, y};
v = m - pA;
d = Det[{u, v}];
w = {Coefficient[d, x], Coefficient[d, y]};
k = GCD[Coefficient[d, x], Coefficient[d, y]];
If[w[[1]] != 0, n = Sign[w[[1]]] w/k,
If[w[[2]] != 0, n = Sign[w[[2]]] w/k]];
TraditionalForm[Expand[n.v]] == 0


I got




x+17 y+50==0




Is there another way to write it?










share|improve this question











$endgroup$




I am trying to write equation of the line passing through two points pA={1, -3} and pB={-33, -1} in the form x+17 y+50=0. I tried



{pA, pB} = {{1, -3}, {-33, -1}};
u = pB - pA;
m = {x, y};
v = m - pA;
d = Det[{u, v}];
w = {Coefficient[d, x], Coefficient[d, y]};
k = GCD[Coefficient[d, x], Coefficient[d, y]];
If[w[[1]] != 0, n = Sign[w[[1]]] w/k,
If[w[[2]] != 0, n = Sign[w[[2]]] w/k]];
TraditionalForm[Expand[n.v]] == 0


I got




x+17 y+50==0




Is there another way to write it?







output-formatting geometry






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 '18 at 23:09







minhthien_2016

















asked Nov 19 '18 at 8:37









minhthien_2016minhthien_2016

566310




566310




closed as unclear what you're asking by march, José Antonio Díaz Navas, m_goldberg, Bob Hanlon, Sumit Nov 22 '18 at 19:46


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









closed as unclear what you're asking by march, José Antonio Díaz Navas, m_goldberg, Bob Hanlon, Sumit Nov 22 '18 at 19:46


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.














  • $begingroup$
    Write or solve?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:39










  • $begingroup$
    @Kuba Write the equation of the line passing through two points.
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:43






  • 1




    $begingroup$
    Isn't 17 x-y-20==0 already in that form?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:51










  • $begingroup$
    Yes. My question is "is there another way to write the equation in that form?"
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:53






  • 1




    $begingroup$
    You can multiply sides by a constant but I fail to see how it is a Mathematica question.
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:58


















  • $begingroup$
    Write or solve?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:39










  • $begingroup$
    @Kuba Write the equation of the line passing through two points.
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:43






  • 1




    $begingroup$
    Isn't 17 x-y-20==0 already in that form?
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:51










  • $begingroup$
    Yes. My question is "is there another way to write the equation in that form?"
    $endgroup$
    – minhthien_2016
    Nov 19 '18 at 8:53






  • 1




    $begingroup$
    You can multiply sides by a constant but I fail to see how it is a Mathematica question.
    $endgroup$
    – Kuba
    Nov 19 '18 at 8:58
















$begingroup$
Write or solve?
$endgroup$
– Kuba
Nov 19 '18 at 8:39




$begingroup$
Write or solve?
$endgroup$
– Kuba
Nov 19 '18 at 8:39












$begingroup$
@Kuba Write the equation of the line passing through two points.
$endgroup$
– minhthien_2016
Nov 19 '18 at 8:43




$begingroup$
@Kuba Write the equation of the line passing through two points.
$endgroup$
– minhthien_2016
Nov 19 '18 at 8:43




1




1




$begingroup$
Isn't 17 x-y-20==0 already in that form?
$endgroup$
– Kuba
Nov 19 '18 at 8:51




$begingroup$
Isn't 17 x-y-20==0 already in that form?
$endgroup$
– Kuba
Nov 19 '18 at 8:51












$begingroup$
Yes. My question is "is there another way to write the equation in that form?"
$endgroup$
– minhthien_2016
Nov 19 '18 at 8:53




$begingroup$
Yes. My question is "is there another way to write the equation in that form?"
$endgroup$
– minhthien_2016
Nov 19 '18 at 8:53




1




1




$begingroup$
You can multiply sides by a constant but I fail to see how it is a Mathematica question.
$endgroup$
– Kuba
Nov 19 '18 at 8:58




$begingroup$
You can multiply sides by a constant but I fail to see how it is a Mathematica question.
$endgroup$
– Kuba
Nov 19 '18 at 8:58










6 Answers
6






active

oldest

votes


















6












$begingroup$

Simplify[y - InterpolatingPolynomial[{pA, pB}, x] == 0]



50 + x + 17 y == 0




Also



Simplify[y - a x - b == 0 /. First@Solve[a # + b == #2 & @@@ {pA, pB}, {a, b}]]



50 + x + 17 y == 0




And



Simplify @ Rationalize[y - Fit[{pA, pB}, {x, 1}, x] == 0]



50 + x + 17 y == 0







share|improve this answer











$endgroup$





















    4












    $begingroup$

    You may do as follows. Let us look for the equation in the form ax+by==1, where the parameters a and b are to be found.This will substitute the coordinates of the points pA and pB into this equations, thus, forming two equations with respect to a and b and solves the system:



    eq = a*#[[1]] + b*#[[2]] == 1 &;
    eq1=eq /@ {{1, -3}, {-33, -1}}

    (* {a - 3 b == 1, -33 a - b == 1} *)


    This will substitute the solution into the linear equation already in coordinates x and y:



    eq[{x, y}] /. sol

    (* -(x/50) - (17 y)/50 == 1 *)


    This will plot the solution:



    Show[{
    ContourPlot[-(x/50) - (17 y)/50 == 1, {x, -34, 2}, {y, -4, 0}],
    Graphics[{Red, PointSize[0.015], Point[#] & /@ {{1, -3}, {-33, -1}}}]
    }]


    yielding the following plot:



    enter image description here



    The original points are shown in red.



    This is one of several possible ways.



    Have fun!






    share|improve this answer









    $endgroup$





















      4












      $begingroup$

      The equation of a planar line going through two points $ P_1(x_1,y_1) $ and $ P_2(x_2,y_2) $ (e.g. cf this for reference) is



      $$
      begin{vmatrix}
      x & y\
      x_2-x_1 & y_2-y_1
      end{vmatrix}
      =
      begin{vmatrix}
      x_1 & y_1\
      x_2 & y_2
      end{vmatrix}.
      $$



      So there is the piece of codes below:



      Clear[eq, pts]
      eq = Simplify[Det[{{x, y}, -Subtract @@ #}] == Det[#]] &;
      pts = {{1, -3}, {-33, -1}};
      eq[pts]



      50 + x + 17 y == 0





      Or



      eq2 = Simplify[Det[{-1, 1} Differences[Prepend[#, {x, y}]]] == 0] &;





      share|improve this answer











      $endgroup$













      • $begingroup$
        If pts = {{1, -3}, {-33, 150}} How can I get the form 9 x+2 y-3=0 . Your code ouput 9 x+2 y==3 Allways in the form a x + b y + c==0, a>0, if a=0, then b >0`.
        $endgroup$
        – minhthien_2016
        Nov 19 '18 at 12:18












      • $begingroup$
        @minhthien_2016 Sort of eq[pts] /. a_ == b_ :> a - b == 0, though I think it just a minor issue.
        $endgroup$
        – Αλέξανδρος Ζεγγ
        Nov 19 '18 at 13:04










      • $begingroup$
        Thank you very much.
        $endgroup$
        – minhthien_2016
        Nov 19 '18 at 13:46










      • $begingroup$
        Another way : Det[{{x - #1[[1]], y - #1[[2]]}, {x - #2[[1]], y - #2[[2]]}}] == 0 & @@ {{1, -3}, {-33, -1}} // Simplify
        $endgroup$
        – Sigis K
        Nov 20 '18 at 23:16












      • $begingroup$
        @SigisK Yes, it is.
        $endgroup$
        – Αλέξανδρος Ζεγγ
        Nov 21 '18 at 4:12



















      4












      $begingroup$

      With RegionMember:



      Simplify[RegionMember[InfiniteLine[{{1, -3}, {-33, -1}}], {x, y}], 
      Element[x | y, Reals]]



      50 + x + 17 y == 0







      share|improve this answer









      $endgroup$





















        2












        $begingroup$

        Knowing that the coefficients are components of a vector perpendicular to the difference of the two points, I think the most convenient command to obtain the equation is



        perp = Cross[pB - pA];
        perp.{x, y} == perp.pA // Simplify



        50 + x + 17 y == 0




        The last step before Simplify is



        -2 x - 34 y == 100


        so you can see that the simplification brought all terms to one side, factored out the greatest common divisor and fixed the signs.



        To Mathematica the sums "50 + x + 17y" and "x + 17y + 50" are exactly the same expression, but if you want to order linear terms before constants in the displayed form, you may consider using TraditionalForm (with the added benefit of using a "normal" equality sign while remaining copy-and-pastable):



        % // TraditionalForm



        $x+17 y+50=0$







        share|improve this answer









        $endgroup$













        • $begingroup$
          Ad sign of the x coefficient: I don't know of any trick simpler than multiply the result by –1 if you don't like it.
          $endgroup$
          – The Vee
          Nov 19 '18 at 13:26



















        1












        $begingroup$

        Although this might be more a math question, the ingenious answers have taught me a lot about MMA. Thanks to all contributors. I can add an answer based on my high school Analytical Geometry classes. The mnemonic two-point form of the equation of a straight line through A(x1,y1) and B(x2,y2) is



        enter image description here



        Using the coordinates for pA and pB given in the question:



        Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
        y2 - y1) == (x - x1)/(x2 - x1)] // TraditionalForm


        gives



        enter image description here



        However the more 'symmetrical form' of the equation leads to an answer that is mathematically identical, but is not in the required form. Does anybody know how to force MMA to yield the required form?



        Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
        x - x1) == (y2 - y1)/(x2 - x1)] // TraditionalForm


        gives



        enter image description here






        share|improve this answer









        $endgroup$













        • $begingroup$
          I think, we can write in the form Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)* (x2 - x1) - (x - x1)*(y2 - y1) == 0] // TraditionalForm
          $endgroup$
          – minhthien_2016
          Nov 21 '18 at 6:29










        • $begingroup$
          My way is almost write the equations in the form a x + b y + c = 0.
          $endgroup$
          – minhthien_2016
          Nov 21 '18 at 6:48


















        6 Answers
        6






        active

        oldest

        votes








        6 Answers
        6






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        6












        $begingroup$

        Simplify[y - InterpolatingPolynomial[{pA, pB}, x] == 0]



        50 + x + 17 y == 0




        Also



        Simplify[y - a x - b == 0 /. First@Solve[a # + b == #2 & @@@ {pA, pB}, {a, b}]]



        50 + x + 17 y == 0




        And



        Simplify @ Rationalize[y - Fit[{pA, pB}, {x, 1}, x] == 0]



        50 + x + 17 y == 0







        share|improve this answer











        $endgroup$


















          6












          $begingroup$

          Simplify[y - InterpolatingPolynomial[{pA, pB}, x] == 0]



          50 + x + 17 y == 0




          Also



          Simplify[y - a x - b == 0 /. First@Solve[a # + b == #2 & @@@ {pA, pB}, {a, b}]]



          50 + x + 17 y == 0




          And



          Simplify @ Rationalize[y - Fit[{pA, pB}, {x, 1}, x] == 0]



          50 + x + 17 y == 0







          share|improve this answer











          $endgroup$
















            6












            6








            6





            $begingroup$

            Simplify[y - InterpolatingPolynomial[{pA, pB}, x] == 0]



            50 + x + 17 y == 0




            Also



            Simplify[y - a x - b == 0 /. First@Solve[a # + b == #2 & @@@ {pA, pB}, {a, b}]]



            50 + x + 17 y == 0




            And



            Simplify @ Rationalize[y - Fit[{pA, pB}, {x, 1}, x] == 0]



            50 + x + 17 y == 0







            share|improve this answer











            $endgroup$



            Simplify[y - InterpolatingPolynomial[{pA, pB}, x] == 0]



            50 + x + 17 y == 0




            Also



            Simplify[y - a x - b == 0 /. First@Solve[a # + b == #2 & @@@ {pA, pB}, {a, b}]]



            50 + x + 17 y == 0




            And



            Simplify @ Rationalize[y - Fit[{pA, pB}, {x, 1}, x] == 0]



            50 + x + 17 y == 0








            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 19 '18 at 9:32

























            answered Nov 19 '18 at 9:03









            kglrkglr

            183k10202417




            183k10202417























                4












                $begingroup$

                You may do as follows. Let us look for the equation in the form ax+by==1, where the parameters a and b are to be found.This will substitute the coordinates of the points pA and pB into this equations, thus, forming two equations with respect to a and b and solves the system:



                eq = a*#[[1]] + b*#[[2]] == 1 &;
                eq1=eq /@ {{1, -3}, {-33, -1}}

                (* {a - 3 b == 1, -33 a - b == 1} *)


                This will substitute the solution into the linear equation already in coordinates x and y:



                eq[{x, y}] /. sol

                (* -(x/50) - (17 y)/50 == 1 *)


                This will plot the solution:



                Show[{
                ContourPlot[-(x/50) - (17 y)/50 == 1, {x, -34, 2}, {y, -4, 0}],
                Graphics[{Red, PointSize[0.015], Point[#] & /@ {{1, -3}, {-33, -1}}}]
                }]


                yielding the following plot:



                enter image description here



                The original points are shown in red.



                This is one of several possible ways.



                Have fun!






                share|improve this answer









                $endgroup$


















                  4












                  $begingroup$

                  You may do as follows. Let us look for the equation in the form ax+by==1, where the parameters a and b are to be found.This will substitute the coordinates of the points pA and pB into this equations, thus, forming two equations with respect to a and b and solves the system:



                  eq = a*#[[1]] + b*#[[2]] == 1 &;
                  eq1=eq /@ {{1, -3}, {-33, -1}}

                  (* {a - 3 b == 1, -33 a - b == 1} *)


                  This will substitute the solution into the linear equation already in coordinates x and y:



                  eq[{x, y}] /. sol

                  (* -(x/50) - (17 y)/50 == 1 *)


                  This will plot the solution:



                  Show[{
                  ContourPlot[-(x/50) - (17 y)/50 == 1, {x, -34, 2}, {y, -4, 0}],
                  Graphics[{Red, PointSize[0.015], Point[#] & /@ {{1, -3}, {-33, -1}}}]
                  }]


                  yielding the following plot:



                  enter image description here



                  The original points are shown in red.



                  This is one of several possible ways.



                  Have fun!






                  share|improve this answer









                  $endgroup$
















                    4












                    4








                    4





                    $begingroup$

                    You may do as follows. Let us look for the equation in the form ax+by==1, where the parameters a and b are to be found.This will substitute the coordinates of the points pA and pB into this equations, thus, forming two equations with respect to a and b and solves the system:



                    eq = a*#[[1]] + b*#[[2]] == 1 &;
                    eq1=eq /@ {{1, -3}, {-33, -1}}

                    (* {a - 3 b == 1, -33 a - b == 1} *)


                    This will substitute the solution into the linear equation already in coordinates x and y:



                    eq[{x, y}] /. sol

                    (* -(x/50) - (17 y)/50 == 1 *)


                    This will plot the solution:



                    Show[{
                    ContourPlot[-(x/50) - (17 y)/50 == 1, {x, -34, 2}, {y, -4, 0}],
                    Graphics[{Red, PointSize[0.015], Point[#] & /@ {{1, -3}, {-33, -1}}}]
                    }]


                    yielding the following plot:



                    enter image description here



                    The original points are shown in red.



                    This is one of several possible ways.



                    Have fun!






                    share|improve this answer









                    $endgroup$



                    You may do as follows. Let us look for the equation in the form ax+by==1, where the parameters a and b are to be found.This will substitute the coordinates of the points pA and pB into this equations, thus, forming two equations with respect to a and b and solves the system:



                    eq = a*#[[1]] + b*#[[2]] == 1 &;
                    eq1=eq /@ {{1, -3}, {-33, -1}}

                    (* {a - 3 b == 1, -33 a - b == 1} *)


                    This will substitute the solution into the linear equation already in coordinates x and y:



                    eq[{x, y}] /. sol

                    (* -(x/50) - (17 y)/50 == 1 *)


                    This will plot the solution:



                    Show[{
                    ContourPlot[-(x/50) - (17 y)/50 == 1, {x, -34, 2}, {y, -4, 0}],
                    Graphics[{Red, PointSize[0.015], Point[#] & /@ {{1, -3}, {-33, -1}}}]
                    }]


                    yielding the following plot:



                    enter image description here



                    The original points are shown in red.



                    This is one of several possible ways.



                    Have fun!







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 19 '18 at 9:17









                    Alexei BoulbitchAlexei Boulbitch

                    21.5k2470




                    21.5k2470























                        4












                        $begingroup$

                        The equation of a planar line going through two points $ P_1(x_1,y_1) $ and $ P_2(x_2,y_2) $ (e.g. cf this for reference) is



                        $$
                        begin{vmatrix}
                        x & y\
                        x_2-x_1 & y_2-y_1
                        end{vmatrix}
                        =
                        begin{vmatrix}
                        x_1 & y_1\
                        x_2 & y_2
                        end{vmatrix}.
                        $$



                        So there is the piece of codes below:



                        Clear[eq, pts]
                        eq = Simplify[Det[{{x, y}, -Subtract @@ #}] == Det[#]] &;
                        pts = {{1, -3}, {-33, -1}};
                        eq[pts]



                        50 + x + 17 y == 0





                        Or



                        eq2 = Simplify[Det[{-1, 1} Differences[Prepend[#, {x, y}]]] == 0] &;





                        share|improve this answer











                        $endgroup$













                        • $begingroup$
                          If pts = {{1, -3}, {-33, 150}} How can I get the form 9 x+2 y-3=0 . Your code ouput 9 x+2 y==3 Allways in the form a x + b y + c==0, a>0, if a=0, then b >0`.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 12:18












                        • $begingroup$
                          @minhthien_2016 Sort of eq[pts] /. a_ == b_ :> a - b == 0, though I think it just a minor issue.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 19 '18 at 13:04










                        • $begingroup$
                          Thank you very much.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 13:46










                        • $begingroup$
                          Another way : Det[{{x - #1[[1]], y - #1[[2]]}, {x - #2[[1]], y - #2[[2]]}}] == 0 & @@ {{1, -3}, {-33, -1}} // Simplify
                          $endgroup$
                          – Sigis K
                          Nov 20 '18 at 23:16












                        • $begingroup$
                          @SigisK Yes, it is.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 21 '18 at 4:12
















                        4












                        $begingroup$

                        The equation of a planar line going through two points $ P_1(x_1,y_1) $ and $ P_2(x_2,y_2) $ (e.g. cf this for reference) is



                        $$
                        begin{vmatrix}
                        x & y\
                        x_2-x_1 & y_2-y_1
                        end{vmatrix}
                        =
                        begin{vmatrix}
                        x_1 & y_1\
                        x_2 & y_2
                        end{vmatrix}.
                        $$



                        So there is the piece of codes below:



                        Clear[eq, pts]
                        eq = Simplify[Det[{{x, y}, -Subtract @@ #}] == Det[#]] &;
                        pts = {{1, -3}, {-33, -1}};
                        eq[pts]



                        50 + x + 17 y == 0





                        Or



                        eq2 = Simplify[Det[{-1, 1} Differences[Prepend[#, {x, y}]]] == 0] &;





                        share|improve this answer











                        $endgroup$













                        • $begingroup$
                          If pts = {{1, -3}, {-33, 150}} How can I get the form 9 x+2 y-3=0 . Your code ouput 9 x+2 y==3 Allways in the form a x + b y + c==0, a>0, if a=0, then b >0`.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 12:18












                        • $begingroup$
                          @minhthien_2016 Sort of eq[pts] /. a_ == b_ :> a - b == 0, though I think it just a minor issue.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 19 '18 at 13:04










                        • $begingroup$
                          Thank you very much.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 13:46










                        • $begingroup$
                          Another way : Det[{{x - #1[[1]], y - #1[[2]]}, {x - #2[[1]], y - #2[[2]]}}] == 0 & @@ {{1, -3}, {-33, -1}} // Simplify
                          $endgroup$
                          – Sigis K
                          Nov 20 '18 at 23:16












                        • $begingroup$
                          @SigisK Yes, it is.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 21 '18 at 4:12














                        4












                        4








                        4





                        $begingroup$

                        The equation of a planar line going through two points $ P_1(x_1,y_1) $ and $ P_2(x_2,y_2) $ (e.g. cf this for reference) is



                        $$
                        begin{vmatrix}
                        x & y\
                        x_2-x_1 & y_2-y_1
                        end{vmatrix}
                        =
                        begin{vmatrix}
                        x_1 & y_1\
                        x_2 & y_2
                        end{vmatrix}.
                        $$



                        So there is the piece of codes below:



                        Clear[eq, pts]
                        eq = Simplify[Det[{{x, y}, -Subtract @@ #}] == Det[#]] &;
                        pts = {{1, -3}, {-33, -1}};
                        eq[pts]



                        50 + x + 17 y == 0





                        Or



                        eq2 = Simplify[Det[{-1, 1} Differences[Prepend[#, {x, y}]]] == 0] &;





                        share|improve this answer











                        $endgroup$



                        The equation of a planar line going through two points $ P_1(x_1,y_1) $ and $ P_2(x_2,y_2) $ (e.g. cf this for reference) is



                        $$
                        begin{vmatrix}
                        x & y\
                        x_2-x_1 & y_2-y_1
                        end{vmatrix}
                        =
                        begin{vmatrix}
                        x_1 & y_1\
                        x_2 & y_2
                        end{vmatrix}.
                        $$



                        So there is the piece of codes below:



                        Clear[eq, pts]
                        eq = Simplify[Det[{{x, y}, -Subtract @@ #}] == Det[#]] &;
                        pts = {{1, -3}, {-33, -1}};
                        eq[pts]



                        50 + x + 17 y == 0





                        Or



                        eq2 = Simplify[Det[{-1, 1} Differences[Prepend[#, {x, y}]]] == 0] &;






                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Nov 19 '18 at 9:38

























                        answered Nov 19 '18 at 9:05









                        Αλέξανδρος ΖεγγΑλέξανδρος Ζεγγ

                        4,2341929




                        4,2341929












                        • $begingroup$
                          If pts = {{1, -3}, {-33, 150}} How can I get the form 9 x+2 y-3=0 . Your code ouput 9 x+2 y==3 Allways in the form a x + b y + c==0, a>0, if a=0, then b >0`.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 12:18












                        • $begingroup$
                          @minhthien_2016 Sort of eq[pts] /. a_ == b_ :> a - b == 0, though I think it just a minor issue.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 19 '18 at 13:04










                        • $begingroup$
                          Thank you very much.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 13:46










                        • $begingroup$
                          Another way : Det[{{x - #1[[1]], y - #1[[2]]}, {x - #2[[1]], y - #2[[2]]}}] == 0 & @@ {{1, -3}, {-33, -1}} // Simplify
                          $endgroup$
                          – Sigis K
                          Nov 20 '18 at 23:16












                        • $begingroup$
                          @SigisK Yes, it is.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 21 '18 at 4:12


















                        • $begingroup$
                          If pts = {{1, -3}, {-33, 150}} How can I get the form 9 x+2 y-3=0 . Your code ouput 9 x+2 y==3 Allways in the form a x + b y + c==0, a>0, if a=0, then b >0`.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 12:18












                        • $begingroup$
                          @minhthien_2016 Sort of eq[pts] /. a_ == b_ :> a - b == 0, though I think it just a minor issue.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 19 '18 at 13:04










                        • $begingroup$
                          Thank you very much.
                          $endgroup$
                          – minhthien_2016
                          Nov 19 '18 at 13:46










                        • $begingroup$
                          Another way : Det[{{x - #1[[1]], y - #1[[2]]}, {x - #2[[1]], y - #2[[2]]}}] == 0 & @@ {{1, -3}, {-33, -1}} // Simplify
                          $endgroup$
                          – Sigis K
                          Nov 20 '18 at 23:16












                        • $begingroup$
                          @SigisK Yes, it is.
                          $endgroup$
                          – Αλέξανδρος Ζεγγ
                          Nov 21 '18 at 4:12
















                        $begingroup$
                        If pts = {{1, -3}, {-33, 150}} How can I get the form 9 x+2 y-3=0 . Your code ouput 9 x+2 y==3 Allways in the form a x + b y + c==0, a>0, if a=0, then b >0`.
                        $endgroup$
                        – minhthien_2016
                        Nov 19 '18 at 12:18






                        $begingroup$
                        If pts = {{1, -3}, {-33, 150}} How can I get the form 9 x+2 y-3=0 . Your code ouput 9 x+2 y==3 Allways in the form a x + b y + c==0, a>0, if a=0, then b >0`.
                        $endgroup$
                        – minhthien_2016
                        Nov 19 '18 at 12:18














                        $begingroup$
                        @minhthien_2016 Sort of eq[pts] /. a_ == b_ :> a - b == 0, though I think it just a minor issue.
                        $endgroup$
                        – Αλέξανδρος Ζεγγ
                        Nov 19 '18 at 13:04




                        $begingroup$
                        @minhthien_2016 Sort of eq[pts] /. a_ == b_ :> a - b == 0, though I think it just a minor issue.
                        $endgroup$
                        – Αλέξανδρος Ζεγγ
                        Nov 19 '18 at 13:04












                        $begingroup$
                        Thank you very much.
                        $endgroup$
                        – minhthien_2016
                        Nov 19 '18 at 13:46




                        $begingroup$
                        Thank you very much.
                        $endgroup$
                        – minhthien_2016
                        Nov 19 '18 at 13:46












                        $begingroup$
                        Another way : Det[{{x - #1[[1]], y - #1[[2]]}, {x - #2[[1]], y - #2[[2]]}}] == 0 & @@ {{1, -3}, {-33, -1}} // Simplify
                        $endgroup$
                        – Sigis K
                        Nov 20 '18 at 23:16






                        $begingroup$
                        Another way : Det[{{x - #1[[1]], y - #1[[2]]}, {x - #2[[1]], y - #2[[2]]}}] == 0 & @@ {{1, -3}, {-33, -1}} // Simplify
                        $endgroup$
                        – Sigis K
                        Nov 20 '18 at 23:16














                        $begingroup$
                        @SigisK Yes, it is.
                        $endgroup$
                        – Αλέξανδρος Ζεγγ
                        Nov 21 '18 at 4:12




                        $begingroup$
                        @SigisK Yes, it is.
                        $endgroup$
                        – Αλέξανδρος Ζεγγ
                        Nov 21 '18 at 4:12











                        4












                        $begingroup$

                        With RegionMember:



                        Simplify[RegionMember[InfiniteLine[{{1, -3}, {-33, -1}}], {x, y}], 
                        Element[x | y, Reals]]



                        50 + x + 17 y == 0







                        share|improve this answer









                        $endgroup$


















                          4












                          $begingroup$

                          With RegionMember:



                          Simplify[RegionMember[InfiniteLine[{{1, -3}, {-33, -1}}], {x, y}], 
                          Element[x | y, Reals]]



                          50 + x + 17 y == 0







                          share|improve this answer









                          $endgroup$
















                            4












                            4








                            4





                            $begingroup$

                            With RegionMember:



                            Simplify[RegionMember[InfiniteLine[{{1, -3}, {-33, -1}}], {x, y}], 
                            Element[x | y, Reals]]



                            50 + x + 17 y == 0







                            share|improve this answer









                            $endgroup$



                            With RegionMember:



                            Simplify[RegionMember[InfiniteLine[{{1, -3}, {-33, -1}}], {x, y}], 
                            Element[x | y, Reals]]



                            50 + x + 17 y == 0








                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Nov 19 '18 at 13:59









                            halmirhalmir

                            10.2k2443




                            10.2k2443























                                2












                                $begingroup$

                                Knowing that the coefficients are components of a vector perpendicular to the difference of the two points, I think the most convenient command to obtain the equation is



                                perp = Cross[pB - pA];
                                perp.{x, y} == perp.pA // Simplify



                                50 + x + 17 y == 0




                                The last step before Simplify is



                                -2 x - 34 y == 100


                                so you can see that the simplification brought all terms to one side, factored out the greatest common divisor and fixed the signs.



                                To Mathematica the sums "50 + x + 17y" and "x + 17y + 50" are exactly the same expression, but if you want to order linear terms before constants in the displayed form, you may consider using TraditionalForm (with the added benefit of using a "normal" equality sign while remaining copy-and-pastable):



                                % // TraditionalForm



                                $x+17 y+50=0$







                                share|improve this answer









                                $endgroup$













                                • $begingroup$
                                  Ad sign of the x coefficient: I don't know of any trick simpler than multiply the result by –1 if you don't like it.
                                  $endgroup$
                                  – The Vee
                                  Nov 19 '18 at 13:26
















                                2












                                $begingroup$

                                Knowing that the coefficients are components of a vector perpendicular to the difference of the two points, I think the most convenient command to obtain the equation is



                                perp = Cross[pB - pA];
                                perp.{x, y} == perp.pA // Simplify



                                50 + x + 17 y == 0




                                The last step before Simplify is



                                -2 x - 34 y == 100


                                so you can see that the simplification brought all terms to one side, factored out the greatest common divisor and fixed the signs.



                                To Mathematica the sums "50 + x + 17y" and "x + 17y + 50" are exactly the same expression, but if you want to order linear terms before constants in the displayed form, you may consider using TraditionalForm (with the added benefit of using a "normal" equality sign while remaining copy-and-pastable):



                                % // TraditionalForm



                                $x+17 y+50=0$







                                share|improve this answer









                                $endgroup$













                                • $begingroup$
                                  Ad sign of the x coefficient: I don't know of any trick simpler than multiply the result by –1 if you don't like it.
                                  $endgroup$
                                  – The Vee
                                  Nov 19 '18 at 13:26














                                2












                                2








                                2





                                $begingroup$

                                Knowing that the coefficients are components of a vector perpendicular to the difference of the two points, I think the most convenient command to obtain the equation is



                                perp = Cross[pB - pA];
                                perp.{x, y} == perp.pA // Simplify



                                50 + x + 17 y == 0




                                The last step before Simplify is



                                -2 x - 34 y == 100


                                so you can see that the simplification brought all terms to one side, factored out the greatest common divisor and fixed the signs.



                                To Mathematica the sums "50 + x + 17y" and "x + 17y + 50" are exactly the same expression, but if you want to order linear terms before constants in the displayed form, you may consider using TraditionalForm (with the added benefit of using a "normal" equality sign while remaining copy-and-pastable):



                                % // TraditionalForm



                                $x+17 y+50=0$







                                share|improve this answer









                                $endgroup$



                                Knowing that the coefficients are components of a vector perpendicular to the difference of the two points, I think the most convenient command to obtain the equation is



                                perp = Cross[pB - pA];
                                perp.{x, y} == perp.pA // Simplify



                                50 + x + 17 y == 0




                                The last step before Simplify is



                                -2 x - 34 y == 100


                                so you can see that the simplification brought all terms to one side, factored out the greatest common divisor and fixed the signs.



                                To Mathematica the sums "50 + x + 17y" and "x + 17y + 50" are exactly the same expression, but if you want to order linear terms before constants in the displayed form, you may consider using TraditionalForm (with the added benefit of using a "normal" equality sign while remaining copy-and-pastable):



                                % // TraditionalForm



                                $x+17 y+50=0$








                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Nov 19 '18 at 13:25









                                The VeeThe Vee

                                1,393916




                                1,393916












                                • $begingroup$
                                  Ad sign of the x coefficient: I don't know of any trick simpler than multiply the result by –1 if you don't like it.
                                  $endgroup$
                                  – The Vee
                                  Nov 19 '18 at 13:26


















                                • $begingroup$
                                  Ad sign of the x coefficient: I don't know of any trick simpler than multiply the result by –1 if you don't like it.
                                  $endgroup$
                                  – The Vee
                                  Nov 19 '18 at 13:26
















                                $begingroup$
                                Ad sign of the x coefficient: I don't know of any trick simpler than multiply the result by –1 if you don't like it.
                                $endgroup$
                                – The Vee
                                Nov 19 '18 at 13:26




                                $begingroup$
                                Ad sign of the x coefficient: I don't know of any trick simpler than multiply the result by –1 if you don't like it.
                                $endgroup$
                                – The Vee
                                Nov 19 '18 at 13:26











                                1












                                $begingroup$

                                Although this might be more a math question, the ingenious answers have taught me a lot about MMA. Thanks to all contributors. I can add an answer based on my high school Analytical Geometry classes. The mnemonic two-point form of the equation of a straight line through A(x1,y1) and B(x2,y2) is



                                enter image description here



                                Using the coordinates for pA and pB given in the question:



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                y2 - y1) == (x - x1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here



                                However the more 'symmetrical form' of the equation leads to an answer that is mathematically identical, but is not in the required form. Does anybody know how to force MMA to yield the required form?



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                x - x1) == (y2 - y1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here






                                share|improve this answer









                                $endgroup$













                                • $begingroup$
                                  I think, we can write in the form Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)* (x2 - x1) - (x - x1)*(y2 - y1) == 0] // TraditionalForm
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:29










                                • $begingroup$
                                  My way is almost write the equations in the form a x + b y + c = 0.
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:48
















                                1












                                $begingroup$

                                Although this might be more a math question, the ingenious answers have taught me a lot about MMA. Thanks to all contributors. I can add an answer based on my high school Analytical Geometry classes. The mnemonic two-point form of the equation of a straight line through A(x1,y1) and B(x2,y2) is



                                enter image description here



                                Using the coordinates for pA and pB given in the question:



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                y2 - y1) == (x - x1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here



                                However the more 'symmetrical form' of the equation leads to an answer that is mathematically identical, but is not in the required form. Does anybody know how to force MMA to yield the required form?



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                x - x1) == (y2 - y1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here






                                share|improve this answer









                                $endgroup$













                                • $begingroup$
                                  I think, we can write in the form Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)* (x2 - x1) - (x - x1)*(y2 - y1) == 0] // TraditionalForm
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:29










                                • $begingroup$
                                  My way is almost write the equations in the form a x + b y + c = 0.
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:48














                                1












                                1








                                1





                                $begingroup$

                                Although this might be more a math question, the ingenious answers have taught me a lot about MMA. Thanks to all contributors. I can add an answer based on my high school Analytical Geometry classes. The mnemonic two-point form of the equation of a straight line through A(x1,y1) and B(x2,y2) is



                                enter image description here



                                Using the coordinates for pA and pB given in the question:



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                y2 - y1) == (x - x1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here



                                However the more 'symmetrical form' of the equation leads to an answer that is mathematically identical, but is not in the required form. Does anybody know how to force MMA to yield the required form?



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                x - x1) == (y2 - y1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here






                                share|improve this answer









                                $endgroup$



                                Although this might be more a math question, the ingenious answers have taught me a lot about MMA. Thanks to all contributors. I can add an answer based on my high school Analytical Geometry classes. The mnemonic two-point form of the equation of a straight line through A(x1,y1) and B(x2,y2) is



                                enter image description here



                                Using the coordinates for pA and pB given in the question:



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                y2 - y1) == (x - x1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here



                                However the more 'symmetrical form' of the equation leads to an answer that is mathematically identical, but is not in the required form. Does anybody know how to force MMA to yield the required form?



                                Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)/(
                                x - x1) == (y2 - y1)/(x2 - x1)] // TraditionalForm


                                gives



                                enter image description here







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Nov 20 '18 at 11:57









                                GommaireGommaire

                                1664




                                1664












                                • $begingroup$
                                  I think, we can write in the form Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)* (x2 - x1) - (x - x1)*(y2 - y1) == 0] // TraditionalForm
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:29










                                • $begingroup$
                                  My way is almost write the equations in the form a x + b y + c = 0.
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:48


















                                • $begingroup$
                                  I think, we can write in the form Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)* (x2 - x1) - (x - x1)*(y2 - y1) == 0] // TraditionalForm
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:29










                                • $begingroup$
                                  My way is almost write the equations in the form a x + b y + c = 0.
                                  $endgroup$
                                  – minhthien_2016
                                  Nov 21 '18 at 6:48
















                                $begingroup$
                                I think, we can write in the form Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)* (x2 - x1) - (x - x1)*(y2 - y1) == 0] // TraditionalForm
                                $endgroup$
                                – minhthien_2016
                                Nov 21 '18 at 6:29




                                $begingroup$
                                I think, we can write in the form Simplify@With[{x1 = 1, y1 = -3, x2 = -33, y2 = -1}, (y - y1)* (x2 - x1) - (x - x1)*(y2 - y1) == 0] // TraditionalForm
                                $endgroup$
                                – minhthien_2016
                                Nov 21 '18 at 6:29












                                $begingroup$
                                My way is almost write the equations in the form a x + b y + c = 0.
                                $endgroup$
                                – minhthien_2016
                                Nov 21 '18 at 6:48




                                $begingroup$
                                My way is almost write the equations in the form a x + b y + c = 0.
                                $endgroup$
                                – minhthien_2016
                                Nov 21 '18 at 6:48



                                這個網誌中的熱門文章

                                Tangent Lines Diagram Along Smooth Curve

                                Yusuf al-Mu'taman ibn Hud

                                Zucchini