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

Showing intermediate process while doing differentiation #1

Open
Phryxia opened this issue Aug 15, 2021 · 0 comments
Open

Showing intermediate process while doing differentiation #1

Phryxia opened this issue Aug 15, 2021 · 0 comments
Labels
suggestion Any good idea

Comments

@Phryxia
Copy link
Owner

Phryxia commented Aug 15, 2021

This idea had been came from one of my friends. This will helps many students all around the world.

Note that this is more than library, because it is level of services. Therefore I'll not include this into library code. Even though, it's really helpful so I'd like to implement it on the demo page.

But we have to define "What is the intermediate process" first. For example, consider x^2 + 2*x + 1. It's outcome should be 2*x + 2. What should be intermediate process of this derivation?

Doing very simple one can be very annoying if I include super low-level process like using definition of diffentiation. (See this)

So I'd like to think "what is implicit process". Differentiating trivial things are easy like x, sin(x) or x^n. Consider more complex case like sin(ln(x))^2. It's derivative is 2 * sin(ln(x)) * cos(ln(x)) / x. In this case, it's not clear what term was came from where. It looks like magic if you're not familiar with differentiation.

But if we wrap internal expression like this:

We have to compute the derivative of E(x) = sin(ln(x))^2
Let f(x) := sin(ln(x))
Then E(x) = f(x)^2
Using chain rule and knowledge of differentiation of polynomial ensures that, E'(x) = 2 * f(x) * f'(x) ... (1)

Now we have to compute the derivative of f(x) = sin(ln(x))
Let g(x) := ln(x)
Then f(x) = sin(g(x))
Using chain rule and knowledge of trigonometry, f'(x) = cos(g(x)) * g'(x) ... (2)

Now we have to compute the derivative of g(x) = ln(x)
Using knowledge of logarithm, g'(x) = 1/x

Plug g'(x) to (2) so that f'(x) = cos(ln(x)) / x.
Plug f'(x) to (1) so that E'(x) = 2 * sin(ln(x)) * cos(ln(x)) / x.

By deriving them recursively, it's very clear to comprehend. In this example, we can define intermediate process as "children derivations of given node", We can think of this in pseudocode like this:

function showIntermediateProcess(expression):
  show local objective (`We have to compute the derivative of ${expression}`)
  replace child with some function name
  show local derivation using replaced expression
  showIntermediateProcess(child)
  plug result into replaced expression

It's just very simplified idea. More polishing would be needed for further cases. We may hide some duplicated calculation (ex: e^x^2 in sin(e^x^2) + cos(e^x^2)).

@Phryxia Phryxia added the suggestion Any good idea label Aug 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Any good idea
Projects
None yet
Development

No branches or pull requests

1 participant