September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -0,0 +1,14 @@
@% = &90F : REM set column width
angle_radians = PI/5
angle_degrees = 36
PRINT SIN(angle_radians), SIN(RAD(angle_degrees))
PRINT COS(angle_radians), COS(RAD(angle_degrees))
PRINT TAN(angle_radians), TAN(RAD(angle_degrees))
number = 0.6
PRINT ASN(number), DEG(ASN(number))
PRINT ACS(number), DEG(ACS(number))
PRINT ATN(number), DEG(ATN(number))

View file

@ -0,0 +1,16 @@
100 LET DG=DEG(PI/4)
110 OPTION ANGLE DEGREES
120 PRINT SIN(DG)
130 PRINT COS(DG)
140 PRINT TAN(DG)
150 PRINT ASIN(SIN(DG))
160 PRINT ACOS(COS(DG))
170 PRINT ATN(TAN(DG))
180 LET RD=RAD(45)
190 OPTION ANGLE RADIANS
200 PRINT SIN(RD)
210 PRINT COS(RD)
220 PRINT TAN(RD)
230 PRINT ASIN(SIN(RD))
240 PRINT ACOS(COS(RD))
250 PRINT ATN(TAN(RD))

View file

@ -1,24 +1,24 @@
import system'math.
import extensions.
import system'math;
import extensions;
program =
[
console printLine("Radians:").
console printLine("sin(π/3) = ",(pi_value/3) sin).
console printLine("cos(π/3) = ",(pi_value/3) cos).
console printLine("tan(π/3) = ",(pi_value/3) tan).
console printLine("arcsin(1/2) = ",0.5r arcsin).
console printLine("arccos(1/2) = ",0.5r arccos).
console printLine("arctan(1/2) = ",0.5r arctan).
console printLine.
public program()
{
console.printLine("Radians:");
console.printLine("sin(π/3) = ",(Pi_value/3).sin());
console.printLine("cos(π/3) = ",(Pi_value/3).cos());
console.printLine("tan(π/3) = ",(Pi_value/3).tan());
console.printLine("arcsin(1/2) = ",0.5r.arcsin());
console.printLine("arccos(1/2) = ",0.5r.arccos());
console.printLine("arctan(1/2) = ",0.5r.arctan());
console.printLine();
console printLine("Degrees:").
console printLine("sin(60º) = ",60.0r radian; sin).
console printLine("cos(60º) = ",60.0r radian; cos).
console printLine("tan(60º) = ",60.0r radian; tan).
console printLine("arcsin(1/2) = ",0.5r arcsin; degree,"º").
console printLine("arccos(1/2) = ",0.5r arccos; degree,"º").
console printLine("arctan(1/2) = ",0.5r arctan; degree,"º").
console.printLine("Degrees:");
console.printLine("sin(60º) = ",60.0r.Radian.sin());
console.printLine("cos(60º) = ",60.0r.Radian.cos());
console.printLine("tan(60º) = ",60.0r.Radian.tan());
console.printLine("arcsin(1/2) = ",0.5r.arcsin().Degree,"º");
console.printLine("arccos(1/2) = ",0.5r.arccos().Degree,"º");
console.printLine("arctan(1/2) = ",0.5r.arctan().Degree,"º");
console readChar.
].
console.readChar()
}

View file

@ -0,0 +1,7 @@
USING: kernel math math.constants math.functions math.trig
prettyprint ;
pi 4 / 45 deg>rad [ sin ] [ cos ] [ tan ]
[ [ . ] compose dup compose ] tri@ 2tri
.5 [ asin ] [ acos ] [ atan ] tri [ dup rad>deg [ . ] bi@ ] tri@

View file

@ -44,20 +44,20 @@ tanErr: call tellErr 'tan(' || x") causes division by zero, X=" || x
AsinErr: call tellErr 'Asin(x), X must be in the range of -1 +1, X=' || x
AcosErr: call tellErr 'Acos(x), X must be in the range of -1 +1, X=' || x
/*──────────────────────────────────────────────────────────────────────────────────────*/
Atan: procedure; parse arg x; if abs(x)=1 then return pi() * .25 * sign(x)
return Asin(x / sqrt(1 + x*x) )
Atan: procedure; parse arg x; if abs(x)=1 then return pi() * .25 * sign(x)
return Asin(x / sqrt(1 + x*x) )
/*──────────────────────────────────────────────────────────────────────────────────────*/
cos: procedure; parse arg x; x= r2r(x); a=abs(x); hpi= pi * .5
numeric fuzz min(6, digits() - 3); if a=pi() then return -1
if a=hpi | a=hpi*3 then return 0; if a=pi() / 3 then return .5
if a=pi() * 2 / 3 then return -.5; return .sinCos(1, -1)
cos: procedure; parse arg x; x= r2r(x); a= abs(x); hpi= pi * .5
numeric fuzz min(6, digits() - 3); if a=pi then return -1
if a=hpi | a=hpi*3 then return 0; if a=pi / 3 then return .5
if a=pi * 2 / 3 then return -.5; return .sinCos(1, -1)
/*──────────────────────────────────────────────────────────────────────────────────────*/
sin: procedure; parse arg x; x=r2r(x); numeric fuzz min(5, max(1, digits() -3))
if x=pi*.5 then return 1; if x==pi * 1.5 then return -1
if abs(x)=pi | x=0 then return 0; return .sinCos(x, 1)
sin: procedure; parse arg x; x=r2r(x); numeric fuzz min(5, max(1, digits()-3))
if x=pi*.5 then return 1; if x==pi * 1.5 then return -1
if abs(x)=pi | x=0 then return 0; return .sinCos(x,1)
/*──────────────────────────────────────────────────────────────────────────────────────*/
.sinCos: parse arg z 1 _,i; q= x*x
do k=2 by 2 until p=z; p= z; _= - _ * q / (k * (k+i) ); z= z+_; end
do k=2 by 2 until p=z; p= z; _= - _ * q / (k * (k+i) ); z= z + _; end
return z
/*──────────────────────────────────────────────────────────────────────────────────────*/
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); i=; m.=9; h= d+6

View file

@ -0,0 +1,15 @@
Public Sub trig()
Pi = WorksheetFunction.Pi()
Debug.Print Sin(Pi / 2)
Debug.Print Sin(90 * Pi / 180)
Debug.Print Cos(0)
Debug.Print Cos(0 * Pi / 180)
Debug.Print Tan(Pi / 4)
Debug.Print Tan(45 * Pi / 180)
Debug.Print WorksheetFunction.Asin(1) * 2
Debug.Print WorksheetFunction.Asin(1) * 180 / Pi
Debug.Print WorksheetFunction.Acos(0) * 2
Debug.Print WorksheetFunction.Acos(0) * 180 / Pi
Debug.Print Atn(1) * 4
Debug.Print Atn(1) * 180 / Pi
End Sub

View file

@ -0,0 +1,21 @@
Module Module1
Sub Main()
Console.WriteLine("=== radians ===")
Console.WriteLine(" sin (pi/3) = {0}", Math.Sin(Math.PI / 3))
Console.WriteLine(" cos (pi/3) = {0}", Math.Cos(Math.PI / 3))
Console.WriteLine(" tan (pi/3) = {0}", Math.Tan(Math.PI / 3))
Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5))
Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5))
Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5))
Console.WriteLine()
Console.WriteLine("=== degrees ===")
Console.WriteLine(" sin (60) = {0}", Math.Sin(60 * Math.PI / 180))
Console.WriteLine(" cos (60) = {0}", Math.Cos(60 * Math.PI / 180))
Console.WriteLine(" tan (60) = {0}", Math.Tan(60 * Math.PI / 180))
Console.WriteLine("arcsin (1/2) = {0}", Math.Asin(0.5) * 180 / Math.PI)
Console.WriteLine("arccos (1/2) = {0}", Math.Acos(0.5) * 180 / Math.PI)
Console.WriteLine("arctan (1/2) = {0}", Math.Atan(0.5) * 180 / Math.PI)
End Sub
End Module