<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Interactive NLS Equation Explorer</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.7.0/chart.min.js"></script>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; max-width: 800px; margin: 0 auto; padding: 20px; }
h1, h2 { color: #2c3e50; }
.math { font-style: italic; }
.interactive { border: 1px solid #ddd; padding: 20px; margin: 20px 0; border-radius: 5px; }
input[type="range"] { width: 100%; }
canvas { max-width: 100%; }
</style>
</head>
<body>
<h1>Interactive NLS Equation Explorer</h1>
<p>This interactive page complements the LaTeX document on the Nonlinear Schrödinger (NLS) equation. Explore soliton solutions and their properties interactively using dimensionless parameters.</p>
<h2>The NLS Equation</h2>
<p>The standard form of the NLS equation with dimensionless variables:</p>
<div class="math">
\[i \frac{\partial \psi}{\partial \tau} + \frac{1}{2} \frac{\partial^2 \psi}{\partial \xi^2} + |\psi|^2 \psi = 0\]
</div>
<h2>Interactive Bright Soliton</h2>
<div class="interactive">
<p>Adjust the parameters to see how they affect the bright soliton solution:</p>
<div>
<label for="alpha">α (amplitude): </label>
<input type="range" id="alpha" min="0.1" max="2" step="0.1" value="1">
<span id="alphaValue">1</span>
</div>
<div>
<label for="beta">β (velocity): </label>
<input type="range" id="beta" min="-2" max="2" step="0.1" value="0">
<span id="betaValue">0</span>
</div>
<canvas id="brightSolitonChart"></canvas>
</div>
<h2>Interactive Dark Soliton</h2>
<div class="interactive">
<p>Adjust the parameters to see how they affect the dark soliton solution:</p>
<div>
<label for="gamma">γ (background amplitude): </label>
<input type="range" id="gamma" min="0.1" max="2" step="0.1" value="1">
<span id="gammaValue">1</span>
</div>
<div>
<label for="beta_dark">β (velocity): </label>
<input type="range" id="beta_dark" min="-1" max="1" step="0.1" value="0">
<span id="beta_darkValue">0</span>
</div>
<canvas id="darkSolitonChart"></canvas>
</div>
<script>
// JavaScript code for interactive charts
function updateBrightSoliton() {
const alpha = parseFloat(document.getElementById('alpha').value);
const beta = parseFloat(document.getElementById('beta').value);
document.getElementById('alphaValue').textContent = alpha;
document.getElementById('betaValue').textContent = beta;
const xi = Array.from({length: 200}, (_, i) => i / 10 - 10);
const psi = xi.map(xi_val => alpha * Math.pow(1 / Math.cosh(alpha * (xi_val - beta * 0)), 2));
brightSolitonChart.data.datasets[0].data = psi;
brightSolitonChart.update();
}
function updateDarkSoliton() {
const gamma = parseFloat(document.getElementById('gamma').value);
const beta = parseFloat(document.getElementById('beta_dark').value);
document.getElementById('gammaValue').textContent = gamma;
document.getElementById('beta_darkValue').textContent = beta;
const xi = Array.from({length: 200}, (_, i) => i / 10 - 10);
const psi = xi.map(xi_val => Math.pow(gamma * Math.tanh(gamma * (xi_val - beta * 0)), 2) + Math.pow(beta, 2));
darkSolitonChart.data.datasets[0].data = psi;
darkSolitonChart.update();
}
const brightSolitonCtx = document.getElementById('brightSolitonChart').getContext('2d');
const brightSolitonChart = new Chart(brightSolitonCtx, {
type: 'line',
data: {
labels: Array.from({length: 200}, (_, i) => i / 10 - 10),
datasets: [{
label: 'Bright Soliton',
data: [],
borderColor: 'rgb(75, 192, 192)',
tension: 0.1
}]
},
options: {
responsive: true,
scales: {
x: {
title: {
display: true,
text: 'ξ'
}
},
y: {
title: {
display: true,
text: '|ψ|²'
}
}
}
}
});
const darkSolitonCtx = document.getElementById('darkSolitonChart').getContext('2d');
const darkSolitonChart = new Chart(darkSolitonCtx, {
type: 'line',
data: {
labels: Array.from({length: 200}, (_, i) => i / 10 - 10),
datasets: [{
label: 'Dark Soliton',
data: [],
borderColor: 'rgb(153, 102, 255)',
tension: 0.1
}]
},
options: {
responsive: true,
scales: {
x: {
title: {
display: true,
text: 'ξ'
}
},
y: {
title: {
display: true,
text: '|ψ|²'
}
}
}
}
});
document.getElementById('alpha').addEventListener('input', updateBrightSoliton);
document.getElementById('beta').addEventListener('input', updateBrightSoliton);
document.getElementById('gamma').addEventListener('input', updateDarkSoliton);
document.getElementById('beta_dark').addEventListener('input', updateDarkSoliton);
updateBrightSoliton();
updateDarkSoliton();
</script>
</body>
</html>