Exemplo n.º 1
0
 public float CalculaX(float x)
 {
     if (Expresion.Equals("a*sen(b*x)"))
     {
         return(float.Parse(A) * (float)(Math.Sin(x * float.Parse(B)) + 4) / 8);
     }
     if (Expresion.Equals("a*cos(b*x)"))
     {
         return(float.Parse(A) * (float)(Math.Cos(x * float.Parse(B)) + 4) / 8);
     }
     if (Expresion.Equals("a*x^n"))
     {
         return(float.Parse(A) * (float)Math.Pow((double)x, double.Parse(Const)));
     }
     if (Expresion.Equals("a*x+b"))
     {
         return(float.Parse(A) * x + float.Parse(B));
     }
     if (Expresion.Equals("a*x2+b*x+c"))
     {
         return(float.Parse(A) * x * x + float.Parse(B) * x + float.Parse(C));
     }
     if (Expresion.Equals("a/(b*x)"))
     {
         if (x == 0)
         {
             return(0);
         }
         else
         {
             return(float.Parse(A) / (x * float.Parse(B)));
         }
     }
     return(0);
 }