Skip to content
TheChatArchiveThe Chat Archive
chatgpt-4o-latest-20250326· OpenAIHugging Face LMArena Human Preference 140K

Make a visual simulation wave function of schirondinger equation that show the colapse…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Mistralmistral-medium-2505’s answer.
  1. User

    Make a visual simulation wave function of schirondinger equation that show the colapse of the wave when I touch my mobile screen, after that the wave will envolving smooth, make it using tree.js put all code in wave.html for I will run on my Brouser. When I touch the screen turn the peak even more high and narrowed.when the pick is increasing turn it more gradually from blue, red to yellow at the pick point. After touch the wave will smoothing spread again.

  2. Assistant

    Here's a complete wave.html file using Three.js that simulates a Schrödinger-like wavefunction and visualizes its collapse and spreading again upon a touch on a mobile screen.

    Touch Events:

    • When you tap or touch your screen:
      • The center peak height will increase sharply.
      • The peak becomes narrower.
      • Its color will gradually change from blue → red → yellow based on the height.
    • After the touch:
      • The wave will smoothly evolve back into a broader wave again over time.

    ✅ Complete wave.html file (ready to run in browser)

    <!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <title>Wave Function Collapse Simulation</title>
        <style>
          body {
            margin: 0;
            overflow: hidden;
          }
          canvas {
            display: block;
          }
        </style>
      </head>
      <body>
        <script src="https://cdn.jsdelivr.net/npm/three@0.155.0/build/three.min.js"></script>
    
        <script>
          let scene, camera, renderer;
          let wave;
          let points = [];
          let geometry, material, line;
          const waveLength = 200;
          let time = 0;
    
          let peakHeight = 1;
          let peakWidth = 20;
          let isTouched = false;
    
          init();
          animate();
    
          function init() {
            scene = new THREE.Scene();
            camera = new THREE.PerspectiveCamera(
              75,
              window.innerWidth / window.innerHeight,
              0.1,
              1000
            );
            camera.position.z = 50;
    
            renderer = new THREE.WebGLRenderer({ antialias: true });
            renderer.setSize(window.innerWidth, window.innerHeight);
            document.body.appendChild(renderer.domElement);
    
            geometry = new THREE.BufferGeometry();
    
            points = new Float32Array(waveLength * 3);
            for (let i = 0; i < waveLength; i++) {
              let x = (i - waveLength / 2) / 2;
              let y = gaussian(x, 0, peakWidth, peakHeight);
              points[i * 3] = x;
              points[i * 3 + 1] = y;
              points[i * 3 + 2] = 0;
            }
    
            geometry.setAttribute(
              "position",
              new THREE.BufferAttribute(points, 3)
            );
    
            material = new THREE.LineBasicMaterial({ vertexColors: true });
            const colors = new Float32Array(waveLength * 3);
            for (let i = 0; i < waveLength; i++) {
              const color = getColorFromHeight(points[i * 3 + 1]);
              colors[i * 3] = color.r;
              colors[i * 3 + 1] = color.g;
              colors[i * 3 + 2] = color.b;
            }
            geometry.setAttribute("color", new THREE.BufferAttribute(colors, 3));
    
            line = new THREE.Line(geometry, material);
            scene.add(line);
    
            window.addEventListener("resize", onWindowResize, false);
            window.addEventListener("touchstart", onTouch, false);
            window.addEventListener("click", onTouch, false); // Also works on desktop
          }
    
          function gaussian(x, mean, width, height) {
            return height * Math.exp(-((x - mean) ** 2) / (2 * width ** 2));
          }
    
          function onWindowResize() {
            camera.aspect = window.innerWidth / window.innerHeight;
            camera.updateProjectionMatrix();
            renderer.setSize(window.innerWidth, window.innerHeight);
          }
    
          function onTouch() {
            isTouched = true;
            // Strengthen the peak
            peakHeight = 5;
            peakWidth = 5;
          }
    
          function getColorFromHeight(y) {
            const normalized = Math.min(Math.max((y - 1) / 4, 0), 1); // Normalize from 1 to 5
            const color = new THREE.Color();
    
            // Interpolate: Blue (low) → Red (mid) → Yellow (high)
            if (normalized < 0.5) {
              color.setRGB(normalized * 2, 0, 1 - normalized * 2);
            } else {
              color.setRGB(1, (normalized - 0.5) * 2, 0);
            }
    
            return color;
          }
    
          function animate() {
            requestAnimationFrame(animate);
    
            time += 0.03;
    
            if (!isTouched) {
              // Smooth spreading back
              peakHeight += (1 - peakHeight) * 0.03;
              peakWidth += (20 - peakWidth) * 0.03;
            } else {
              isTouched = false;
            }
    
            const positions = geometry.attributes.position.array;
            const colors = geometry.attributes.color.array;
    
            for (let i = 0; i < waveLength; i++) {
              let x = (i - waveLength / 2) / 2;
    
              // Simple harmonic oscillation + Gaussian envelope
              let y =
                gaussian(x, 0, peakWidth, peakHeight) *
                Math.cos(0.1 * x - time) *
                1;
    
              positions[i * 3 + 1] = y;
    
              const c = getColorFromHeight(Math.abs(y));
              colors[i * 3] = c.r;
              colors[i * 3 + 1] = c.g;
              colors[i * 3 + 2] = c.b;
            }
    
            geometry.attributes.position.needsUpdate = true;
            geometry.attributes.color.needsUpdate = true;
    
            renderer.render(scene, camera);
          }
        </script>
      </body>
    </html>
    

    🔍 How It Works

    • Wave Representation:

      • A 1D Gaussian wave packet with oscillating behavior (cos term).
      • Rendered as a colored 3D line using THREE.Line.
    • Interactivity:

      • Tap or click invokes onTouch():
        • Sets the peakHeight = 5 (higher),
        • Reduces width = 5 (narrower),
        • Simulates the wavefunction collapse on measurement.
    • Color Transition:

      • Color is based on wave height:
        • Blue when low
        • Red mid
        • Yellow at the peak
    • Natural Spread:

      • After touch, the wave gradually spreads (increases width) and lowers (peak falls), mimicking quantum spreading over time.

    📱 Mobile Compatible!

    This will work when you open it in your mobile Chrome/Safari browser. Simply tap the screen, and you'll see the wave pop and evolve again.

    Let me know if you want to add quantum potential wells, probability density, or want this as a 2D simulation!

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.