I am an absolute beginner to programming and I have to make a program that numerically calculates the speed and position as functions of time by using the Euler-Cromer method stooping when the brick stops and find out how far it moves. Furthermore, I am asked to use matplotlib to plot the results and show of graphs for position, speed and acceleration as functions of time, but I have no idea where to even begin.

There are several guides online for Euler’s (and related) methods. Here is one that covers Euler-Cromer

https://cooperrc.github.io/computational-mechanics/module_03/03_Get_Oscillations.html

Hi,

You will have to learn how to start using `for loops`

since this type of problem requires multiple iterations (you can also use `list comprehensions`

which is ideally built for this). For example, when you plot a function, you plug in multiple values of the independent variable into a function. For each value of say, `x`

, there is a corresponding value of `y`

. You then connect the dots in the graph, and you now have a plot. However, to do this in Python code to do it for you, you can follow this example to familiarize yourself with the concepts to get you started.

Say, the values of `x`

are: x_values = [2, 3, 4, 5, 6] (the independent variable values)

The function is: y(x) = x ** 2 + 5 * x - 1.25 (the dependent variable values)

To solve for `y`

, you perform the following:

```
y_values = [ x ** 2 + 5 * x - 1.25 for x in x_values]
```

To plot on a graph the `x_values`

vs. `y_values`

:

```
from matplotlib import pyplot as pl
x_values = [2, 3, 4, 5, 6]
# Using a list comprehension to obtain values
y_values = [ x ** 2 + 5 * x - 1.25 for x in x_values]
print(y_values)
pl.plot(x_values, y_values, 'r')
pl.xlabel('X-Value')
pl.ylabel('Y-Value')
pl.title('Plot of X vs. Y')
pl.show()
```

What you’ll be doing is basically the same idea/concept.

Try learning the fundamentals first.