Reputation: 15
I am new to sympy. My ultimate goal is to plot y with respect to x.
Y is the known formula of k, m, ω
and x = ω*(m/k)**0.5
is also known.
I want to know how can I plot a function of both of them.
I am not sure which direction I should proceed from. I have tried simplification, and in the handwritten calculation, M/K of the numerator and denominator should be eliminated, but I have used sympy to only achieve the same variables in the top and bottom, which makes me at a loss. I hope that you can give me a solution.
Upvotes: 1
Views: 252
Reputation: 19093
This is an implicit definition of y
and x
in terms of parameters omega
, k
and m
. Since omega
and x are directly proportional, I would recommend solving for omega
in terms of x
and then replacing omega
in y
with that solution. That will give you y
as a function of x
which you can then plot. Here is a toy example:
>>> from sympy.abc import x, w, k
>>> yi = w
>>> xi = w*k
>>> yx = yi.subs(w. solve(x - xi, w)[0]); yx
x/k
>>> plot(yx.subs(k, 1), ylim=(-1,3))
Upvotes: 2