Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit edad75a

Browse files
Create Solving_the_Law_of_Cosines.py
1 parent f2f558c commit edad75a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎Solving_the_Law_of_Cosines.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import numpy as np
2+
import sympy as sp
3+
4+
# Define symbols
5+
a, b, c, gamma = sp.symbols('a b c gamma')
6+
7+
# Define the Law of Cosines equation
8+
law_of_cosines_eq = sp.Eq(c**2, a**2 + b**2 - 2 * a * b * sp.cos(gamma))
9+
10+
# Solve for c
11+
solution_c = sp.solve(law_of_cosines_eq, c)[0]
12+
print("Solution for c:", solution_c)
13+
14+
15+
# Answer: Solution for c: -sqrt(a**2 - 2*a*b*cos(gamma) + b**2)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /