Skip to content

Commit

Permalink
https://github.com/crowlogic/arb4j/issues/253
Browse files Browse the repository at this point in the history
  • Loading branch information
crowlogic committed Dec 8, 2024
1 parent 6e5f954 commit ae84d8c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/arb/expressions/nodes/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,14 @@ public Node<D, R, F> cot()
return apply("cot");
}

public Node<D, R, F> sinh()
{
return apply("sinh");
}

public Node<D, R, F> cosh()
{
return apply("cosh");
}

}
5 changes: 5 additions & 0 deletions src/main/java/arb/expressions/nodes/unary/FunctionNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public Node<D, R, F> differentiate(VariableNode<D, R, F> variable)
*/
private Node<D, R, F> differentiateBuiltinFunction()
{

switch (functionName)
{
case "arcsin":
Expand All @@ -170,6 +171,10 @@ private Node<D, R, F> differentiateBuiltinFunction()
return arg.cos();
case "cos":
return arg.sin().neg();
case "sinh":
return arg.cosh();
case "cosh":
return arg.sinh();
case "exp":
return this;
case "log":
Expand Down
14 changes: 14 additions & 0 deletions src/test/java/arb/expressions/nodes/DerivativeNodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ public class DerivativeNodeTest extends
TestCase
{

public void testHyperbolicSineDerivative()
{
var f = RealFunction.parse("∂sinh(x)/∂x");
var df = RealFunction.parse("cosh(x)");
assertEquals(df.rootNode.toString(), f.rootNode.toString());
}

public void testHyperbolicCosineDerivative()
{
var f = RealFunction.parse("∂cosh(x)/∂x");
var df = RealFunction.parse("sinh(x)");
assertEquals(df.rootNode.toString(), f.rootNode.toString());
}

public void testCotangentDerivative()
{
var f = RealFunction.parse("∂cot(x)/∂x");
Expand Down

0 comments on commit ae84d8c

Please sign in to comment.