-1
$\begingroup$

Maybe this is very basic, but I'm not getting it. I've googled around and searched here for an answer but I can't find it. I need to set D[h[r], r] equal to zero, so that when this is evaluated it shows that it's zero. I've tried doing:

Block[D[h[r], r], 0]

or even just

D[h[r], r] = 0

but this returns "tag is protected". Thank you for your help

$\endgroup$
2
  • $\begingroup$ Could you show Mathematica expressions instead of LaTeX? $\endgroup$
    – MarcoB
    Jul 19, 2015 at 23:44
  • 1
    $\begingroup$ Why do you need it to be zero? Is this to solve for something? Having the code would help. $\endgroup$
    – Edmund
    Jul 19, 2015 at 23:56

1 Answer 1

3
$\begingroup$

You can specify upvalues for any symbol. Try defining one on h as follows:

h /: D[h[r_], r_] := 0
UpValues[h]

As a result

D[h[x], x]==0
(* True *)
$\endgroup$
4
  • $\begingroup$ I tried this, but instead I used: $$h_{rr}[r,\theta,\phi]$$ for h instead. I got the error "Argument at position 1 is expected to be a symbol. >>" h is some function which will need to approximated later on in the code. One way I can make the entire output an approximation is by cutting off this derivative $\endgroup$
    – ful1meta1
    Jul 20, 2015 at 1:43
  • 1
    $\begingroup$ No one can help with your error unless you give us the actual Mathematica expression that produced it. $\endgroup$
    – Ian
    Jul 20, 2015 at 1:45
  • $\begingroup$ Okay. I tried it this way: h11 /: D[h11, r] := 0 UpValues[h11] This returns TagSetDelayed::tagnf: Tag h11 not found>> $\endgroup$
    – ful1meta1
    Jul 20, 2015 at 1:55
  • 2
    $\begingroup$ I'm a bit stumped, because h11 /: D[h11, r] := 0 doesn't give me an error. It's also not going to solve your problem though, because without underscores it will only match the literal expression D[h11,r]. You can add additional arguments to the answer I gave like this: h /: D[h[r_, t_, p_], r_]:=0 $\endgroup$
    – Ian
    Jul 20, 2015 at 3:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.