Beispiel #1
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("/"));
                }
Beispiel #2
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("/"));
 }
Beispiel #3
0
 public override void CopyDerivedFunctionToStack(ExpressionTree cur,ExpressionTree inner, StaticStack<MathOperation> DeriveStack,MathState State)
 {
     inner.CopyToStack(DeriveStack);
     DeriveStack.Push(State.GetFunction("cos"));
 }
Beispiel #4
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("*"));
 }
Beispiel #5
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);
                    }*/
                }