# Implicit differentiation at a point

**URL:** <https://community.wolfram.com/t/implicit-differentiation-at-a-point/18562>\
**Category:** Questions\
**Tags:** calculus, equation-solving\
**Created:** [July 17, 2021, 4:58am UTC](https://community.wolfram.com/t/implicit-differentiation-at-a-point/18562 "2021-07-17T04:58:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![guangye](https://avatars.discourse-cdn.com/v4/letter/g/f05b48/32.png) [@guangye](https://community.wolfram.com/u/guangye)\
**Post date:** [July 17, 2021, 4:58am UTC](https://community.wolfram.com/t/implicit-differentiation-at-a-point/18562/1 "2021-07-17T04:58:59Z")

</div>

I have the following implicit equation, and I’d like to compute the derivative of p with respect to T at a specific point. In other words, if I were to create the Contourplot of this equation, with p as the y-axis, and T as the x-axis, what would be its slope a certain point. I’m using Dt[] for the derivative, but it seems to give another implicit function, whereas I’m looking a numeric value. Code is attached.

```auto
derivativ = 
 Dt[p == \[Phi]/R + ((1 - \[Phi]) \[Phi] (1 - \[Lambda]) \[Beta])/(((W - T p) R + \[Phi] T) R + \[Phi]*(1 - \[Phi]) T)/(R (\[Lambda]/((W - T p) R + \[Phi] T ) + ((1 - \[Lambda]) \[Beta] R)/(((W - T p) R + \[Phi] T) R + \[Phi] (1 - \[Phi]) T))), T]

derivativ /. {p -> 0.3192789688874802, T -> 313.206}

```

I get the following warning:

```auto
General::ivar: 313.206` is not a valid variable.

```

The output is:

```auto
Dt[0.319279, 313.206] == -142495. (-7.33049*10^-13 (0.16 + 1.05263 (0.2 + 1.05263 (-0.319279 - 313.206 Dt[0.319279, 313.206]))) - 9.02573*10^-14 (0.2 + 1.05263 (-0.319279 - 313.206 Dt[0.319279, 313.206]))) - 1.16674*10^-7 (0.16 + 1.05263 (0.2 + 1.05263 (-0.319279 - 313.206 Dt[0.319279, 313.206])))

```

Is it possible to get a number for the derivative evaluated at {p → 0.3192789688874802, T → 313.206}? And what does that warning actually mean?

Thank you,

[differentiate.nb](https://community.wolfram.com/uploads/short-url/ufgWR8xNDlaQ0lbAnYrMnamOOoW.nb) (13.4 KB)

---

<div class="post-metadata">

**Author:** ![neils](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/neils/32/20595_2.png) [@neils](https://community.wolfram.com/u/neils)\
**Post date:** [July 17, 2021, 1:17pm UTC](https://community.wolfram.com/t/implicit-differentiation-at-a-point/18562/2 "2021-07-17T13:17:43Z")

</div>

You need to control what symbols are constant and what symbols vary with T. I really think you need to use D[] and not Dt[]. Dt[] assumes that every symbol varies with T. This is an unusual case. For example, if all your variables are constant in T, except for p, you would do:

```
derivativ = 
 D[p[T] == \[Phi]/
     R + ((1 - \[Phi]) \[Phi] (1 - \[Lambda]) \[Beta])/(((W - 
              T p[
                T]) R + \[Phi] T) R + \[Phi]*(1 - \[Phi]) T)/(R (\
\[Lambda]/((W - 
               T p[
                 T]) R + \[Phi] T) + ((1 - \[Lambda]) \[Beta] R)/(((W \
- T p[T]) R + \[Phi] T) R + \[Phi] (1 - \[Phi]) T))), T]

```

Now solve for the term p’[T] (solve returns a list of solution lists so take the first and only answer)

```
ans = Simplify[Solve[derivativ, p'[T]]][[1, 1]]

```

use the solution rule to evaluate p’[T] and substitute your numbers:

```
p'[T] /. ans /. {p[T] -> 0.3192789688874802, T -> 313.206}

```

If, say, R depended on T you would change all occurrences of R to R[T] and Mathematica would know to do the differentiation with T and you would get terms with R’[T] in the result.

I hope this helps.

Regards

Neil

---

<div class="post-metadata">

**Author:** ![guangye](https://avatars.discourse-cdn.com/v4/letter/g/f05b48/32.png) [@guangye](https://community.wolfram.com/u/guangye)\
**Post date:** [July 17, 2021, 5:06pm UTC](https://community.wolfram.com/t/implicit-differentiation-at-a-point/18562/3 "2021-07-17T17:06:43Z")

</div>

Hello Neil,

Thank you so much! Your suggestion works perfectly. I have a follow up question: I’m trying to plot the derivative p’[T] as a function T, so p’[T] on the y-axis, and T on the x-axis. The following code returns an empty plot. I assume I need to compute p[T] for all T in my desired range, ie: {0,1000}, and then compute p’[T] for each pair of p[T] and T, and then plot. Would you know any way of achieving that?

Thank you again!

```auto
Plot[Evaluate[ans], {T, 0, 10000}]

```

---

<div class="post-metadata">

**Author:** ![neils](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/neils/32/20595_2.png) [@neils](https://community.wolfram.com/u/neils)\
**Post date:** [July 18, 2021, 1:03am UTC](https://community.wolfram.com/t/implicit-differentiation-at-a-point/18562/4 "2021-07-18T01:03:26Z")

</div>

The problem is ans is not numerical. You need to define all the variables if you want to plot it. For example Phi, Lambda, etc. You will also need p[T] for each T or some function for p (or interpolation).

To verify that you have everything in place, try evaluating the plot argument and make sure its numerical.

Regards.

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [July 18, 2021, 3:43am UTC](https://community.wolfram.com/t/implicit-differentiation-at-a-point/18562/5 "2021-07-18T03:43:25Z")

</div>

Crossposted [here](https://mathematica.stackexchange.com/q/251130/58370).
