ccitonline.com

CCIT – Cara Cerdas Ingat Tuhan

| DAI5 eBook Free Download | CFDSOF | VisualFOAM | PT CCIT Group Indonesia : Indonesia leading CFD services company with Inhouse CFD Technology |

HTML CFDSOF – Ganda

Curve Fitting Visualization function polynomialRegression2(x, y) { let n = x.length; let sumX = 0, sumX2 = 0, sumX3 = 0, sumX4 = 0; let sumY = 0, sumXY = 0, sumX2Y = 0; for (let i = 0; i < n; i++) { let xi = x[i]; let yi = y[i]; let xi2 = xi * xi; let xi3 = xi2 * xi; let xi4 = xi3 * xi; sumX += xi; sumX2 += xi2; sumX3 += xi3; sumX4 += xi4; sumY += yi; sumXY += xi * yi; sumX2Y += xi2 * yi; } let A = [ [sumX4, sumX3, sumX2], [sumX3, sumX2, sumX], [sumX2, sumX, n] ]; let B = [sumX2Y, sumXY, sumY]; function solveSystem(A, B) { let det = (A[0][0] * (A[1][1] * A[2][2] – A[1][2] * A[2][1]) – A[0][1] * (A[1][0] * A[2][2] – A[1][2] * A[2][0]) + A[0][2] * (A[1][0] * A[2][1] – A[1][1] * A[2][0])); let A_inv = [ [ (A[1][1] * A[2][2] – A[1][2] * A[2][1]) / det, -(A[0][1] * A[2][2] – A[0][2] * A[2][1]) / det, (A[0][1] * A[1][2] – A[0][2] * A[1][1]) / det], [-(A[1][0] * A[2][2] – A[1][2] * A[2][0]) / det, (A[0][0] * A[2][2] – A[0][2] * A[2][0]) / det, -(A[0][0] * A[1][2] – A[0][2] * A[1][0]) / det], [ (A[1][0] * A[2][1] – A[1][1] * A[2][0]) / det, -(A[0][0] * A[2][1] – A[0][1] * A[2][0]) / det, (A[0][0] * A[1][1] – A[0][1] * A[1][0]) / det] ]; let result = [ A_inv[0][0] * B[0] + A_inv[0][1] * B[1] + A_inv[0][2] * B[2], A_inv[1][0] * B[0] + A_inv[1][1] * B[1] + A_inv[1][2] * B[2], A_inv[2][0] * B[0] + A_inv[2][1] * B[1] + A_inv[2][2] * B[2] ]; return result; } let [a, b, c] = solveSystem(A, B); return { a, b, c }; } let x_data = [0.0, 0.125, 0.25, 0.375, 0.5, 0.625, 0.75, 0.875, 1.0]; let y_data = [328.529, 345.116, 367.235, 389.358, 411.71, 423.0, 416.925, 404.9, 395.975]; let coeffs = polynomialRegression2(x_data, y_data); console.log(`Persamaan regresi: y = ${coeffs.a.toFixed(2)}xยฒ + ${coeffs.b.toFixed(2)}x + ${coeffs.c.toFixed(2)}`); let x_fit = []; let y_fit = []; for (let x = 0; x ({ x: xi, y: y_data[i] })), backgroundColor: ‘red’ }, { label: ‘Curve Fitting’, data: x_fit.map((xi, i) => ({ x: xi, y: y_fit[i] })), type: ‘line’, borderColor: ‘blue’, fill: false } ] }, options: { scales: { x: { title: { display: true, text: ‘Posisi (m)’ } }, y: { title: { display: true, text: ‘Temperatur (K)’ } } } } });

HTML dari CFDSOF


Leave a Reply

Your email address will not be published. Required fields are marked *