RosettaCodeData/Task/Law-of-cosines---triples/00-TASK.txt

36 lines
1.7 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

The [https://en.wikipedia.org/wiki/Law_of_cosines Law of cosines] states that for an angle γ, (gamma) of any triangle, if the sides adjacent to the angle are A and B and the side opposite is C; then the lengths of the sides are related by this formula:
<big> <code>A<sup>2</sup> + B<sup>2</sup> - 2ABcos(γ) = C<sup>2</sup></code> </big>
;Specific angles:
For an angle of of &nbsp; '''90º''' &nbsp; this becomes the more familiar "Pythagoras equation":
<big> <code>A<sup>2</sup> + B<sup>2</sup> = C<sup>2</sup></code> </big>
For an angle of &nbsp; '''60º''' &nbsp; this becomes the less familiar equation:
<big> <code>A<sup>2</sup> + B<sup>2</sup> - AB = C<sup>2</sup></code> </big>
And finally for an angle of &nbsp; '''120º''' &nbsp; this becomes the equation:
<big> <code>A<sup>2</sup> + B<sup>2</sup> + AB = C<sup>2</sup></code> </big>
;Task:
* &nbsp; Find all integer solutions (in order) to the three specific cases, distinguishing between each angle being considered.
* &nbsp; Restrain all sides to the integers &nbsp; '''1..13''' &nbsp; inclusive.
* &nbsp; Show how many results there are for each of the three angles mentioned above.
* &nbsp; Display results on this page.
Note: Triangles with the same length sides but different order are to be treated as the same.
;Optional Extra credit:
* How many 60° integer triples are there for sides in the range 1..10_000 ''where the sides are not all of the same length''.
;Related Task
* [[Pythagorean triples]]
;See also:
* [https://youtu.be/p-0SOWbzUYI?t=12m11s Visualising Pythagoras: ultimate proofs and crazy contortions] Mathlogger Video
<br><br>