@@ -992,27 +992,19 @@ <h4 style="font-size:160%;margin:7px">Trigonometry</h4>
992992 return bestMatch ;
993993}
994994
995-
996- function Atan ( input ) {
997- // Normalize and extract the value: "atan 0.5" or "atan(0.5)"
998- const match = input . match ( / a t a n \s * \( ? ( [ 0 - 9 . / \s √ - ] + ) \) ? / i) ;
999- if ( ! match ) return ; // Invalid format
1000-
1001- const inputStr = match [ 1 ] . trim ( ) ;
1002- const x = parseFloat ( eval ( inputStr . replace ( / √ ( \d + ) / g, 'Math.sqrt($1)' ) ) ) ;
1003-
1004- if ( isNaN ( x ) || x <= 0 ) return ; // Domain cutoffs from your spec
995+ function Atan ( x ) {
996+ if ( typeof x !== 'number' || isNaN ( x ) || x <= 0 ) return null ;
1005997
1006- // Case A: x > 1 or x < 0.089 → direct match
1007- if ( x > 1 || x < 0.089 ) {
1008- const bestMatch = closestValue ( x , 'tan' ) ;
1009- if ( bestMatch ) return `atan( ${ inputStr } ) ≈ ${ bestMatch . angle } ` ;
1010- }
998+ // Direct match zone
999+ if ( x > 1 || x < 0.089 ) {
1000+ const match = closestValue ( x , 'tan' ) ;
1001+ return match ? .angle ?? null ;
1002+ }
10111003
1012- // Case B: 0.089 < x < 1 → invert to 1/x and search tan table
1013- const reciprocal = 1 / x ;
1014- const bestMatch = closestValue ( reciprocal , 'tan' ) ;
1015- if ( bestMatch ) return `atan( ${ inputStr } ) ≈ ${ bestMatch . angle } ` ;
1004+ // Reflective zone ( 0.089 < x < 1)
1005+ const reciprocal = 1 / x ;
1006+ const match = closestValue ( reciprocal , 'tan' ) ;
1007+ return match ? .angle ?? null ;
10161008}
10171009
10181010</ script >
@@ -1343,7 +1335,7 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
13431335 }
13441336
13451337 const thing = 2 * height / length ;
1346- const angle = parseFloat ( atan ( thing ) . toFixed ( 5 ) ) ;
1338+ const angle = parseFloat ( Atan ( thing ) . toFixed ( 5 ) ) ;
13471339 const cosine = parseFloat ( cos ( angle ) . toFixed ( 5 ) ) ;
13481340 const radius = length / ( 2 * cosine ) ;
13491341
@@ -2443,11 +2435,13 @@ <h6 style="font-size:160%;margin:7px">Area of a circle</h6>
24432435 const s = sin ( angle ) ;
24442436 const c = cos ( angle ) ;
24452437 const t = tan ( angle ) ;
2438+ const at = Atan ( angle ) ;
24462439
24472440 output . innerText += `✅ Testing angle: ${ angle } \n\n` ;
24482441 output . innerText += `• sin(${ angle } ) = ${ s } \n` ;
24492442 output . innerText += `• cos(${ angle } ) = ${ c } \n` ;
24502443 output . innerText += `• tan(${ angle } ) = ${ t } \n` ;
2444+ output . innerText += `• Atan(${ angle } ) = ${ at } \n` ;
24512445
24522446
24532447 // Optional: known expectations
0 commit comments