Repository: ManimCommunity/manim

Issue:
Typo in coordinate_systems
At `manim/mobject/coordinate_systems.py` line 195 and 196, the origin code is 

```python
    def get_y_unit_size(self):
        return self.get_x_axis().get_unit_size()
```

And it should be
```python
    def get_y_unit_size(self):
        return self.get_y_axis().get_unit_size()
```
This typo is small but may cause confusion if someone use this method. Please fix it soon.
`angle_of_tangent` method of Coordinate System gives wrong result when the x and y axes aren't scaled equally
## Description of bug / unexpected behavior
The [way angle_of_tangent is implemented](https://github.com/ManimCommunity/manim/blob/main/manim/mobject/coordinate_systems.py#L635-L661) right now causes issues when getting the angle for graphs where the x and y axes aren't scaled equally. For example, 

```py
class TestGraphScene(Scene):
  def construct(self):
    ax = NumberPlane()
    graph = ax.get_graph(lambda x : x**2, x_range=[-2, 2.5, 0.01], color=RED)
    b = ax.angle_of_tangent(2, graph, dx=0.01)

    c = Tex("ax.","angle\_","of\_","tangent","(2, graph1)","(in radians)=",b).scale(0.8).move_to(np.array([-1,-1.3,0]))
    c[0].set_color(ORANGE)
    c[1:4].set_color(BLUE)
    e = Tex("but the correct answer is: 1.3258166").next_to(c, DOWN) 
    
    self.add(c,e, ax, graph)
```
gives a relatively close result to the correct answer:
![image](https://user-images.githubusercontent.com/9102529/122345420-6b69fd00-cf7a-11eb-86a7-44b1467a802e.png)

But

```py
class TestGraphScene(Scene):
  def construct(self):
    ax = Axes([-2, 2.5], [-1, 5], x_length = 10)
    graph = ax.get_graph(lambda x : x**2, x_range=[-2, 2.5, 0.01], color=RED)
    b = ax.slope_of_tangent(2, graph, dx=0.01)

    c = Tex("ax.","angle\_","of\_","tangent","(2, graph1)","(in radians)=",b).scale(0.8).move_to(np.array([-1,-1.3,0]))
    c[0].set_color(ORANGE)
    c[1:4].set_color(BLUE)
    e = Tex("but the correct answer is: 1.3258166").next_to(c, DOWN) 
    
    self.add(c,e, ax, graph)
```

gives a different result:

![image](https://user-images.githubusercontent.com/9102529/122345492-7f156380-cf7a-11eb-91d2-2ee07dd20669.png)

Changing the x_length to 2 gives yet another different result:
![image](https://user-images.githubusercontent.com/9102529/122345668-aec46b80-cf7a-11eb-85e6-f33ba347e5c8.png)

(credit to anant_patel on Discord for first discovering this issue)

A simple solution would be to calculate the `slope_of_tangent` first instead, using the naive f(x+h)-f(x)/h for some small h, then calculating the `angle_of_tangent` from there instead (instead of the current method, which is the other way around). However, since we have to rewrite it anyways, it'll probably be best to offload this work to some other library; this will likely lead to more accurate results and also cut down on some of the code we have to maintain.

## Expected behavior
<!-- Add a clear and concise description of what you expected to happen. -->


## How to reproduce the issue
<!-- Provide a piece of code illustrating the undesired behavior. -->

<details><summary>Code for reproducing the problem</summary>

```py
Paste your code here.
```

</details>


## Additional media files
<!-- Paste in the files manim produced on rendering the code above. -->

<details><summary>Images/GIFs</summary>

<!-- PASTE MEDIA HERE -->

</details>


## Logs
<details><summary>Terminal output</summary>
<!-- Add "-v DEBUG" when calling manim to generate more detailed logs -->

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

<!-- Insert screenshots here (only when absolutely necessary, we prefer copy/pasted output!) -->

</details>


## System specifications

<details><summary>System Details</summary>

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (`python/py/python3 --version`):
- Installed modules (provide output from `pip list`):
```
PASTE HERE
```
</details>

<details><summary>LaTeX details</summary>

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:
<!-- output of `tlmgr list --only-installed` for TeX Live or a screenshot of the Packages page for MikTeX -->
</details>

<details><summary>FFMPEG</summary>

Output of `ffmpeg -version`:

```
PASTE HERE
```
</details>

## Additional comments
<!-- Add further context that you think might be relevant for this issue here. -->



Discussion:

Resolving patch:
diff --git a/manim/mobject/coordinate_systems.py b/manim/mobject/coordinate_systems.py
--- a/manim/mobject/coordinate_systems.py
+++ b/manim/mobject/coordinate_systems.py
@@ -943,6 +943,30 @@ def construct(self):
                     f"x={x} not located in the range of the graph ([{self.p2c(graph.get_start())[0]}, {self.p2c(graph.get_end())[0]}])",
                 )
 
+    def input_to_graph_coords(self, x: float, graph: "ParametricFunction") -> Tuple:
+        """
+        Returns a tuple of the axis relative coordinates of the point
+        on the graph based on the x-value given.
+
+        Examples
+        --------
+
+        .. code-block:: pycon
+
+            >>> from manim import Axes
+            >>> ax = Axes()
+            >>> parabola = ax.plot(lambda x: x ** 2)
+            >>> ax.input_to_graph_coords(x=3, graph=parabola)
+            (3, 9)
+        """
+        return x, graph.underlying_function(x)
+
+    def i2gc(self, x: float, graph: "ParametricFunction") -> Tuple:
+        """
+        Alias for :meth:`input_to_graph_coords`.
+        """
+        return self.input_to_graph_coords(x, graph)
+
     def i2gp(self, x: float, graph: "ParametricFunction") -> np.ndarray:
         """
         Alias for :meth:`input_to_graph_point`.
@@ -1313,7 +1337,7 @@ def angle_of_tangent(
             ax = Axes()
             curve = ax.plot(lambda x: x ** 2)
             ax.angle_of_tangent(x=3, graph=curve)
-            # 1.3825747960950903
+            # 1.4056476493802699
 
 
         Parameters
@@ -1331,8 +1355,8 @@ def angle_of_tangent(
             The angle of the tangent to the curve.
         """
 
-        p0 = self.input_to_graph_point(x, graph)
-        p1 = self.input_to_graph_point(x + dx, graph)
+        p0 = np.array([*self.input_to_graph_coords(x, graph)])
+        p1 = np.array([*self.input_to_graph_coords(x + dx, graph)])
         return angle_of_vector(p1 - p0)
 
     def slope_of_tangent(


Test patch: