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 |

Mencari solusi x untuk persamaan ln(x²) + e^x  = 0

Newton-Raphson Solver

Solusi Persamaan ln(x²) + e^x = 0 dengan Newton-Raphson

function f(x) { return Math.log(x * x) + Math.exp(x); } function df(x) { return (2 / x) + Math.exp(x); } function newtonRaphson(x0, tol = 1e-6, maxIter = 100) { let x = x0; for (let i = 0; i < maxIter; i++) { let fx = f(x); let dfx = df(x); if (Math.abs(dfx) < 1e-10) { return "Diferensial nol, metode gagal."; } let xNext = x – fx / dfx; if (Math.abs(xNext – x) < tol) { return `Akar ditemukan: ${xNext.toFixed(6)} (iterasi ke-${i + 1})`; } x = xNext; } return "Maksimum iterasi tercapai, solusi tidak konvergen."; } function solveNewtonRaphson() { let initialGuess = parseFloat(document.getElementById("initialGuess").value); let result = newtonRaphson(initialGuess); document.getElementById("result").innerText = result; }

Leave a Reply

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