2
$\begingroup$

I need to find the obtuse angle between two lines but I am not sure how to code it.

my two angles are 𝑥+√3𝑦=1 and (1−√3)𝑥+(1+√3)𝑦=8

I already did the calculations but im just not sure how to implement it, any help would be greatly appreciated.

Specifically what I need is to convert the two equations to slope intercept form, and then use that slope in the formula
Theta = arctan m2- m1/ 1+ m1*m2

calculations

$\endgroup$
1
  • $\begingroup$ Welcome to the Mathematica Stack Exchange. Are you seeking a Mathematica based solution? or a Math solution? For a math solution, please post at Math SE site. $\endgroup$
    – Syed
    Nov 23, 2022 at 5:23

2 Answers 2

2
$\begingroup$

Why slope intercept form? From the equations we immediately know their normal vectors are {1, Sqrt[3]} and {1 - Sqrt[3], 1 + Sqrt[3]}, so the angle between the lines is

VectorAngle[{1, Sqrt[3]}, {1 - Sqrt[3], 1 + Sqrt[3]}] // Simplify
(* π/4 *)

You need a obtuse angle, so we simply do π - π/4 and obtain 3 π/4. The whole process can be automated with:

angle…between…lines[eqns_, vars_] := 
 VectorAngle @@ CoefficientArrays[eqns, vars][[-1]] // Simplify

obtuse = If[# > Pi/2, #, Pi - #] &;
acute  = If[# < Pi/2, #, Pi - #] &;

Then we can calculate the angle directly from the equation:

obtuse@angle…between…lines[{x + √3 y == 1, (1 - √3) x + (1 + √3) y == 8}, {x, y}]
(* (3 π)/4 *)

If you need acute angle, use acute instead of obtuse in the code.

$\endgroup$
2
$\begingroup$

Or Differences the two points on the line to get the direction of line.

eqn1 = x + Sqrt[3] y == 1;
eqn2 = (1 - Sqrt[3]) x + (1 + Sqrt[3]) y == 8;
dir1 = {x, y} /. FindInstance[eqn1, {x, y}, Reals, 2] // 
   Differences;
dir2 = {x, y} /. FindInstance[eqn2, {x, y}, Reals, 2] // 
   Differences;
angle = VectorAngle[dir1[[1]], dir2[[1]]] // FullSimplify
Max[angle, π - angle]

enter image description here

$\endgroup$
1
  • $\begingroup$ thank you very much, is there any way I can get it into the exact radian measurement? and it rounded to 3 decimal places? $\endgroup$
    – gobert
    Nov 23, 2022 at 6:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.