1
$\begingroup$

I'm trying to set the derivative of a function to zero at a specified point. This will act as an initial condition for an algorithm I'm writing: so I'm specifying the value of the function at x=0, and I'm specifying the value of the slope of the function at x=0. The function is u[n, x] and is unknown. The algorithm, based on Adomian decomposition method, will solve a nonlinear differential equation for this u-function.

Clear[u]
u /: D[u[n_, x_], x_] := 0
UpValues[u];
D[u[n, x], x] == 0

It gives the right output -- says it's True.

The problem I'm having is other queries say they are True when they shouldn't be:

D[u[n, x], 0] == 0 \\True
D[u[n, 0], 0] == 0 \\True

This is a somewhat duplicate of a question here, which is asked in a broader sense: How to set the derivative of a function to zero?

Ideally, what should happen is based on modifying this line of code:

u /: (D[u[n_, x_], x_] := 0)/.x->0

The result would be:

(D[u[n, x], x] == 0)/.x->0 \\True
(D[u[n, x], x] == 0)/.x->5 \\False or indeterminate

Thank you for any tips.

$\endgroup$
5
  • $\begingroup$ Why not attach rules with Derivative[] instead? u /: Derivative[0, 1][u][n_, x_] := 0. $\endgroup$ Commented Jul 7, 2016 at 23:36
  • 1
    $\begingroup$ @J.M. In that case, I think u is too deeply nested in the expression, so it won't work. Every time I think UpValues is the solution to one of my problems, I get this error. $\endgroup$
    – march
    Commented Jul 7, 2016 at 23:47
  • $\begingroup$ @march, thanks for trying it out; I currently do not have Mathematica on hand. I guess a simple Derivative[0, 1][u][n_, x_] := 0 should have to suffice. $\endgroup$ Commented Jul 7, 2016 at 23:48
  • 2
    $\begingroup$ @J.M. Or, as I read it, Derivative[0, 1][u][n_, 0] := 0. $\endgroup$
    – Michael E2
    Commented Jul 8, 2016 at 0:33
  • $\begingroup$ Thank you guys! Michael's advice worked. I did not know we could set derivatives equal to a number using := notation, but it makes sense. $\endgroup$
    – Buddhapus
    Commented Jul 8, 2016 at 17:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.