Why Is the Area Calculation of a Triangle Using Given Algorithms Unstable?

Click For Summary
SUMMARY

The discussion focuses on the instability of two algorithms for calculating the area of a triangle given sides A, B, and C. The first algorithm, Area1(A,B,C) = sqrt(S(S-C)(S-B)(S-A)), is deemed unstable due to significant numerical errors when sides are nearly collinear. The second algorithm, Area2(A,B,C) = sqrt((A+B+C)(A+B-C)(A-B+C)(-A+B+C)) / 4, while more stable than the first, still suffers from instability under certain conditions. A proposed rearrangement of the formula aims to enhance stability by reducing the impact of subtractive cancellation.

PREREQUISITES
  • Understanding of Heron's formula for triangle area calculation
  • Familiarity with numerical stability concepts in computational mathematics
  • Basic knowledge of square root functions and their properties
  • Experience with algebraic manipulation of equations
NEXT STEPS
  • Research numerical stability in algorithms, focusing on computational geometry
  • Explore alternative triangle area formulas, such as the sine rule
  • Learn about error analysis in numerical computations
  • Investigate the impact of floating-point arithmetic on algorithm performance
USEFUL FOR

Mathematicians, computer scientists, and software engineers involved in computational geometry or numerical analysis, particularly those focused on algorithm optimization and stability in mathematical computations.

MtX
Messages
9
Reaction score
0
Consider the following algorithm for computing the area of a triangle with sides of length A, B, and C:

S = (A+B+C) / 2
Area1(A,B,C) = sqrt(S(S-C)(S-B)(S-A)).

A) Explain why this approach is unstable, and illustrate with an example.

B) A student proposes the following less efficient, but more stable, approach:

Area2(A,B,C) = sqrt((A+B+C)(A+B-C)(A-B+C)(-A+B+C)) / 4

Explain why this approach is still unstable and illustrate with an example.

C) Reaarange the formula to produce a more stable version. Explain why it is more stable.


I really have no clue on how to start off but for parts A) and B), I plan to insert arbitrary values of A, B and C, compare the area of the triangle using sides A, B, and C, versus the value of the area after using the Area1 and Area2 equations as examples. I am guessing the compared values will differ greatly and as a result makes this "approach" unstable.

For Part C) however, I have no clue how to begin. Am I suppose to create my own formula? Or modify theirs? What should I do?

Thanks.
 
Physics news on Phys.org
I am not sure what "stability" is supposed to mean. I'll assume that it means expression without minus signs. With very little difficulty I got:

area=sqrt(S(S3+AB(A+B)+AC(A+C)+BC(B+C)+ABC)/2)
 

Similar threads

  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 2 ·
Replies
2
Views
5K
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 12 ·
Replies
12
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K