@@ -1186,6 +1186,11 @@ internal static bool IsDeterminate(Entity combined, Variable x)
11861186 {
11871187 MultithreadingFunctional . ExitIfCancelled ( ) ;
11881188 derivative = derivative . Differentiate ( x ) . Simplify ( ) ;
1189+ // A derivative with an arccotangent at its jump in it has no single value at the point:
1190+ // x arccot(x) differentiates to arccot(x) - x / (1 + x^2), pi/2 there by putting 0 in
1191+ // and -pi/2 from the left, so its sign from the left came out -1 where it is +1.
1192+ if ( HasAnArccotangentAtItsJump ( derivative , x , dest ) )
1193+ return null ;
11891194 var atThePoint = EvalAssumingContinuous ( derivative . Substitute ( x , dest ) . InnerSimplified ) ;
11901195 if ( atThePoint is not Real { IsFinite : true } value )
11911196 return null ;
@@ -1494,13 +1499,23 @@ internal static bool VanishesNear(Entity difference, Variable x, Entity dest, Ap
14941499 private static bool AlreadyBeingDifferentiated ( Entity quotient )
14951500 => ( lHopitalChain ??= new ( ) ) . Contains ( quotient ) ;
14961501
1502+ /// <summary>
1503+ /// Whether <paramref name="expr"/> holds an arccotangent whose argument is 0 at <paramref name="dest"/>, where it
1504+ /// jumps: it is arctan(1/t), with range (-pi/2, pi/2], so arccot(-0.001) = -1.5698 and arccot(0) = pi/2. Its value
1505+ /// there is not its limit from below, as a step function's value at a jump is not.
1506+ /// </summary>
1507+ private static bool HasAnArccotangentAtItsJump ( Entity expr , Variable x , Entity dest )
1508+ => expr . Nodes . Any ( node => node is Arccotanf ( var argument ) && argument . ContainsNode ( x )
1509+ && argument . Substitute ( x , dest ) . Evaled is Complex { IsZero : true } ) ;
1510+
14971511 /// <summary>
14981512 /// The value of <paramref name="expr"/> at a finite <paramref name="dest"/>, where it is a finite real number and
14991513 /// nothing in it jumps, which is its limit there; otherwise <see langword="null"/>.
15001514 /// </summary>
15011515 private static Entity ? ItsValueAt ( Entity expr , Variable x , Entity dest )
15021516 {
1503- if ( ! dest . IsFinite || expr . Nodes . Any ( static node => node is Floorf or Ceilf or Roundf or Signumf or Piecewise ) )
1517+ if ( ! dest . IsFinite || expr . Nodes . Any ( static node => node is Floorf or Ceilf or Roundf or Signumf or Piecewise )
1518+ || HasAnArccotangentAtItsJump ( expr , x , dest ) )
15041519 return null ;
15051520 var there = expr . Substitute ( x , dest ) ;
15061521 return there . Evaled is Real { IsFinite : true , IsNaN : false } ? there . InnerSimplified : null ;
@@ -1523,7 +1538,8 @@ private static bool AlreadyBeingDifferentiated(Entity quotient)
15231538 private static Entity ? ItsValueOrPoleAt ( Entity applied , Variable x , Entity dest , ApproachFrom side )
15241539 {
15251540 if ( ! dest . IsFinite || side is ApproachFrom . BothSides
1526- || applied . Nodes . Any ( static node => node is Floorf or Ceilf or Roundf or Signumf or Piecewise ) )
1541+ || applied . Nodes . Any ( static node => node is Floorf or Ceilf or Roundf or Signumf or Piecewise )
1542+ || HasAnArccotangentAtItsJump ( applied , x , dest ) )
15271543 return null ;
15281544 var distance = dest is Integer { IsZero : true } ? ( Entity ) x : x - dest ;
15291545 Entity finite = Integer . Zero ;
@@ -2041,6 +2057,7 @@ bool TakeOut(Entity factor)
20412057 {
20422058 if ( factor . ContainsNode ( x )
20432059 && ! factor . Nodes . Any ( static node => node is Floorf or Ceilf or Roundf or Signumf or Piecewise )
2060+ && ! ( dest . IsFinite && HasAnArccotangentAtItsJump ( factor , x , dest ) )
20442061 && TreeAnalyzer . IsRealValued ( factor , x )
20452062 && ( dest . IsFinite ? factor . Substitute ( x , dest ) : IsAPolynomialPower ( factor , x ) ? MathS . NaN : ComputeLimit ( factor , x , dest , side ) ?? MathS . NaN ) is var there
20462063 && there . Evaled is Real { IsFinite : true , IsNaN : false , IsZero : false } )
0 commit comments