-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmath.dm42
81 lines (71 loc) · 912 Bytes
/
math.dm42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Various math functions missing from the dm42
// - LCM
// - GCF
// - Log_y(x)
// - xth root of y
// - Hypot
// - Quadratic Solver
export def math {
CLMENU
"lcm", KEY 1 XEQ lcm
"gcf", KEY 2 XEQ gcf
"logy x", KEY 3 XEQ log_yx
"x√y", KEY 4 XEQ x_root_y
"hypot", KEY 5 XEQ hypot
"quad", KEY 6 XEQ quadratic
if { FS? 03 } {
KEY 9 GTO custom_menu
}
MENU
STOP
}
def custom_menu { SF 27 }
// == Functions ==
def gcf {
do while { X!=0? } {
MOD
LASTX
X<>Y
}
DROP
ABS
}
def lcm {
DUPN 2
gcf()
/
*
}
def log_yx {
LOG
X<>Y
LOG
/
}
def x_root_y {
1/X
Y^X
}
def hypot {
X↑2
X<>Y
X↑2
+
SQRT
}
def quadratic {
RCL ST Z
+/-
STO/ ST Z
/
X<>Y
2
/
STO ST Z
STO ST T
X↑2
+
SQRT
STO- ST Z
+
}