예제 #1
0
 public override Sexpr diff(Sexpr v)
 {
     return Symbolic.mult(argument.diff(v), new Exp(argument));
 }
예제 #2
0
 public static Sexpr sin(Sexpr arg)
 {
     if (arg.isConstant())
         return new Constant(Math.Sin(arg.getValue()));
     else
         return new Sin(arg);
 }
예제 #3
0
 public override Sexpr diff(Sexpr v)
 {
     if(name.Equals(v.ToString()))
         return new Constant(1);
     else
         return new Constant(0);
 }
예제 #4
0
 public static Sexpr exp(Sexpr arg)
 {
     if (arg.isConstant())
         return new Constant(Math.Exp(arg.getValue()));
     else
         return new Exp(arg);
 }
예제 #5
0
        public static Sexpr mult(Sexpr l, Sexpr r)
        {
            if(l.isConstant() && r.isConstant())
            return new Constant(l.getValue() * r.getValue());

            else if(l.isZero() || r.isZero())
            return new Constant(0);

            else if(l.isOne())
            return r;
            else if(r.isOne())
            return l;

            else
            return new Mult(l,r);
        }
예제 #6
0
 public override Sexpr diff(Sexpr v)
 {
     return Symbolic.sub(left.diff(v), right.diff(v));
 }
예제 #7
0
 public static Sexpr cos(Sexpr arg)
 {
     if (arg.isConstant())
         return new Constant(Math.Cos(arg.getValue()));
     else
         return new Cos(arg);
 }
예제 #8
0
 public Mult(Sexpr x, Sexpr y)
     : base(x,y)
 {
 }
예제 #9
0
        public override Sexpr diff(Sexpr v)
        {
            if(left.isConstant() && right.isConstant())
                return new Constant(0);

                else
                return Symbolic.add(Symbolic.mult(left.diff(v), right),
                        Symbolic.mult(left, right.diff(v)));
        }
예제 #10
0
 public Assignment(Sexpr s, Sexpr v)
     : base(s, v)
 {
 }
예제 #11
0
 public MonOp(Sexpr t)
     : base()
 {
     tecken=t;
 }
예제 #12
0
 public override Sexpr diff(Sexpr v)
 {
     return Symbolic.mult(argument.diff(v), new Div(new Constant(1), argument));
 }
예제 #13
0
 public Log(Sexpr a)
     : base(a)
 {
 }
예제 #14
0
 public Function(Sexpr a)
     : base()
 {
     argument=a;
 }
예제 #15
0
 public override Sexpr diff(Sexpr h)
 {
     return Symbolic.mult(argument.diff(h),
                        new Cos(argument));
 }
예제 #16
0
 public Negation(Sexpr t)
     : base(t)
 {
 }
예제 #17
0
 public Subtraction(Sexpr x, Sexpr y)
     : base(x,y)
 {
 }
예제 #18
0
 public override Sexpr diff(Sexpr v)
 {
     return Symbolic.neg(tecken.diff(v));
 }
예제 #19
0
        public static Sexpr add(Sexpr l, Sexpr r)
        {
            if (l.isConstant() && r.isConstant())
            {
                Sexpr ret = new Constant(l.getValue() + r.getValue());

                // return new Constant(l.getValue() + r.getValue());
                return ret;
            }
            else if (l.isZero())
                return r;

            else if (r.isZero())
                return l;

            else
                return new addition(l, r);
        }
예제 #20
0
 public override Sexpr diff(Sexpr v)
 {
     return new Constant(0);
 }
예제 #21
0
        public static Sexpr div(Sexpr l, Sexpr r)
        {
            if(r.isZero())
            throw new CalculatorException("F�r inte dela med noll");

            else
            {
            if(l.isConstant() && r.isConstant())
                return new Constant(l.getValue() / r.getValue());

            else if(l.isZero())
                return new Constant(0);

            else
                return new Div(l,r);
            }
        }
예제 #22
0
 public Quot(Sexpr t)
     : base(t)
 {
 }
예제 #23
0
 public static Sexpr log(Sexpr arg)
 {
     if (arg.isConstant())
         return new Constant(Math.Log(arg.getValue()));
     else
         return new Log(arg);
 }
예제 #24
0
 public override Sexpr diff( Sexpr v)
 {
     return tecken.diff(v);
 }
예제 #25
0
 public static Sexpr neg(Sexpr tecken)
 {
     if (tecken.isConstant())
         return new Constant(-(tecken.getValue()));
     else
         return new Negation(tecken);
 }
예제 #26
0
 public abstract Sexpr diff(Sexpr v);
예제 #27
0
        public static Sexpr sub(Sexpr l, Sexpr r)
        {
            if(l.isConstant() && r.isConstant())
               return new Constant(l.getValue() - r.getValue());

            else if(l.isZero())
                return new Negation(r);

            else if(r.isZero())
                return l;

            else
                return new Subtraction(l,r);
        }
예제 #28
0
 public Sin(Sexpr a)
     : base(a)
 {
 }
예제 #29
0
 public addition(Sexpr l, Sexpr r)
     : base(l,r)
 {
 }
예제 #30
0
 public Exp(Sexpr a)
     : base(a)
 {
 }