Question
Write a Python program that implements Lanchester's Law for aimed fire: Where x and y are the troop levels of opposing sides, and are their
Write a Python program that implements Lanchester's Law for aimed fire:
Where x and y are the troop levels of opposing sides, and are their respective lethality coefficients.
The program shall read inputs for the troop starting levels, x0 and y0, and the lethality coefficients and . It shall output a time history of the remaining troops for each side. This will require a numerical integration of the differential equations over time. A recommended simplest solution is to use Eulers method, but it is not required:
Where t is the time step size to increment tn to tn+1. The supplemental reference Numerical Methods also summarizes Eulers method and provides a sample program (see Sakai Resources>References).
An example test case with expected results for x0 = 1000, y0 = 800, = .8, and = .9 is shown in Figure 1. Supplementary information can be found in Alan Washburn, Lanchester Systems, 2000. This test example is described in section 2.2 on p. 7.
Figure 1: Expected Results for x0 = 1000, y0 = 800, = .8, and = .9
Use the Python 3.5 version. import math
#read initiali values of x0 , y0 and alpha and beta x0 = float(input("Enter x0: ")) alpha = float(input("Enter alpha: "))
y0 = float(input("Enter y0: ")) beta = float(input("Enter beta: "))
#set x to x0 , y to y0 and time to 0 and delta of time to 0.5 x = x0 y = y0 t = 0 delta_t = 0.5
for i in range(0,5): #calculate x and y at time t x = x0*math.exp((-((alpha*beta)**0.5))*t) y = y0*math.exp((-((alpha*beta)**0.5))*t) #print x and y at time t print("x = %f" %x) print("y = %f" %y) #TODO print time #increment time t = t+delta_t
Find the error in the code or develop a new code to: Develop three files 1 that ends with .py where you write the program and run it, 1 that ends with .pyc file and another one is a word file in which you will copy the program from the python file that you wrote.
Can you please complete that problem in python. Find the errors in the code so that it produces the right output. Also, don't forget to create the numerical integration of the differential equations over time which is supposed to be a graph.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started