'How to use arccos in Lazarus (pascal)

I have to write a program to find out the angles of a triangle. For some reason I always get the message 'INVALID OPERATION' which results in the program crashing. Can someone help me?

function Winkela(a,b,c:real):float;
var alpha:real;
begin
     alpha:= (b*b)+(c*c)-(a*a)/(2*b*c);
     radtodeg(arccos(alpha));
end;

function Winkelb(a,b,c:real):float;
var beta:real;
begin
     beta:= (c*c)+(a*a)-(b*b)/(2*c*a);
     radtodeg(arccos(beta));
end;

function Winkelc(a,b,c:real):float;
var gamma:real;
begin
     gamma:= (a*a)+(b*b)-(c*c)/(2*a*b);
     radtodeg(arccos(gamma));
end;

procedure TForm1.Button1Click(Sender: TObject);
var a,b,c:real;
begin
     a:=strtofloat(edit1.text);
     b:=strtofloat(edit2.text);
     c:=strtofloat(edit3.text);
     edit4.text:=floattostr(Winkela(a,b,c));
     edit5.text:=floattostr(Winkelb(a,b,c));
     edit6.text:=floattostr(Winkelc(a,b,c));
end;  


Solution 1:[1]

Assuming your data starts in cell A1 and the number of columns chosen is in H6 and you are using dynamic array excel then try this formula:

=SUM(ABS(INDEX(A1#,SEQUENCE(ROWS(A1#),1),SEQUENCE(1,COLUMNS(A1#)-H6+1,H6))))

To enter into cell Z9 using vba if nCols contains the number of columns try this:

Range("Z9").formula2="=SUM(ABS(INDEX(A1#,SEQUENCE(ROWS(A1#),1),SEQUENCE(1,COLUMNS(A1#)-" & nCols & "+1," & nCols & "))))"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1