Last active
October 9, 2019 16:41
-
-
Save DownGoat/d3084d0d0f6e1fe1e2c94554c7a14a74 to your computer and use it in GitHub Desktop.
flex.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# (1a) Write a function here | |
def func(x: float) -> float: | |
return -x * lam | |
def other_func(yn: float, _lambda: float) -> float: | |
return -(_lambda * yn) | |
def main(): | |
_lambda = 2 # lambda | |
time_delta = 0.05 # time step | |
total_integration_time = 0.2 # total integration time | |
time_steps = round(T / dt) # total number of time steps | |
initial_conditions = 1 # initial conditions | |
for it in range(nt): | |
initial_conditions = initial_conditions - time_delta * _lambda * initial_conditions # (1a) Your function should go here! | |
plt.plot((it + 1) * time_delta, func(initial_conditions), 'gs') | |
print("t_n = %-.2f, y_n = %-.3f, -lamy_n = %-.4f" | |
% ((it + 1) * time_delta, initial_conditions, func(initial_conditions))) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment