Home
Random example
Search
Applications
Chemistry
Economy
Famous theorems
Geography
Physics
Sports
Test
Assessment
Calculus
3D
Applied calculus
Basic calculus
Differential equations
Function plotting
Implicit plotting
Sequences and series
Charts and data
Charts
Statistics
Curves
Interpolation
Intersection, Union, Difference
Lindenmayer Systems
Splines
Geometry
3D
Analytic
Euclidean
Basic constructions
Mappings
Non-Euclidean
Projective
Symmetry
Technical
Animation
Roulettes
Board options
First steps
Images
JSXGraph objects
Arcs and angles
Axes
Circles
Groups
Lines and arrows
Point
Polygons
Slider
Turtle
Vectors
JessieCode
Texts
Transformations
Video
jsxgraph.org
JSXGraph logo
JSXGraph
JSXGraph share

Share

3D function graph with gradient plane
Show plain example
QR code
<iframe 
    src="https://www.jsxgraph.org/share/iframe/3d-function-graph-with-gradient-plane" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: 3D function graph with gradient plane" 
    allowfullscreen
></iframe>
This code has to
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 1 / 1; width: 100%;" data-ar="1 / 1"></div>
</div>

<script type = "text/javascript"> 
    /*
    This example is licensed under a 
    Creative Commons Attribution ShareAlike 4.0 International License.
    https://creativecommons.org/licenses/by-sa/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID = 'board-0';

    var board = JXG.JSXGraph.initBoard(BOARDID, {
        boundingbox: [-8, 8, 8, -8],
        keepaspectratio: false,
        axis: false
    });
    
    var box = [-5, 5];
    var view = board.create('view3d',
        [
            [-6, -3],
            [8, 8],
            [box, box, box]
        ], {
            xPlaneRear: {
                visible: false
            },
            yPlaneRear: {
                visible: false
            },
        });
    
    // Slider to manipulate the function F below.
    var s = board.create('slider', [[-7, -6], [5, -6], [-3, 0.3, 4]], {name: 's'});
    
    // Function F to be plotted
    var F = (x, y) => s.Value() * x * y + 2;
    
    // 3D surface
    var c = view.create('functiongraph3d', [F, box, box], {
        strokeWidth: 0.5,
        stepsU: 70,
        stepsV: 70
    });
    
    // 3D point: point on xy plane
    var Axy = view.create('point3d', [2, 2, -5], {
        withLabel: false,
        size: 5
    });
    
    // Project Axy to the surface
    var A = view.create('point3d', [
       () => [Axy.X(), Axy.Y(), F(Axy.X(), Axy.Y())]
    ], {
        withLabel: false
    });
    view.create('line3d', [Axy, A], {
        dash: 1
    });
    
    // Hard coded, partial derivatives of F in point A
    var dFx = () => s.Value() * A.Y(),
        dFy = () => s.Value() * A.X(),
        dFx_vec = [1, 0, dFx],
        dFy_vec = [0, 1, dFy];
    
    // Gradient plane
    var plane1 = view.create('plane3d', [A, dFx_vec, dFy_vec, [() => -dFx(), dFx], [() => -dFy(), dFy]], {
        fillOpacity: 0.8,
        fillColor: 'red'
    });
    var a = view.create('line3d', [A, dFx_vec, [0, dFx]]);
    var b = view.create('line3d', [A, dFy_vec, [0, dFy]]);
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution ShareAlike 4.0 International License.
https://creativecommons.org/licenses/by-sa/4.0/

Please note you have to mention 
The Center of Mobile Learning with Digital Technology
in the credits.
*/

const BOARDID = 'your_div_id'; // Insert your id here!

var board = JXG.JSXGraph.initBoard(BOARDID, {
    boundingbox: [-8, 8, 8, -8],
    keepaspectratio: false,
    axis: false
});

var box = [-5, 5];
var view = board.create('view3d',
    [
        [-6, -3],
        [8, 8],
        [box, box, box]
    ], {
        xPlaneRear: {
            visible: false
        },
        yPlaneRear: {
            visible: false
        },
    });

// Slider to manipulate the function F below.
var s = board.create('slider', [[-7, -6], [5, -6], [-3, 0.3, 4]], {name: 's'});

// Function F to be plotted
var F = (x, y) => s.Value() * x * y + 2;

// 3D surface
var c = view.create('functiongraph3d', [F, box, box], {
    strokeWidth: 0.5,
    stepsU: 70,
    stepsV: 70
});

// 3D point: point on xy plane
var Axy = view.create('point3d', [2, 2, -5], {
    withLabel: false,
    size: 5
});

// Project Axy to the surface
var A = view.create('point3d', [
   () => [Axy.X(), Axy.Y(), F(Axy.X(), Axy.Y())]
], {
    withLabel: false
});
view.create('line3d', [Axy, A], {
    dash: 1
});

// Hard coded, partial derivatives of F in point A
var dFx = () => s.Value() * A.Y(),
    dFy = () => s.Value() * A.X(),
    dFx_vec = [1, 0, dFx],
    dFy_vec = [0, 1, dFy];

// Gradient plane
var plane1 = view.create('plane3d', [A, dFx_vec, dFy_vec, [() => -dFx(), dFx], [() => -dFy(), dFy]], {
    fillOpacity: 0.8,
    fillColor: 'red'
});
var a = view.create('line3d', [A, dFx_vec, [0, dFx]]);
var b = view.create('line3d', [A, dFy_vec, [0, dFy]]);
<jsxgraph width="100%" aspect-ratio="1 / 1" title="3D function graph with gradient plane" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false">
   /*
   This example is licensed under a 
   Creative Commons Attribution ShareAlike 4.0 International License.
   https://creativecommons.org/licenses/by-sa/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   var board = JXG.JSXGraph.initBoard(BOARDID, {
       boundingbox: [-8, 8, 8, -8],
       keepaspectratio: false,
       axis: false
   });
   
   var box = [-5, 5];
   var view = board.create('view3d',
       [
           [-6, -3],
           [8, 8],
           [box, box, box]
       ], {
           xPlaneRear: {
               visible: false
           },
           yPlaneRear: {
               visible: false
           },
       });
   
   // Slider to manipulate the function F below.
   var s = board.create('slider', [[-7, -6], [5, -6], [-3, 0.3, 4]], {name: 's'});
   
   // Function F to be plotted
   var F = (x, y) => s.Value() * x * y + 2;
   
   // 3D surface
   var c = view.create('functiongraph3d', [F, box, box], {
       strokeWidth: 0.5,
       stepsU: 70,
       stepsV: 70
   });
   
   // 3D point: point on xy plane
   var Axy = view.create('point3d', [2, 2, -5], {
       withLabel: false,
       size: 5
   });
   
   // Project Axy to the surface
   var A = view.create('point3d', [
      () => [Axy.X(), Axy.Y(), F(Axy.X(), Axy.Y())]
   ], {
       withLabel: false
   });
   view.create('line3d', [Axy, A], {
       dash: 1
   });
   
   // Hard coded, partial derivatives of F in point A
   var dFx = () => s.Value() * A.Y(),
       dFy = () => s.Value() * A.X(),
       dFx_vec = [1, 0, dFx],
       dFy_vec = [0, 1, dFy];
   
   // Gradient plane
   var plane1 = view.create('plane3d', [A, dFx_vec, dFy_vec, [() => -dFx(), dFx], [() => -dFy(), dFy]], {
       fillOpacity: 0.8,
       fillColor: 'red'
   });
   var a = view.create('line3d', [A, dFx_vec, [0, dFx]]);
   var b = view.create('line3d', [A, dFy_vec, [0, dFy]]);
</jsxgraph>

3D function graph with gradient plane

3D
Calculus
Function plotting
This is an example for a function graph together with the gradient plane.
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, {
    boundingbox: [-8, 8, 8, -8],
    keepaspectratio: false,
    axis: false
});

var box = [-5, 5];
var view = board.create('view3d',
    [
        [-6, -3],
        [8, 8],
        [box, box, box]
    ], {
        xPlaneRear: {
            visible: false
        },
        yPlaneRear: {
            visible: false
        },
    });

// Slider to manipulate the function F below.
var s = board.create('slider', [[-7, -6], [5, -6], [-3, 0.3, 4]], {name: 's'});

// Function F to be plotted
var F = (x, y) => s.Value() * x * y + 2;

// 3D surface
var c = view.create('functiongraph3d', [F, box, box], {
    strokeWidth: 0.5,
    stepsU: 70,
    stepsV: 70
});

// 3D point: point on xy plane
var Axy = view.create('point3d', [2, 2, -5], {
    withLabel: false,
    size: 5
});

// Project Axy to the surface
var A = view.create('point3d', [
   () => [Axy.X(), Axy.Y(), F(Axy.X(), Axy.Y())]
], {
    withLabel: false
});
view.create('line3d', [Axy, A], {
    dash: 1
});

// Hard coded, partial derivatives of F in point A
var dFx = () => s.Value() * A.Y(),
    dFy = () => s.Value() * A.X(),
    dFx_vec = [1, 0, dFx],
    dFy_vec = [0, 1, dFy];

// Gradient plane
var plane1 = view.create('plane3d', [A, dFx_vec, dFy_vec, [() => -dFx(), dFx], [() => -dFy(), dFy]], {
    fillOpacity: 0.8,
    fillColor: 'red'
});
var a = view.create('line3d', [A, dFx_vec, [0, dFx]]);
var b = view.create('line3d', [A, dFy_vec, [0, dFy]]);

license

This example is licensed under a Creative Commons Attribution ShareAlike 4.0 International License.
Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.