Timeline for How to only evaluate this function in the new variables after the derivative has been taken?
Current License: CC BY-SA 4.0
19 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 25 at 22:01 | answer | added | lericr | timeline score: 0 | |
Oct 25 at 20:02 | comment | added | user1620696 |
@lericr I think that it is probably better to work all the time with Function , I'll try to recast the code using that, because I feel it might be a better solution in the end.
|
|
Oct 25 at 20:02 | comment | added | user1620696 |
@TedErsek: I will write in plain math then. Imagine that you have some collection of functions $F_{AB}(x,y)$ that takes values in $\mathbb{R}^2$. I want to construct the matrix of derivatives $\partial_i [F_{AB}]_j$. I coded the functions $F_{AB}(x,y)$ as linear combinations of symbols e[i] that play the role of the basis vectors. So I wanted to extract the coefficient and differentiate. But I want the final result to be again a function, so that I can use whatever argument I want. The problem is that to take the derivatives I'm using that coords list...
|
|
Oct 25 at 19:31 | comment | added | Ted Ersek | If you would explain what result you expect to get, people will provide far smarter solutions. | |
Oct 25 at 17:50 | answer | added | lericr | timeline score: 1 | |
Oct 25 at 17:26 | comment | added | lericr |
So, you either need to do everything with x and y and the do a replacement {x->t, y->s} or you could just do all the work with pure Function s and just use Derivative on the resulting pure function. You might even want to skip taking the coefficient and just do Derivative[1,0] or Derivative[0,1] depending on what i was passed in. Not sure if that's exactly the semantic you want, but that feels like what you're trying to do to me.
|
|
Oct 25 at 17:23 | comment | added | lericr |
Basically, in this expression D[coeff[i][a, b][x, y], coords[[j]]] , when you pass in t and s to derF[a, b][t, s] you're going to end up taking the derivative with respect to a variable that doesn't exist in the expression your taking the derivate of.
|
|
Oct 25 at 17:20 | comment | added | lericr |
Okay, sorry for not having an actual answer to post yet, but I think we need to first decide whether you want to operate with polynomial expressions or with functions (functions in the sense of Function[...] . You keep referring to x and y in your code, which implies you like using those as indeterminates (formal variables), but then at the end you want to get expressions using other variables, e.g. t and s . If your end goal is to be able to use any arbitrary symbols/inputs, then probably we should lean toward using just pure Function s.
|
|
Oct 25 at 17:09 | comment | added | lericr |
My first thought is to use Derivative instead of D
|
|
Oct 25 at 17:09 | comment | added | user1620696 |
Yes, exactly! Everything works with x and y but when I change the argument it doesn't. I understood why (I hard-coded x and y in the coords list), but don't know the best work-around
|
|
Oct 25 at 17:07 | comment | added | lericr |
Yeah, you're sort of hard-coding everything to x and y . Don't do that. :)
|
|
Oct 25 at 17:07 | comment | added | lericr |
Oh, so everything works okay when you pass in x and y , just not other arguments like t and s , is that it?
|
|
Oct 25 at 16:49 | comment | added | user1620696 |
Hi @lericr, sorry, I should have used e[i] instead. It is always just either e[1] or e[2] . Now, I don't have a general formula for F[a,b] as a function of a and b . I have manually defined F[a, b] for a = 1,2,3 and b=1,2,3 , but here I just put one of them as an example. The point is that I have a $3\times 3$ matrix of functions of {x,y} which are linear combinations of the symbols e[1] and e[2]
|
|
Oct 25 at 15:11 | answer | added | Ted Ersek | timeline score: 1 | |
Oct 25 at 15:01 | comment | added | lericr |
Also, just a nit, but E is a pre-defined symbol, so you may want to avoid it.
|
|
Oct 25 at 15:00 | comment | added | lericr |
I'm sorry, I'm having trouble understanding what you're saying. It seems to me that you either want f1 = Function[{x, y}, x^2 e[1] + y^2 e[2]] or f2[a_, b_] := Function[{x, y}, x^2 e[a] + y^2 e[b]] . Maybe you can give a concrete example of what you expect for f[a,b] for some specific a and b . And then what you expect for coeff[i][a,b][x,y] for some specific i , a , and b .
|
|
Oct 25 at 14:51 | comment | added | lericr |
You have an expression like this F[a, b][x, y] , but you've only defined F with F[1,2] . Does that mean a and b will always be 1 or 2 ? Or is that your actual question--how to define F for any a and b ?
|
|
Oct 25 at 14:46 | comment | added | lericr |
So, the E[i] are always either E[1] or E[2] ?
|
|
Oct 25 at 14:12 | history | asked | user1620696 | CC BY-SA 4.0 |