Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] New Diff2 #521

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

[wip] New Diff2 #521

wants to merge 4 commits into from

Conversation

latot
Copy link
Contributor

@latot latot commented Sep 1, 2016

Hi!, it feels to much time, well here i have a rewrite to the diff function, the reasons are simple, first, when we have a function with more than one var the diff command send the partial derivation only of the first founded var, ex:

>> syms f(g, h)
>> diff(f)
ans(g, h) = (symfun)

  ∂          
  ──(f(g, h))
  ∂h         

i think this is really bad, theoretically the diff should use the chain rule and apply it, but actually we can't do that, at least while this issue is open: #519
So, i think its better have a warning/error instead a wrong calc, (and start searching the problem etc).

I try keep the main functions of diff, so the new syntax would be :

diff(FUNCTION, VAR1, GRADE OF VAR1, VAR2, GRADE OF VAR2 .....)

this code recognize symbols on functions if you don't send the first derive var, and if the first arg is a number is derived in that grade, one of the differences with the actual diff is this:

actual diff:

>> syms x
>> f=sin(x)
f = (sym) sin(x)
>> diff(f, 2, x)
ans = (sym) -sin(x)

new diff

>> syms x
>> f=sin(x)
f = (sym) sin(x)
>> diff(f, 2, x)
ans = (sym) -cos(x)

basically the new diff(f, 2, x) menas, derive f two times in x, then derive it in x again.
I think include the chain rule but i will leave that to sympy: sympy/sympy#11573

Thx. Cya.

@latot
Copy link
Contributor Author

latot commented Sep 1, 2016

mm, reading this will break compatibility with SMT, so this don't is an option D:
other pr!

@latot latot closed this Sep 1, 2016
@latot latot reopened this Sep 1, 2016
@latot
Copy link
Contributor Author

latot commented Sep 1, 2016

Thinking, the diff of SMT diverge of the diff of SymPy, maybe can be good idea move this diff to diff2 to better compatibility with SymPy.

In what diverge? diff of sympy use chain rule, while diff of SMT only partial derive of the first founded var.

@latot latot changed the title rewrite diff New Diff2 Sep 2, 2016
@latot
Copy link
Contributor Author

latot commented Sep 5, 2016

ups, don't is a octave problem, my bad again, i notice this now, the actual diff don't its compatible with octave D:
that should be fixed!
lets work a little more in this.

@cbm755 cbm755 changed the title New Diff2 [wip] New Diff2 Sep 14, 2016
@cbm755
Copy link
Collaborator

cbm755 commented Sep 14, 2016

Regarding your specific example: that does look wrong, I think symvar should choose g as the variable to differentiate w.r.t.; I've filed #550.

@cbm755
Copy link
Collaborator

cbm755 commented Sep 14, 2016

Now: I don't understand what you're trying to fix. diff(f, 2, x) is old legacy SMT stuff as discussed elsewhere. But it is supposed to calculate the 2nd partial wrt x: not a third partial.

Was there something else you're trying to address here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants