Group Abstract Group Abstract

Message Boards Message Boards

Finding the function given the gradient vector

Posted 5 years ago

Hello. The gradient vector Grad(f) of the function f is given as in the file. Question 1: How can I find the smallest value of Grad(f) based on variables x1 and x2 ? Question 2: Given only Grad(f) vector, how can I find the function f ? I will be very happy if those who know this subject can help.

Attachments:
POSTED BY: Meryem Aslı
18 Replies

Hello Meryem,

your expressions are indeed somewhat complicated, so I choose a much simpler example which may, at least I hope so, give you a hint.

First of all you should check the "mixed derivatives" of your gradient, that means check the "integrability conditions". That will show if your function f exists.

Now for the example.

Define

grad[f_] := {D[f, x], D[f, y], D[f, z]}

Let's say you have a gradient

gradf = {(2 x)/z, (2 y)/z, -((x^2 + y^2)/z^2)};

Check the mixed derivatives

D[gradf[[1]], y] == D[gradf[[2]], x]
D[gradf[[1]], z] == D[gradf[[3]], x]
D[gradf[[2]], z] == D[gradf[[3]], y]

Each answer is True, so there is indeed a function giving the gradient in question.

Now chose a straight line from { x0, y0, z0 } to { x1, y1, z1 } and the derivative of the line element to calculate

Integrate [ gradf . dr ]

along this line. Set

rule = {x -> x0 (1 - t) + t x1, y -> y0 (1 - t) + t y1, z -> z0 (1 - t) + t z1};
xp = D[{x, y, z} /. rule, t];
df = (gradf /. rule).xp // FullSimplify;

Switch off the output of conditions in Integrate and do the integration, change the variables back to x, y, z and get a function yielding the given gradient

SetOptions[Integrate, GenerateConditions -> False];
ff = Integrate[df, {t, 0, 1}] /. {x1 -> x, y1 -> y, z1 -> z} // FullSimplify
grad[ff]

Of course you may as well integrate along the edges of the cuboid:

fff = Integrate[(gradf[[1]] /. {x -> u, y -> y0, z -> z0}), {u, x0, x1}] +
  Integrate[(gradf[[2]] /. {x -> x1, y -> u, z -> z0}), {u, y0, y1}] +
  Integrate[(gradf[[3]] /. {x -> x1, y -> y1, z -> u}), {u, z0, z1}]
fff = (fff // FullSimplify) /. {x1 -> x, y1 -> y, z1 -> z}
grad[fff]
gradf

I hope you got an idea how to calculate your function f.

POSTED BY: Hans Dolhaine

Rename your Grad(f) given above to gf = ... your expression.... and try

D[ gf[[1]], x2] == D[ gf[[2]], x1]
D[ gf[[1]], x3] == D[ gf[[3]], x1]
D[ gf[[2]], x3] == D[ gf[[3]], x2]

That means the function you are looking for does not exist

POSTED BY: Hans Dolhaine

In general the procedure may be written as

grad[f_] := {D[f, x], D[f, y], D[f, z]}

t1 = Integrate[a[u, y0, z0], {u, x0, x}];
t2 = Integrate[b[x, u, z0], {u, y0, y}];
t3 = Integrate[c[x, y, u], {u, z0, z}];

(*Integrability conditions *)
rr = {
   Derivative[1, 0, 0][b][xx__] -> Derivative[0, 1, 0][a][xx],
   Derivative[1, 0, 0][c][xx__] -> Derivative[0, 0, 1][a][xx],
   Derivative[0, 1, 0][c][xx__] -> Derivative[0, 0, 1][b][xx]
   };

F = t1 + t2 + t3;
grad[F]
grad[F] /. rr
POSTED BY: Hans Dolhaine
Posted 4 years ago

Also, since each of the x1, x2, x3 terms are functions dependent on variables, I might not have reached a solution.

POSTED BY: Meryem Aslı
Posted 4 years ago

Hello Hans. I could not deal with this question for a long time due to my health problems. Yesterday I looked at the question again and unfortunately there is no function that gives this gradient as you said.

POSTED BY: Meryem Aslı

Hi Meryem,

any progress in your problem?

Did you realize that with your gradf a function giving this gradient does not exist?

What about telling us the background of your problem (without the lengthy Sin and Cos terms)?

Greetings HD

POSTED BY: Hans Dolhaine
Posted 5 years ago

Thank you so much. I will try to solve the problem using this solution method.

POSTED BY: Meryem Aslı

David,

What is the current version of your GrassmannAlgebra application? I tried to find out from the link at https://davidandalicepark.wordpress.com/home-2/mathematica/, but that gives a "page can't be found" error.

[Similar question for your Presentations application! (While recent versions of Mathematica have introduced some built-in complex function plotting tools along with some utility functions for complex numbers, Mathematica still lacks a lot of the functionality of "Presentations" as well as its more flexible paradigm for graphics objects.)]

POSTED BY: Murray Eisenberg

This remains confusing. On one side there is what looks like a surface of the form z=f(x,y) (so the two parameters are x and y). Later it appear that the surface is instead of the form {f1(s,t),f2(s,t),f3(s,t)} with {s,t} being the parameters.

As a second remark, it seems that you have a gradient and want to recover a potential function? Existence of such a function requires that some second derivative equations be satisfied.

POSTED BY: Daniel Lichtblau
Posted 5 years ago
POSTED BY: Meryem Aslı

It could be that the problem is to:

1) First, calculate a scalar potential field,f, from the vector force field. (The statement seems to indicate there is one.)

2) Then, as a second step, find the maximum of the potential on the surface specified.

Maybe this has somehow all gotten mashed together.

A clearer statement of the objective is necessary.

Anonymous User
Anonymous User
Posted 5 years ago

I want to underline what the first responding poster said* a minimization problem (other than 0) requires a constraint which still hasn't been stated. Say, two curves and a condition that says "what is considered minimal" (the distance between them or along them? a mutual distance from the origin?)*

You've also said you want f, but I assume f( x ) is the surface you gave, that the surface is not the constraint. If the constraint is the surface and you gave us (grad f)={x1,x2,f[x1,x2]} then you've still withheld (grad f)={x1,x2,x3} meaning before you altered it.

I can only guess you mean the direction of greatest change is normal to the surface and of least change is tangent to surface as a condition. In that light you want the equation that is always tangent to the surface and the gradient is not necessary since the surface was given. If r[t,s] = surface given, then r'[t,s] (easily done by mathematica), is tangent to the surface at each point and so the direction of least change. If you have N you should already have T, the tangent vector.

(* the vector valued surface *)
In[109]:= D[(a + t Cos[b s] - g[t] Sin[b s]) {Cos[s], Sin[s], 0} + {0,
    0, t Sin[b s] + g[t] Cos[b s]}, t, s]

(* the direction of least change, r'[t,s] *)
Out[109]= {Cos[s] (-b Sin[b s] - b Cos[b s] Derivative[1][g][t]) - 
  Sin[s] (Cos[b s] - Sin[b s] Derivative[1][g][t]), 
 Sin[s] (-b Sin[b s] - b Cos[b s] Derivative[1][g][t]) + 
  Cos[s] (Cos[b s] - Sin[b s] Derivative[1][g][t]), 
 b Cos[b s] - b Sin[b s] Derivative[1][g][t]}

If you mean minimal curvature K, then since you have a wavy sin cos surface then you may only need the maximum points of the surface to find minimal K or the 0 points for greatest K (ie, it may be a trick question not requiring the kind of solution your looking for).

You should ask a teacher or look in the book's "solution guide". And you should ask people this kind of question without the problem FULLY TYPED OUT as the book had it (and page, and name) - which likely requires being in a different forum altogether.

POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 5 years ago

If you put x3 in terms of x1 and x2 and applied the gradient you still would not have the expression first posted (for one thing, the first element of the vector x cannot be x1 after the gradient since that was the value before the gradient). Also if you knew the equation for x then why would post a questionably formulated gradient and as what it was (this is not an arcane puzzle forum)? Also Grad[ x ] evaluates without substitutions. But that doesn't matter.

When working with gradients during a calculus course it is easy to apply the Grad operator and get a nasty expressions perhaps hundreds of terms long (many are surprised by this). The answer is not to do it that way. If you are led to a wild expression in your vectors you should do as the book proposes one step at a time to maintain a solvable expressions. You will learn other methods as you advance in Mathematics but you will have to wait. Therefore technique of expressing one vector in terms of another is not "always useful".

POSTED BY: Anonymous User
Posted 5 years ago
POSTED BY: Meryem Aslı
Anonymous User
Anonymous User
Posted 5 years ago

There's allot of free math showing how to find f from the gradient of f. Also the lagrange multiplier method (as well as others) for minimization. And linear algebra algorithms as well.

It's against Community policy to "drop a problem you haven't attempted to solve" in the forum, nor should problems be contrived to be unsolvable by certain methods without being introducing as such.

POSTED BY: Anonymous User
POSTED BY: W. Craig Carter
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard