| | |
| | | |
| | | import {terminal} from "./dfhi.js"; |
| | | |
| | | window.main = function(...argv) { |
| | | //const x = Number.parseFloat(argv[0]); |
| | | window.main = (...argv) => { |
| | | //const x = Number(argv[0]); |
| | | //const x_rad = x * Math.PI / 180; |
| | | const alpha = [0, 30, 45, 60, 90]; |
| | | alpha.map(x => x*Math.PI/180).forEach( a => { |
| | |
| | | }; |
| | | |
| | | |
| | | function makeTest(testName, value, impl, ref) { |
| | | const makeTest = (testName, value, impl, ref) => { |
| | | const result = impl(value); |
| | | const expected = ref(value); |
| | | terminal.print(`${testName} result: ${result} expected : ${expected}\n`); |
| | | } |
| | | |
| | | function sin(x) { |
| | | const sin = (x) => { |
| | | let sum = x; |
| | | let term = -(x**3 / 6); |
| | | const xsqr = x*x; |
| | |
| | | return sum; |
| | | } |
| | | |
| | | function cos(x) { |
| | | const cos = (x) => { |
| | | let sum = 1; |
| | | const xsqr = x*x; |
| | | let g = 2; |