diff --git a/src/generators/latexGenerators.js b/src/generators/latexGenerators.js index 3d6ce5ce..e3a8b0f4 100644 --- a/src/generators/latexGenerators.js +++ b/src/generators/latexGenerators.js @@ -160,15 +160,17 @@ export function infiniteGeometricSeries(n, useGammaFunction) { * @returns {string} LaTeX string */ export function trigIdentity(n, randOption) { + const a = Math.floor(Math.random() * 51) - 10; // Random number from -10 to 40 + if (n > 0) { const randomValue = Math.random(); if (randomValue < 0.25) { - return `\\left({${randOption(n)} \\over {(\\cos^2x + \\sin^2x)}}\\right)`; + return `\\left({${randOption(n)} \\over {\\lim_{{x\\to ${a}}}(\\cos^2x + \\sin^2x)}}\\right)`; } if (randomValue < 0.5) { - return `\\left({${randOption(n)} \\times (\\cos^2x + \\sin^2x)}\\right)`; + return `\\left({${randOption(n)} \\times \\lim_{{x\\to ${a}}}(\\cos^2x + \\sin^2x)}\\right)`; } - return `\\left({${randOption(n + 1)} - (\\cos^2x + \\sin^2x)}\\right)`; + return `\\left({${randOption(n + 1)} - \\lim_{{x\\to ${a}}}(\\cos^2x + \\sin^2x)}\\right)`; } - return `\\left({${randOption(n + 1)} - (\\cos^2x + \\sin^2x)}\\right)`; + return `\\left({${randOption(n + 1)} - \\lim_{{x\\to ${a}}}(\\cos^2x + \\sin^2x)}\\right)`; } diff --git a/src/services/decompositionService.js b/src/services/decompositionService.js index ff0cd02f..05813b6d 100644 --- a/src/services/decompositionService.js +++ b/src/services/decompositionService.js @@ -151,7 +151,7 @@ export function decompose(n, possibleOptions, sameNumber) { const randomValue = Math.random(); // Strategy 1: Factor decomposition - ab = (a - c)(b + c) + c(b - a + c) - if (n < MEDIUM_NUMBER_THRESHOLD && (n === 2 || !isPrime(n)) && randomValue < 0.25) { + if (parseInt(n) !== 0 && n < MEDIUM_NUMBER_THRESHOLD && (n === 2 || !isPrime(n)) && randomValue < 0.25) { const factors = getFactors(parseInt(n)); const randomIndex = randomInt(0, factors.length - 1); const a = factors[randomIndex];