уравнение

Discussion in 'Болталка' started by shuba, 21 May 2012.

  1. shuba

    shuba Elder - Старейшина

    Joined:
    22 May 2009
    Messages:
    582
    Likes Received:
    124
    Reputations:
    52
    С такой проблемой столкнулся...
    Необходимо написать программу в паскале, которая вычисляет это лютое уравнение:

    cosx*chx+1=0

    Да ладно программу, мне бы просто его решение)
     
  2. Kaimi

    Kaimi Well-Known Member

    Joined:
    23 Aug 2007
    Messages:
    1,732
    Likes Received:
    809
    Reputations:
    231
    http://www.wolframalpha.com/input/?i=cos%28x%29*ch%28x%29%2B1%3D0
     
    _________________________
  3. shuba

    shuba Elder - Старейшина

    Joined:
    22 May 2009
    Messages:
    582
    Likes Received:
    124
    Reputations:
    52
    я уже так пробовал, решение мне не понятно
     
  4. od1n0chka

    od1n0chka Member

    Joined:
    13 Dec 2010
    Messages:
    297
    Likes Received:
    47
    Reputations:
    1
    разбирайся на delphi
    PHP:
    unit Unit1

    {
    $mode objfpc}{$H+}

    interface

    uses
      Classes
    SysUtilsFileUtilFormsControlsGraphicsDialogsStdCtrls,
      
    ExtCtrls,  LResources ;
     function 
    (x:real):real;
     
    procedure Graphika (a,b:  real);
    type

      
    TForm1 }

      
    TForm1 = class(TForm)
        
    Button1TButton;

        
    Image1TImage;
        
    procedure Button1Click(SenderTObject);
         
    procedure formcreatesendertobject);


      private

        { private 
    declarations }
      public
        { public 
    declarations }
      
    end

    var
      
    Form1TForm1;
      
    x0,xk,y0,yk,a,breal ;
      
    x,: array [0..1000of real;
      
    u,: array [0..1000of integer;
      
    integer;
        
    c,:real;
        const 
    pi=3.14;

    implementation
      
    function (x:real) : real;
      
    begin
     
    if x<=0 then result:=sin(x/2)
     else 
    result :=sqrt((1+x)/3);
       
    end;
           
    procedure Graphika (a,breal);
           const 
    Kx=5Ky=5;
             var 
    dx,dy,c,d,g,h,max,min  real;
               
    itempx,tempy integer;
               
    :string;
        
    begin
          h
    :=(b-a)/(N-1);
          
    x[0]:=a;
          
    y[0]:=f(x[0]);
          for 
    i:=1 to N do
    begin
      x
    [i]:=x[i-1]+h;
      
    y[i]:=f(x[i]);
      
    end;
         
    max :=y[0];
         
    min:=y[0];
         for 
    i:=1 to N do
         
    begin
           
    if y[i]>max then max :=y[i];
           if 
    y[i]<min then min:=y[i];
           
    end;
         
    c:=(Form1.Image1.ClientWidth-x0-xk)/(b-a);
         
    d:=x0-c*x[0];
         
    g:=(Form1.Image1.ClientHeight -y0-yk)/(min-max);
         
    h:=yk-g*max;
         for 
    i:=0 to N do
         
    begin
           u
    [i] :=trunc (c*x[i]+d);
           
    v[i] :=trunc (g*y[i]+h);
           
    end;
         
    Form1.Image1.Canvas.pen.color := clGray;
           
    Form1.Image1.Canvas.Pen.Mode :=pmNot;
             
    Form1.Image1.Canvas.Moveto (u[0],v[0]);
               
    Form1.Image1.Canvas.Pen.width :=;
                 
    Form1.Image1.Canvas.pen.color :=clgreen;
                 for 
    i:=1 to N do
                          
    Form1.Image1.Canvas.Lineto (u[i],v[i]);
                     
    Form1.Image1.Canvas.Pen.Width :=1;
                       
    Form1.Image1.Canvas.pen.color :=clblack;
                       
    Form1.image1.canvas.Moveto(trunc(x0),trunc(h));
                       if (
    trunc(h)>yk) and
                       (
    trunc(h)<trunc(Form1.Image1.Clientheight-y0 ))
                       
    then
                       form1
    .Image1.canvas.LineTo(trunc
                       
    (form1.Image1.clientwidth-xk),trunc(h));
                        
    form1.image1.canvas.moveto(trunc(d),trunc(yk));
                        if (
    trunc(d)>x0) and
                         (
    trunc(d)<trunc(form1.Image1.clientwidth-xk))
                         
    then
                        form1
    .image1.canvas.lineto(trunc(d),
                          
    trunc(Form1.Image1.clientheight-y0));
                       
    dx:=(Form1.Image1.ClientWidth-x0-xk)/KX;
                       for 
    i:=0 to KX do
                       
    begin
                         
    if (i=0) or (i=KXthen
                         form1
    .image1.canvas.pen.style:=pssolid
                         
    else
                           
    form1.image1.Canvas.pen.style:=psdash;
                         
    form1.image1.canvas.moveto(trunc(x0+i*dx),
                         
    trunc(yk  ));
                         
    form1.image1.canvas.lineto(trunc(x0+i*dx),
                         
    trunc(form1.Image1.clientheight -y0));
                         
    end;

                
    dy:= (form1.image1.clientheight -y0-yk)/KY;
         for 
    i:=0 to KY do
         
    begin
           
    if (i=0) or (i=KYthen
             Form1
    .Image1.canvas.pen.style:=pssolid
           
    else
           
    form1.Image1.canvas.Pen.Style:=psDash;
           
    Form1.Image1.Canvas.moveto(trunc(x0),trunc(yk+i*dy));
           
    form1.image1.canvas.lineto(trunc
           
    (form1.Image1.clientwidth -xk),trunc(yk+i*dy));
           
    end;
           
    form1.image1.canvas.pen.Style :=pssolid;
           
    dx := (b-a)/KX;
           
    tempy :=     trunc(form1.image1.clientheight y0+10);
           for 
    i:=0 to KX do
           
    begin
             str
    (a+i*dx:5:2,s);
           
    tempx :=trunc(x0+i*(form1.image1.clientwidth x0-xk)/KX)-10;
              
    Form1.image1.canvas.textout(tempx,tempy,s);
           
    end;
           if (
    trunc(d)>x0) and
           (
    trunc(d)<form1.Image1.ClientWidth-xkthen
           form1
    .image1.canvas.textout(trunc(d)-5,tempy,'0' );
           
    dy:=(max-min)/KY;
           
    tempx :=5;
           for 
    i:=0 to KY do
           
    begin
             str
    (max-i*dy:5:2,s);
             
    tempy :=trunc(yk-5+
             
    i*(form1.Image1.clientheight-y0-yk)/KY);
            
    form1.image1.canvas.TextOut(tempx,tempy,s);
         
    end;
            if (
    trunc(h)>yk) and (trunc (h)<
            
    Form1.image1.ClientHeight-y0)then
            Form1
    .image1.Canvas.TextOut(tempx+10trunc(h)-5,'0');
            
    tempx:=trunc(x0+i*(form1.image1.clientwidth x0-xk)/2);
            
    Form1.Image1.canvas.textout(tempx,10'график функции');
         
    end;
           {
    tform1}

           
    procedure TForm1.formcreate(sendertobject);

           var 
    string;  kod integer;


        
    begin
         N
    := 100;
         
    x0:=40;
         
    xk:=40;
         
    y0:=40;
         
    yk:=40;
         
    repeat
           s
    := Inputbox('график непрерывной функции',
                             
    'введите левую границу','-9');
           
    Val (s,a,kod);
           
    until kod=0;
           
    repeat
             s
    :=(inputbox('график непрерывный функции ',
             
    'Введите границу','9'));
           
    val (s,b,kod);
           
    until kod=0;
           
    end;





                  
    procedure TForm1.Button1Click(SenderTObject);
           
    begin
             Graphika
    a,b);
           
    end;




           
    initialization

           
    {$I unit1.lrs}
           
    end.