Skip to content

Commit 3b66a74

Browse files
authored
Update index.html
1 parent 520a33c commit 3b66a74

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

index.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,28 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
947947
const fallbackKey = closestRad(radian);
948948
return trig[fallbackKey]?.cos ?? null;
949949
}
950+
951+
function tan(radian) {
952+
const radKey = `rad(${radian.toFixed(3)})`;
953+
954+
// 🔹 Case 1: Exact match
955+
if (trig[radKey]?.tan !== undefined) return trig[radKey].tan;
956+
957+
// 🔹 Case 2: 0.8 > x > 0.1 → Use sine reflection
958+
if (radian > 0.1 && radian < 0.8) {
959+
const reflected = 1.6 - radian;
960+
const reflectedKey = `rad(${reflected.toFixed(3)})`;
961+
962+
if (trig[reflectedKey]?.tan !== undefined) return trig[reflectedKey].tan;
963+
964+
const fallbackKey = closestRad(reflected);
965+
return 1 / trig[fallbackKey]?.tan ?? null;
966+
}
967+
968+
// 🔹 Case 3: Otherwise, search sin column directly
969+
const fallbackKey = closestRad(radian);
970+
return trig[fallbackKey]?.tan ?? null;
971+
}
950972

951973

952974
function closestValue(input, funcType) {
@@ -2420,11 +2442,12 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
24202442
try {
24212443
const s = sin(angle);
24222444
const c = cos(angle);
2423-
2445+
const t = tan(angle);
24242446

24252447
output.innerText += `✅ Testing angle: ${angle}\n\n`;
24262448
output.innerText += `• sin(${angle}) = ${s}\n`;
24272449
output.innerText += `• cos(${angle}) = ${c}\n`;
2450+
output.innerText += `• tan(${angle}) = ${t}\n`;
24282451

24292452

24302453
// Optional: known expectations

0 commit comments

Comments
 (0)