Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Map;
- import java.util.TreeMap;
- public class Plus extends BinaryExpression implements Expression{
- //constructor
- public Plus(Expression firstExp, Expression secondExp){
- super(firstExp, secondExp);
- }
- protected Expression getOperation(Expression first, Expression second) {
- return new Plus(first,second);
- }
- protected String getOperationString() {
- return "+";
- }
- protected double returnExp(double first, double second) {
- return first + second;
- }
- protected Expression getDifRules(Expression first, Expression second, Expression
- firstDx, Expression secondDx) {
- return new Plus(firstDx,secondDx);
- }
- public static void main(String args[]) throws Exception {
- Expression e2 = new Sin(new Var("x"));
- System.out.println(e2);
- System.out.println(e2.differentiate("x"));
- Expression e = new Div(new Num(1),new Var("y"));
- System.out.println(e);
- System.out.println(e.differentiate("y"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement