I am trying to do this homework exercise: Orbit of the Earth My plot does not show the whole trajectory. I don’t know if it is something wrong with my equations or if it is a plotting matter. Cheers! Earth trajectory Plot Answer Okay, so there’s a pretty funny typo: That’s 16 times larger than what you most likely wanted
Tag: numerical-methods
How to plot a line in 3 dimensional space with matplotlib
I have two 3D-points, for example a = (100, 100, 10) and b = (0, 100, 60), and would like to fit a line through those points. I know, the 3D line equation can have different shapes: Vector-form: Parameter-form: But I have a problem getting the data in the right shape for a numerical function. Answer The following code should
Implementing composite Gauss quadrature in Python
I want to implement the composite Gaussian quadrature in Python to evaluate the integral ∫01 ex2 dx. Evaluting this using Python’s quad command, I get ∫01 ex2 dx ≈ 1.46 Below is my attempt at implementing this in Python. What I expect is that as n gets larger, the closer the quadrature gets to the ‘real’ integral. However, as I
Numerical Python: Solving a BVP with a boolean condition?
I am not sure about the best way to ask this question, but I am trying to find the long-term state of an ODE system with an arbitrary extra constraint that needs to be fulfilled. Ex: In the code above, f is the right-hand-side of my ODE model. N is the dimension of my state vector X, t_range is the
Python implementation of Matlab Code – Finite Difference Method
Given this Matlab Code created by my teacher: I tried to implement this in Python by using this code: However when I run the code with the same inputs, I get different results when plotting them. My inputs: Python plot result compared to exact result. The x-es represent the actual solution, and the red line is the function: Matlab plot
How can I stop my Runge-Kutta2 (Heun) method from exploding?
I am currently trying to write some python code to solve an arbitrary system of first order ODEs, using a general explicit Runge-Kutta method defined by the values alpha, gamma (both vectors of dimension m) and beta (lower triangular matrix of dimension m x m) of the Butcher table which are passed in by the user. My code appears to