Menu

#176 built-in grad function

open
nobody
5
2022-06-30
2022-06-29
No

There is a built-in jacobian function, but no grad; there should be a built-in grad function, even if it only punts to jacobian. People looking for grad are unlikely to find jacobian.

Discussion

  • Jaime E. Villate

    Using jacobian to find a gradient one would have to write

    jacobian([expression],[var1,...,varn])
    

    and the result would be a matrix. Instead of punting to jacobian, I would prefer defining it:

    grad(exp,vars):= map(lambda([u], diff(exp, u)), vars)
    

    Which is easier to use:

    grad(exp,[var1,...,varn])
    

    and returns a list instead of a matrix.

     
  • Stavros Macrakis

    Don't several share packages define grad or gradient? Are their definitions consistent?
    Do they assume that you're working in Cartesian coordinates?
    Isn't it useful to have a grad operator that doesn't calculate out the diffs, but can be used symbolically?

     
  • Robert Dodier

    Robert Dodier - 2022-06-30

    These are all great points.

    (1) About jacobian and grad, I just want them to be consistent with each other.

    (2) About existing definitions, there's at least one I can think of (share/vector/vect.mac), and it allows different coordinate systems (share/vector/vect_transform.mac). I didn't look for other definitions.

    Incidentally vect.mac also defines div, curl, etc.; dunno if we want to try to import all that stuff too.

    (3) Agreed that allowing symbolic gradients is desirable. Probably diff, grad, jacobian, etc., should all be consistent in that respect.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.