Построение графика функции - C# (204796)
Формулировка задачи:
Задача построить график функции f(x) при a=<x=<b функция y= 3*x-4*Ln(x-5)... решение через forms. a=2 b=5 n=30
во первых не разбирусь куда вписывать n
набросал вот такую программу
Выдается вот такая ошибка
"Не удается явно преобразовать int в double." Если задавать переменные как double то вылетает куча ошибок.
помогите.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Form1_Resize(object sender, EventArgs e)
{
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
int xs = this.Width / 2; //THIS в данном случае-форма
int yc = this.Height / 2;
g.TranslateTransform(xs, yc);
g.DrawEllipse(new Pen(Color.Red, 8.0f), 0, 0, 1, 1);
int x, y;
//вычерчивание осей координат
g.DrawLine(new Pen(Color.Brown, 1.0f), -200, 0, 200, 0);
g.DrawLine(new Pen(Color.Brown, 1.0f), 0, -200, 0, 200);
//вычерчивание графика функции
for (x = 2; x <= 5; x += 1)
{
y = 3*x-4*Math.Log(x-4);
g.DrawEllipse(new Pen(Color.Blue, 2.0f), x * 5, -y, 1, 1);
}
}
}
}Решение задачи: «Построение графика функции»
textual
Листинг программы
//вычерчивание осей координат g.DrawLine(new Pen(Color.Brown, 3.0f), -1*xs, 0, xs, 0); g.DrawLine(new Pen(Color.Brown, 1.0f), 0, yc, 0, -1*yc);