public override Sexpr diff(Sexpr v) { return Symbolic.mult(argument.diff(v), new Exp(argument)); }
public static Sexpr sin(Sexpr arg) { if (arg.isConstant()) return new Constant(Math.Sin(arg.getValue())); else return new Sin(arg); }
public override Sexpr diff(Sexpr v) { if(name.Equals(v.ToString())) return new Constant(1); else return new Constant(0); }
public static Sexpr exp(Sexpr arg) { if (arg.isConstant()) return new Constant(Math.Exp(arg.getValue())); else return new Exp(arg); }
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); }
public override Sexpr diff(Sexpr v) { return Symbolic.sub(left.diff(v), right.diff(v)); }
public static Sexpr cos(Sexpr arg) { if (arg.isConstant()) return new Constant(Math.Cos(arg.getValue())); else return new Cos(arg); }
public Mult(Sexpr x, Sexpr y) : base(x,y) { }
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))); }
public Assignment(Sexpr s, Sexpr v) : base(s, v) { }
public MonOp(Sexpr t) : base() { tecken=t; }
public override Sexpr diff(Sexpr v) { return Symbolic.mult(argument.diff(v), new Div(new Constant(1), argument)); }
public Log(Sexpr a) : base(a) { }
public Function(Sexpr a) : base() { argument=a; }
public override Sexpr diff(Sexpr h) { return Symbolic.mult(argument.diff(h), new Cos(argument)); }
public Negation(Sexpr t) : base(t) { }
public Subtraction(Sexpr x, Sexpr y) : base(x,y) { }
public override Sexpr diff(Sexpr v) { return Symbolic.neg(tecken.diff(v)); }
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); }
public override Sexpr diff(Sexpr v) { return new Constant(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); } }
public Quot(Sexpr t) : base(t) { }
public static Sexpr log(Sexpr arg) { if (arg.isConstant()) return new Constant(Math.Log(arg.getValue())); else return new Log(arg); }
public override Sexpr diff( Sexpr v) { return tecken.diff(v); }
public static Sexpr neg(Sexpr tecken) { if (tecken.isConstant()) return new Constant(-(tecken.getValue())); else return new Negation(tecken); }
public abstract Sexpr diff(Sexpr v);
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); }
public Sin(Sexpr a) : base(a) { }
public addition(Sexpr l, Sexpr r) : base(l,r) { }
public Exp(Sexpr a) : base(a) { }