|
19 | 19 | import org.matheclipse.core.expression.ImplementationStatus;
|
20 | 20 | import org.matheclipse.core.expression.S;
|
21 | 21 | import org.matheclipse.core.interfaces.IAST;
|
22 |
| -import org.matheclipse.core.interfaces.IASTAppendable; |
23 | 22 | import org.matheclipse.core.interfaces.IExpr;
|
24 | 23 | import org.matheclipse.core.interfaces.IInteger;
|
25 | 24 | import org.matheclipse.core.visit.VisitorPlusTimesPowerReplaceAll;
|
@@ -109,8 +108,12 @@ private IExpr expandPlus(IAST ast, IAST plusAST) {
|
109 | 108 | return expandCoshSinhPlus(plusAST, true);
|
110 | 109 | } else if (ast.isAST(S.Csch, 2)) {
|
111 | 110 | return expandCschPlus(plusAST, 1);
|
| 111 | + } else if (ast.isAST(S.Coth, 2)) { |
| 112 | + // Cosh(x) / Sinh(x) |
| 113 | + return F.Divide(expandCoshSinhPlus(plusAST, true), expandCoshSinhPlus(plusAST, false)); |
112 | 114 | } else if (ast.isTanh()) {
|
113 |
| - return expandTanhPlus(plusAST, 1); |
| 115 | + // Sinh(x) / Cosh(x) |
| 116 | + return F.Divide(expandCoshSinhPlus(plusAST, false), expandCoshSinhPlus(plusAST, true)); |
114 | 117 | }
|
115 | 118 | return F.NIL;
|
116 | 119 | }
|
@@ -298,28 +301,6 @@ private static IExpr expandSechPlus(IAST plusAST, int startPosition) {
|
298 | 301 | F.Power(F.Plus(F.Times(F.Cosh(b), F.Cosh(a)), F.Times(F.Sinh(a), F.Sinh(b))), F.CN1)));
|
299 | 302 | }
|
300 | 303 |
|
301 |
| - /** |
302 |
| - * <code>Tanh(a+b+c+...)</code> |
303 |
| - * |
304 |
| - * @param plusAST |
305 |
| - * @param startPosition |
306 |
| - * @return |
307 |
| - */ |
308 |
| - private static IExpr expandTanhPlus(IAST plusAST, int startPosition) { |
309 |
| - IASTAppendable result = F.TimesAlloc(2); |
310 |
| - IExpr lhs = plusAST.get(startPosition); |
311 |
| - if (startPosition == plusAST.size() - 2) { |
312 |
| - // (Tanh(x)+Tanh(y)) / (1+Tanh(x)*Tanh(y)) |
313 |
| - IExpr rhs = plusAST.get(startPosition + 1); |
314 |
| - result.append(Plus(F.Tanh(lhs), F.Tanh(rhs))); |
315 |
| - result.append(F.Power(Plus(F.C1, Times(F.Tanh(lhs), F.Tanh(rhs))), F.CN1)); |
316 |
| - } else { |
317 |
| - result.append(Plus(F.Tanh(lhs), expandTanhPlus(plusAST, startPosition + 1))); |
318 |
| - result.append(F.Power( |
319 |
| - Plus(F.C1, Times(F.Tanh(lhs), expandTanhPlus(plusAST, startPosition + 1))), F.CN1)); |
320 |
| - } |
321 |
| - return result; |
322 |
| - } |
323 | 304 | }
|
324 | 305 |
|
325 | 306 | public TrigExpand() {}
|
|
0 commit comments