Curve creation including y variable
See original GitHub issueI have this script:
from manimlib.imports import *
import numpy as np
class graphx(GraphScene):
CONFIG={
"x_min": -4,
"x_max": 4,
"y_min": -2,
"y_max": 2,
"x_axis_label": "$x$",
"y_axis_label": "$y$",
"graph_origin": 0.5 * DOWN + 0 * LEFT,
}
# Defining graph functions
def show_function_graph(self):
self.setup_axes(animate=True)
# Math function
def func(x):
return x**3 + 497*x + 1768
#sin graph
graph_sin=self.get_graph(func,x_min=-5, x_max=5)
graph_sin.set_color(RED)
# Cos graph
# Play grapgs
self.play(ShowCreation(graph_sin,), run_time=3)
self.wait(1)
# self.play(ShowCreation(graph_cos), run_time=3)
# Defining construction
def construct(self):
self.show_function_graph()
and what I am trying to do is to show this curve: y^2 = x^3 + 497*x + 1768
.
Have tried to math.sqrt(x**3 + 497*x + 1768), but it doesn’t work.
Is there any way that I can include y
variable?
Issue Analytics
- State:
- Created 3 years ago
- Comments:11
Top Results From Across the Web
Curve Fitting using Linear and Nonlinear Regression
Curve fitting is the process of specifying the model that provides the best fit to the curve in your data. Learn how using...
Read more >Dependent and Independent Variables - YouTube
This math and science video tutorial shows you how to identify the dependent and independent variables so you which data to plot on...
Read more >How do you sketch level curves of multivariable functions?
7:52 // How to rewrite the function to graph the multivariable function? ... of x and y only and can therefore be graphed...
Read more >Module 3.2: Curvature, Dummy Variables and Interaction
To add curvature, we simply create a new variable by squaring the quantitative independent variable, as shown in Worksheet 3.2.5. On the Excel...
Read more >How do I include multiple independent variables or column ...
To do this, you need to use the table function. For example, suppose you plotted c0 as X and c1 as Y and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Mate
Push the code block containing the method implicit curve one level of indentation lower. The way I see it you’ve placed it in the construct block hence it couldn’t be initialized as an attribute of the scene class.
Your dilemma needs some serious math to be solved. Let’s dive in.
We start off by admitting that computers exist and if you’re going to hassle a graph in Manim at least get some help. Say, Desmos for example.
Your example is wayyy too complicated so I’m shrinking it down a bit.
Great! Now let’s think through this a bit.
For any x value you give me, can I determine the y value that is on that graph? Let’s see!
Yes…and no. Not all x values work(orange line) and even for those that do(purple line) you have to account for two solutions which is not very helpful.
The reverse is feasible though. Any y value gives you one and only one x value, Except it pushes you to do something less efficient and objectively worse: solving this equation:
And not just for any specific something, which is doable by hand, but every point in the y range available. The good thing about this, however, is being able to represent that as a parametric equation which is already Manim programmed.
You tell me if that’s worth the effort.