, Visual C#



40.1. Form1_Load.

// z = f1 = f(x, y):

public float f(float x, float y)

{

float f1;

f1 = 2 * x * x * x * x - 3 * x * x + 4 * y * y;

return f1;

}

// df/dx:

public float df_dx(float x, float y)

{

float f2;

f2 = 8 * x * x * x - 6 * x;

return f2;

}

// df/dy:

public float df_dy(float x, float y)

{

float f3;

f3 = 8 * y;

return f3;

}

// :

Pen myPen;

 

// :

private void Form1_Load_1(object sender, EventArgs e)

{

// :

myPen = new Pen(Color.Black, 0);

// PictureBox1

// g Graphics:

Bitmap bmp = new Bitmap(pictureBox1.ClientSize.Width,

pictureBox1.ClientSize.Height);

Graphics g = Graphics.FromImage(bmp);

//

// PictureBox

//-2 <= x <= 2, -1.5 <= y <= 1.5:

float x_min = -2f;

float x_max = 2f;

float y_min = -1.5f;

float y_max = 1.5f;

g.ScaleTransform(bmp.Width / (x_max - x_min),

bmp.Height / (y_max - y_min));

g.TranslateTransform(-x_min, -y_min,

System.Drawing.Drawing2D.MatrixOrder.Prepend);

// :

for (int LevelCurves = -3; LevelCurves <= 25;

LevelCurves++)

PlotLevelCurve(g, Convert.ToSingle(

LevelCurves / 4),

-4f, 4f, -4f, 4f, 0.05f, 1f, 1f, 0.002f);

// :

pictureBox1.Image = bmp;

}

.

40.2.

.

// :

float initial_delta = 0.1f;