Hauptsatz der Differential- und Integralrechnung: Unterschied zwischen den Versionen

Zeile 37: Zeile 37:
<head>
<head>
     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/1.4.6/jsxgraphcore.js"></script>
     <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/1.4.6/jsxgraphcore.js"></script>
     <script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" id="MathJax-script"></script>
     <script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
     <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/1.4.6/jsxgraph.css" />
     <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/jsxgraph/1.4.6/jsxgraph.css" />
</head>
</head>
<body>
<body>
     <div id="box2" style="width:500px; height:500px;"></div>
     <div id="box2" style="width:40%; aspect-ratio:3/2; margin-top:20px;"></div>
    <div id="integralLabel" style="font-size: 20px; margin-top: 20px;"></div> <!-- Hier wird das LaTeX-Label gerendert -->
   
     <script type="text/javascript">
     <script type="text/javascript">
        // MathJax in JSXGraph aktivieren
         JXG.Options.text.useMathJax = true;
         JXG.Options.text.useMathJax = true;
 
          
         // JSXGraph-Board erstellen
         var board = JXG.JSXGraph.initBoard('box2', {
         var board = JXG.JSXGraph.initBoard('box2', {
             boundingbox: [-5, 5, 5, -5], // Angepasste Boundingbox für die Skalierung
             boundingbox: [-5, 5, 8, -5],
             axis: true,
             axis: true,
             showCopyright: false,
             showCopyright: false,
             showNavigation: true,
             showNavigation: true,
             grid: true, // Gitternetz aktivieren
             grid: true
            defaultAxes: {
                x: {
                    withLabel: true,
                    name: 't',
                    label: {
                        position: 'rt',
                        offset: [-5, 15],
                        fontSize: 16,
                        anchorX: 'right'
                    },
                    ticks: {
                        ticksDistance: 1,
                        minorTicks: 0
                    }
                },
                y: {
                    withLabel: true,
                    name: 'f(t)',
                    label: {
                        position: 'rt',
                        offset: [15, 5],
                        fontSize: 16,
                        anchorY: 'right'
                    },
                    ticks: {
                        ticksDistance: 1,
                        minorTicks: 0
                    }
                }
            }
         });
         });


Zeile 94: Zeile 64:
             [-2.0, 2.0], c1
             [-2.0, 2.0], c1
         ], {
         ], {
             withLabel: true,
             withLabel: false, // Wir setzen das Label manuell
            label: {
             baseLeft: { visible: true, fixed: false, withLabel: true, name: 'a' },
                fontSize: 16,
             baseRight: { visible: true, fixed: false, withLabel: true, name: 'b' }
                offset: [0, 50],
                digits: 4,
                intl: {
                    enabled: false,
                    options: {}
                }
            },
             baseLeft: {   // Start point
                visible: true,
                fixed: false,
                withLabel: true,
                name: 'a'
            },
             baseRight: {   // End point
                visible: true,
                fixed: false,
                withLabel: true,
                name: 'b'
            }
         });
         });


         // Integral-Label anpassen
         // Funktion zum Aktualisieren des LaTeX-Labels
         i1.label.setText(() => {
         function updateIntegralLabel() {
             const a = i1.baseLeft.X().toFixed(2); // Untere Grenze
             const a = i1.baseLeft.X().toFixed(2);
             const b = i1.baseRight.X().toFixed(2); // Obere Grenze
             const b = i1.baseRight.X().toFixed(2);
             const value = i1.Value().toFixed(4); // Wert des Integrals
             const value = i1.Value().toFixed(4);
             return `\\[\\int_{${a}}^{${b}} f(x) \\, dx = ${value}\\]`;
 
         });
             document.getElementById('integralLabel').innerHTML = `\\[
                \\int_{${a}}^{${b}} f(t) \\, dt = ${value}
            \\]`;
 
            MathJax.typesetClear();  // Vorherige Formeln löschen
            MathJax.typesetPromise(); // Neu rendern
         }
 
        // Event-Listener für die Endpunkte des Integrals
        i1.baseLeft.on('drag', updateIntegralLabel);
        i1.baseRight.on('drag', updateIntegralLabel);


         // MathJax nach jeder Änderung neu ausführen
         // Erstes Rendern
         i1.label.onUpdate = function() {
         updateIntegralLabel();
            // MathJax neu rendern
            if (typeof MathJax !== 'undefined' && MathJax.typesetPromise) {
                MathJax.typesetPromise();
            }
        };


        // Beschriftung der Funktion mit f
        board.create('text', [3.5, 3, 'f'], {
            fontSize: 16,
            fixed: true,
            anchorX: 'left',
            anchorY: 'bottom',
            color: 'blue'
        });
     </script>
     </script>
</body>
</body>