Homework physics help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Homework physics help

This is actually a physics assignment simulating a throw. Can someone please help me to plot a function based on the solution of the equation? I want to plot a function where the 'y' symbol is the variable. Please ask questions if u don't understand my problem. import sympy as sp import matplotlib.pyplot as plt import numpy as np from scipy import constants as constant x = sp.Symbol('x') t = sp.Symbol('t') y = sp.Symbol('y') y0 = 2.0 x0 = 0 v0 = 20 v0x = v0*np.sin(30) v0y = v0*np.cos(30) ax = 0 ay = -(constant.g) eq1 = sp.Eq(0.5*ax*t**2 + v0x*t + x0,x) eq2 = sp.Eq(0.5*ay*t**2 + v0y*t + y0,y) solve = sp.solve((eq1,eq2), (x, t))

28th Sep 2022, 1:21 PM
mariusep
1 Answer
+ 1
I found that the result of your equation is a 2d list with each element being a function of y. You can use sympy.plotting to generate subplots for each equation and combine them to a single plot like this. Maybe there is an easier way, but I am not an expert :) https://code.sololearn.com/c61vJw2tYyx0/?ref=app
28th Sep 2022, 6:13 PM
Tibor Santa
Tibor Santa - avatar