package org.lvcp.eepperly.expr;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by eepperly16 on 12/14/15.
 */
public class Arccosine extends Expr {
	public Arccosine(List<Expr> arguments) {
		super(arguments);
	}
	public Expr differentiate(){
		List <Expr> arcosineList = new ArrayList<>();
		arcosineList.add(arguments.get(0));
		arcosineList.add(Expr.TWO);
		Expr argSquared= new Exponential(arcosineList);
		List <Expr> sumList = new ArrayList<>();
		sumList.add(Expr.ONE);
		sumList.add(Product.unitaryNegation(argSquared));
		Expr sum = new Sum(sumList);
		List <Expr> toTheMinusOneHalfList = new ArrayList<>();
		toTheMinusOneHalfList.add(sum);
		toTheMinusOneHalfList.add(new NumConstant(-0.5));
		Expr toTheMinusOneHalf = new Exponential(toTheMinusOneHalfList);
		List <Expr> prodList = new ArrayList<>();
		prodList.add(toTheMinusOneHalf);
		prodList.add(arguments.get(0).differentiate());
		prodList.add(Expr.MINUS_ONE);
		return new Product(prodList);
	}

	public double evaluate(double value){
		return Math.acos(arguments.get(0).evaluate(value));
	}

	public String toString(){
		return ("arcos("+arguments.get(0).toString()+")");
	}

}

@@ -274,16 +274,17 @@
 xpr%3E arc
+c
 osineLis
@@ -303,32 +303,33 @@
 yList%3C%3E();%0A%09%09arc
+c
 osineList.add(ar
@@ -350,16 +350,17 @@
 );%0A%09%09arc
+c
 osineLis
@@ -414,16 +414,17 @@
 tial(arc
+c
 osineLis

Fix spelling for `arccosine`