diff --git a/BREAKING-CHANGES.md b/BREAKING-CHANGES.md
index ba2ef27cf..fdc701c96 100644
--- a/BREAKING-CHANGES.md
+++ b/BREAKING-CHANGES.md
@@ -618,6 +618,23 @@ read them as nonzero. They are now decided over one bar, expanded, and at pinned
| `"e^(3*acoth(a*x))/(c-a*c*x)^3".Integrate("x")`, and over `(c - a c x)^4` | left unevaluated | an antiderivative in `sqrt((a x + 1)/(a x - 1))` |
| `"e^(2*acoth(a*x))*sqrt(c-a*c*x)/x".Integrate("x")`, and over `x^2` | left unevaluated | an antiderivative in `sqrt(c - a c x)`, by cases on the sign of `c` |
+### A trigonometric function of an imaginary multiple of a logarithm is integrated in exponentials
+
+**Answers where there were none.** `tan(a + i ln(x))` and `sin(a + ln(c x^2) sqrt(-1/4))` were
+declined: the closed form for a power of the variable times a sine or cosine of a logarithm divides
+by `(m + 1)^2 + B^2`, which an imaginary `B` can make zero, and Rubi's 4.7.5 is built on exactly
+that. `e^(i (a + b ln(u)))` is `e^(i a)` times a real power of `u` when `b` is imaginary, so each
+such function is a sum or quotient of powers of `u`, and is written so now when `b` is an imaginary
+number; the zero is a power `1/x`, whose integral is a logarithm. A symbolic `b`,
+`sqrt(-1/n^2)`, is left alone, since whether the zero is there turns on the sign of `n`
+([#718](https://github.com/asc-community/AngouriMath/issues/718)).
+
+| Input | Was (2.5.0) | Now |
+|---|---|---|
+| `"tan(a + i*ln(x))".ToEntity().Integrate("x")` | `integral(...)` | a rational function of `x` and `e^(i a)`, with a logarithm |
+| `"sin(a + ln(c*x^2)*sqrt(-1/4))".ToEntity().Integrate("x")` | `integral(...)` | powers of `x` and `c x^2` and a logarithm, through `e^(i a)` |
+| `"1/cos(a - 2*i*ln(c*x))^(3/2)".ToEntity().Integrate("x")` | `integral(...)` | an arctangent and a logarithm of a root, through `e^(i a)` |
+
### `e^(n i arctan(a x))` to a power that is not whole is integrated
**Answers where there were none.** `e^(n i arctan(L))` is written algebraically, as
diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
index 15d52c2cb..2f20ae968 100644
--- a/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Integration/IndefiniteIntegralSolver.cs
@@ -21977,6 +21977,95 @@ private static (Entity Factor, Entity Inside)? TryTakeACommonLinearFactorOfASum(
return back.Nodes.Any(node => node == MathS.NaN) ? null : back;
}
+ ///
+ /// A trigonometric function of a + b ln(u) with an imaginary b, written in
+ /// exponentials: e^(i (a + b ln(u))) is e^(i a) times the real power
+ /// u^(i b), so the sine, cosine and the rest are sums and quotients of powers of
+ /// u, which the rules for those answer.
+ ///
+ ///
+ /// sin(a + ln(c x^2) sqrt(-1/4)) and tan(a + i ln(x)) were declined: the closed
+ /// form for a power of the variable times a sine or cosine of a logarithm divides by
+ /// (m + 1)^2 + B^2, which an imaginary B makes zero, and Rubi's 4.7.5 has 62
+ /// problems built on exactly that, with b = sqrt(-(m + 1)^2/n^2). In exponentials the
+ /// zero is a power of x that is 1/x, and its integral a logarithm. Only for a
+ /// number: a real b is the closed form's, after which this is asked, and a symbolic
+ /// one, sqrt(-1/n^2), makes the zero one that only a sign of n decides.
+ /// https://github.com/asc-community/AngouriMath/issues/718
+ ///
+ internal static Entity? SolveByWritingATrigonometricFunctionOfAnImaginaryLogarithmInExponentials(Entity expr, Entity.Variable x, bool integrateByParts)
+ {
+ if (!expr.Nodes.Any(node => node is Logf && node.ContainsNode(x)))
+ return null;
+ var any = false;
+ var rewritten = expr.Replace(node =>
+ {
+ var (argument, kind) = node switch
+ {
+ Sinf(var of) => (of, 0),
+ Cosf(var of) => (of, 1),
+ Tanf(var of) => (of, 2),
+ Cotanf(var of) => (of, 3),
+ Secantf(var of) => (of, 4),
+ Cosecantf(var of) => (of, 5),
+ _ => ((Entity?)null, -1)
+ };
+ if (argument is null || !IsLinearInALogarithmWithAnImaginaryCoefficient(argument, x))
+ return node;
+ any = true;
+ var plus = MathS.Pow(MathS.e, MathS.i * argument);
+ var minus = MathS.Pow(MathS.e, -MathS.i * argument);
+ return kind switch
+ {
+ 0 => (plus - minus) / (2 * MathS.i),
+ 1 => (plus + minus) / 2,
+ 2 => (plus - minus) / (MathS.i * (plus + minus)),
+ 3 => MathS.i * (plus + minus) / (plus - minus),
+ 4 => 2 / (plus + minus),
+ _ => 2 * MathS.i / (plus - minus),
+ };
+ });
+ if (!any)
+ return null;
+ // Beside its own derivative the logarithm is a substitution's: `tan(a + i ln(x))/x` is
+ // `tan(a + i u)` in `u = ln(x)`, which the integrator answers in a closed form, where the
+ // exponentials would answer it as a piecewise in `e^(i a)`.
+ if (expr.Nodes.FirstOrDefault(node => node is Logf(var @base, var of) && @base == MathS.e && of.ContainsNode(x)) is { } logarithm)
+ {
+ Entity beside = Number.Integer.One;
+ foreach (var (factor, underneath) in FactorsOfTheIntegrand(expr))
+ if (!factor.ContainsNode(logarithm))
+ beside = underneath ? beside / factor : beside * factor;
+ if (beside.ContainsNode(x) && AreProportionalAtSampledPoints(beside, logarithm.Differentiate(x), x))
+ return null;
+ }
+ return Integration.ComputeAsTheSameQuestion(rewritten, x, integrateByParts);
+ }
+
+ ///
+ /// Whether is a + b ln(u), with u the only place the
+ /// variable is and b an imaginary number.
+ ///
+ private static bool IsLinearInALogarithmWithAnImaginaryCoefficient(Entity argument, Entity.Variable x)
+ {
+ var logarithms = argument.Nodes
+ .Where(node => node is Logf(var @base, var of) && @base == MathS.e && of.ContainsNode(x))
+ .Distinct().ToList();
+ if (logarithms.Count != 1)
+ return false;
+ var placeholder = Variable.CreateUnique(argument, "l_log");
+ var inPlaceholder = argument.Replace(node => node == logarithms[0] ? placeholder : node);
+ if (inPlaceholder.ContainsNode(x)
+ || !TreeAnalyzer.TryGetPolyLinear(inPlaceholder, placeholder, out var coefficient, out _)
+ || TreeAnalyzer.IsZero(coefficient))
+ return false;
+ // A number, and not a symbol's: with `b = sqrt(-1/n^2)` the power of the variable this
+ // leaves is `1/x` for every positive n, which nothing reading `n` symbolically can know,
+ // and the general power's formula comes back with a zero below its bar.
+ return coefficient.Vars.Count() == 0 && coefficient.Evaled is Number.Complex number && number is not Number.Real
+ && System.Math.Abs((double)number.RealPart) < 1e-12 * System.Math.Abs((double)number.ImaginaryPart);
+ }
+
///
/// A power of the variable times a sine or cosine of a logarithm, in closed form:
/// int x^m sin(L) dx is x^(m + 1)((m + 1) sin(L) - B cos(L))/((m + 1)^2 + B^2)
diff --git a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
index 97ab8287d..7bf208d48 100644
--- a/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
+++ b/Sources/AngouriMath/Functions/Continuous/Integration/Integration.Definition.cs
@@ -704,6 +704,9 @@ private static Entity Normalized(Entity expr, Entity.Variable x) =>
// A power of the variable times a sine or cosine of a logarithm, where two rounds of
// parts close on the integrand: `int x^m sin(a + b ln(c x^n))` in closed form.
if ((answer = IndefiniteIntegralSolver.SolveAPowerTimesATrigonometricOfALogarithm(expr, x, integrateByParts)) is { }) return answer;
+ // The same with an imaginary coefficient on the logarithm, where the closed form divides
+ // by zero: in exponentials, powers of the variable.
+ if ((answer = IndefiniteIntegralSolver.SolveByWritingATrigonometricFunctionOfAnImaginaryLogarithmInExponentials(expr, x, integrateByParts)) is { }) return answer;
// A logarithm of a quotient that cancels with the functions in it as
// indeterminates, which is how an inverse hyperbolic function of a hyperbolic
// one arrives: atanh(tanh(u)) is 1/2 ln(e^(2u)) once its quotient is cancelled.
diff --git a/Sources/Tests/UnitTests/Calculus/TrigonometricOfAnImaginaryLogarithmIntegralTest.cs b/Sources/Tests/UnitTests/Calculus/TrigonometricOfAnImaginaryLogarithmIntegralTest.cs
new file mode 100644
index 000000000..1e33f74c0
--- /dev/null
+++ b/Sources/Tests/UnitTests/Calculus/TrigonometricOfAnImaginaryLogarithmIntegralTest.cs
@@ -0,0 +1,64 @@
+//
+// Copyright (c) 2019-2026 Angouri.
+// AngouriMath is licensed under MIT.
+// Details: https://github.com/asc-community/AngouriMath/blob/master/LICENSE.md.
+// Website: https://am.angouri.org.
+//
+
+using System;
+using AngouriMath.Extensions;
+using Xunit;
+
+namespace AngouriMath.Tests.Calculus
+{
+ ///
+ /// A trigonometric function of a + b ln(u) with an imaginary number for b, in
+ /// exponentials: e^(i (a + b ln(u))) is e^(i a) times a real power of
+ /// u. The closed form for a power of the variable times a sine or cosine of a logarithm
+ /// divides by zero on exactly these, Rubi's 4.7.5. The integrands are complex, and compared as
+ /// complex numbers.
+ /// #718
+ ///
+ [Trait("Area", "Calculus")]
+ public sealed class TrigonometricOfAnImaginaryLogarithmIntegralTest
+ {
+ [Theory]
+ [InlineData("sin(a + ln(c*x^2)*sqrt(-1/4))")]
+ [InlineData("tan(a + i*ln(x))")]
+ [InlineData("cot(a + i*ln(x))/x^2")]
+ [InlineData("1/cos(a - 2*i*ln(c*x))^(3/2)")]
+ [InlineData("x^2*cos(a + i*ln(x))^2")]
+ public void InExponentials(string integrand) => DifferentiatesBack(integrand, integrand.ToEntity().Integrate("x"));
+
+ ///
+ /// Beside its own derivative the logarithm is left to the substitution:
+ /// tan(a + i ln(x))/x is tan(a + i u) in u = ln(x), answered in a
+ /// closed form, where the exponentials would answer it as a piecewise in e^(i a).
+ ///
+ [Theory]
+ [InlineData("tan(a + i*ln(x))/x")]
+ [InlineData("cot(a + i*ln(x))/x")]
+ public void BesideItsOwnDerivativeByTheSubstitution(string integrand)
+ {
+ var integral = integrand.ToEntity().Integrate("x");
+ Assert.DoesNotContain("piecewise", integral.Stringize());
+ DifferentiatesBack(integrand, integral);
+ }
+
+ private static void DifferentiatesBack(string integrand, Entity integral)
+ {
+ Assert.DoesNotContain("integral(", integral.Stringize());
+ Entity Pinned(Entity e) => e.Substitute("a", 0.4).Substitute("c", 1.3);
+ var derivative = Pinned(integral.Substitute("C", 0)).Differentiate("x");
+ var original = Pinned(integrand.ToEntity());
+ foreach (var at in new[] { 0.3, 0.8, 1.5, 2.4 })
+ {
+ var want = original.Substitute("x", at).EvalNumerical();
+ var got = derivative.Substitute("x", at).EvalNumerical();
+ Assert.True(Math.Abs((double)(got - want).RealPart) + Math.Abs((double)(got - want).ImaginaryPart)
+ < 1e-9 * Math.Max(1, Math.Abs((double)want.RealPart) + Math.Abs((double)want.ImaginaryPart)),
+ $"d/dx of the antiderivative of {integrand} is {got} at x = {at}, where the integrand is {want}");
+ }
+ }
+ }
+}