Exemplo n.º 1
0
 public override void CopyDerivedFunctionToStack(ExpressionTree cur, ExpressionTree inner, StaticStack<MathOperation> DeriveStack, MathState State)
 {
     //ln(x)' = 1/x
     // 1 x /
     DeriveStack.Push((Number)1);
     inner.CopyToStack(DeriveStack);
     DeriveStack.Push(State.GetOperator("/"));
 }
Exemplo n.º 2
0
 public virtual void CopyDerivedFunctionToStack(ExpressionTree cur,ExpressionTree inner, StaticStack<MathOperation> DeriveStack,MathState State)
 {
     throw new MathEvaluator.Exceptions.UndefinedResultException(ToString() + " is not derivable");
 }
Exemplo n.º 3
0
 public override void CopyDerivedFunctionToStack(ExpressionTree cur, ExpressionTree inner, StaticStack<MathOperation> DeriveStack, MathState State)
 {
     //sqrt(x)' = 1/(2*sqrt(x))
     // 1 2 x sqrt * /
     DeriveStack.Push((Number)1,(Number)2);
     inner.CopyToStack(DeriveStack);
     DeriveStack.Push(State.GetFunction("sqrt"), State.GetOperator("*"), State.GetOperator("/"));
 }
Exemplo n.º 4
0
                public override void CopyDerivedFunctionToStack(ExpressionTree cur, ExpressionTree inner, StaticStack<MathOperation> DeriveStack, MathState State)
                {
                    //sqrt(x)' = 1/(x * ln 10)
                    // 1 x 10 ln * /

                    DeriveStack.Push((Number)1);
                    inner.CopyToStack(DeriveStack);
                    DeriveStack.Push((Number)10,State.GetFunction("ln"),State.GetOperator("*"), State.GetOperator("/"));
                }
Exemplo n.º 5
0
 public override void CopyDerivedFunctionToStack(ExpressionTree cur,ExpressionTree inner, StaticStack<MathOperation> DeriveStack,MathState State)
 {
     inner.CopyToStack(DeriveStack);
     DeriveStack.Push(State.GetFunction("cos"));
 }
Exemplo n.º 6
0
 public override void CopyDerivedFunctionToStack(ExpressionTree cur, ExpressionTree inner, StaticStack<MathOperation> DeriveStack,MathState State)
 {
     inner.CopyToStack(DeriveStack);
     DeriveStack.Push(State.GetFunction("sin"), (Number)(-1), State.GetOperator("*"));
 }
Exemplo n.º 7
0
 public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
 {
     DeriveStack.Push((Number)0);
 }
Exemplo n.º 8
0
                public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
                {
                    //f(x) = u(v(x))
                    //f'(x) = u'(v(x))*v'(x)
                    // v u' v' *
                    if(ArgumentCount != 1)
                        throw new MathEvaluator.Exceptions.UndefinedResultException(ToString() + " is not derivable");
                    ExpressionTree inner = cur.FunctionParameters[0];

                    CopyDerivedFunctionToStack(cur,inner, DeriveStack,State);
                    inner.DeriveToStack(DeriveStack,State);
                    DeriveStack.Push(new Multiplication());
                }
Exemplo n.º 9
0
 public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
 {
     throw new UndefinedResultException(ToString() + " is not derivable");
 }
Exemplo n.º 10
0
 public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
 {
     DeriveStack.Push((Number)(_name.ToLower() == "x" ? 1 : 0));
 }
Exemplo n.º 11
0
                public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
                {
                    // (f(x)^g(x))'
                    // f(x)^(g(x)-1) (g(x) f'(x)+f(x) ln(f(x)) g'(x))
                    // f(x) g(x) 1 - ^ g(x) f'(x) * f(x) f(x) ln * + * g'(x) *
                    //  f g 1 - ^ g v * f f ln * b * + *
                    ExpressionTree f = cur.Left;
                    ExpressionTree g = cur.Right;
                    f.CopyToStack(DeriveStack);
                    g.CopyToStack(DeriveStack);
                    DeriveStack.Push((Number)1, State.GetOperator("-"), State.GetOperator("^"));
                    g.CopyToStack(DeriveStack);
                    f.DeriveToStack(DeriveStack,State);
                    DeriveStack.Push(State.GetOperator("*"));
                    f.CopyToStack(DeriveStack);
                    f.CopyToStack(DeriveStack);
                    DeriveStack.Push(State.GetFunction("ln"), State.GetOperator("*"));
                    g.DeriveToStack(DeriveStack,State);
                    DeriveStack.Push(State.GetOperator("*"), State.GetOperator("+"), State.GetOperator("*"));

                    /*
                    if (cur.Left.ContainsVariable("x"))
                    {
                        //(x^n)' = n * x^(n-1)
                        ExpressionTree left = cur.Left;
                        ExpressionTree right = cur.Right;

                        right.CopyToStack(DeriveStack);
                        left.CopyToStack(DeriveStack);
                        right.CopyToStack(DeriveStack);
                        DeriveStack.Push((Number)1,State.GetOperator("-"),State.GetOperator("^"),State.GetOperator("*"));
                    }
                    else if (cur.Right.ContainsVariable("x"))
                    {
                        // (a^x)' = a^x * ln a
                        // a x ^ a ln *
                        ExpressionTree left = cur.Left;
                        ExpressionTree right = cur.Right;

                        left.CopyToStack(DeriveStack);
                        right.CopyToStack(DeriveStack);
                        DeriveStack.Push(State.GetOperator("^"));

                        left.CopyToStack(DeriveStack);
                        DeriveStack.Push(State.GetFunction("ln"), State.GetOperator("*"));

                        //chain rule
                        right.DeriveToStack(DeriveStack, State);
                        DeriveStack.Push(State.GetOperator("*"));
                    }
                    else if (cur.Left.ToString() == "e" && cur.Right.ToString() == "x")
                    {
                        cur.Left.CopyToStack(DeriveStack);
                        cur.Right.CopyToStack(DeriveStack);
                        DeriveStack.Push(this);
                    }
                    else
                    {
                        DeriveStack.Push((Number)0);
                    }*/
                }
Exemplo n.º 12
0
                public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
                {
                    //(u * v)' = u' * v + u * v'
                    //PF:      = u' v * u v' * +
                    ExpressionTree left = cur.Left;
                    ExpressionTree right = cur.Right;

                    left.DeriveToStack(DeriveStack,State);
                    right.CopyToStack(DeriveStack);
                    DeriveStack.Push(State.GetOperator("*"));
                    left.CopyToStack(DeriveStack);
                    right.DeriveToStack(DeriveStack,State);
                    DeriveStack.Push(State.GetOperator("*"), State.GetOperator("+"));
                }
Exemplo n.º 13
0
 public abstract void DeriveToStack(ExpressionTree cur,MathState State,StaticStack<MathOperation> DeriveStack);
Exemplo n.º 14
0
                public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
                {
                    //(u * v)' = (u'v - uv')/v²
                    //PF:      = u' v * u v' * - v 2 ^ /
                    ExpressionTree left = cur.Left;
                    ExpressionTree right = cur.Right;

                    left.DeriveToStack(DeriveStack,State);
                    right.CopyToStack(DeriveStack);

                    DeriveStack.Push(State.GetOperator("*"));
                    left.CopyToStack(DeriveStack);
                    right.DeriveToStack(DeriveStack,State);
                    DeriveStack.Push(State.GetOperator("*"), State.GetOperator("-"));
                    right.CopyToStack(DeriveStack);
                    DeriveStack.Push((Number)2, State.GetOperator("^"), State.GetOperator("/"));
                }
Exemplo n.º 15
0
 public override void DeriveToStack(ExpressionTree cur, MathState State, StaticStack<MathOperation> DeriveStack)
 {
     cur.Left.DeriveToStack(DeriveStack, State);
     cur.Right.DeriveToStack(DeriveStack, State);
     DeriveStack.Push(this);
 }