Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a higher dimensional function:

$$f(x,t)=-\ln(t)-\ln(1-\left\|x\right\|^2-t^2)$$ where $x\in\mathbb{R}^n,~t\in\mathbb{R}$.

I want to compute the derivatives with the commands

D[f, xi]
D[f, t]
D[f, xi, t] 

and higher, to check my own computations which I do by hand. I dont know how to define the function $f$ to apply the commands.

Im new Mathematica user and I've not found a right solution Documentation Center.

share|improve this question
    
You should start with searching for similar questions here, e.g. see Using D to find a symbolic derivative. –  Artes Dec 9 '13 at 10:58
    
To close voters. Maybe I've overlooked it but in documentation there are only examples with explicitly written vector components so I do not think it is useful for n=36. On the other hand example with Array is not obvious for someone who has experience with WolframAlpha, D[Sin[x[1]],x[1]] is not interpreted there as in Mathematica –  Kuba Dec 9 '13 at 11:54
    
@Kuba This question is not clear whether n is given or not. In the latter case your post doesn't answer the question. If you provide an answer without specifying explicitly n (e.g. using new tensor capabilities) I'll retract my close vote. –  Artes Dec 9 '13 at 13:10
    
@Artes But whether n is given or not does not affect the utility of the question, only area of application of my answer. About more general approach, it seems you know how to do this, why not post an answer by yourself? :) I would use NonConstants option for this purpose but I don't use MMA for symbolics very often so that's not probably it. –  Kuba Dec 9 '13 at 13:23
add comment

1 Answer 1

up vote 2 down vote accepted

Something like this?

n = 5;
xi = Array[x, n]
f[x_, t_] := -Log[t] - Log[1 - x.x - t^2]
{x[1], x[2], x[3], x[4], x[5]}
D[f[x, t], t]
D[f[xi, t], x[3]]
D[f[xi, t], x[1], t]

$\frac{2 t}{-t^2-x.x+1}-\frac{1}{t}$

$\frac{2 x(3)}{-t^2-x(1)^2-x(2)^2-x(3)^2-x(4)^2-x(5)^2+1}$

$\frac{4 t x(1)}{\left(-t^2-x(1)^2-x(2)^2-x(3)^2-x(4)^2-x(5)^2+1\right)^2}$

share|improve this answer
    
@dalvo It is good habit to hold on with an accept a day or two. Accepted answer is sometimes discouraging for others, and I do not find my answer perfect so let's wait ;) –  Kuba Dec 9 '13 at 13:47
    
ok, you're right :) –  dalvo Dec 9 '13 at 14:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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