Python Forum
Solving for zeros of an equation!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solving for zeros of an equation!
#1
Hello all,

Looking for some advice on how to solve for the zeros of a particular variable in the equation below. I am new to Python, coming from MATLAB. I have a conceptual rocket propulsion sizing code from MATLAB that I am transcribing into Python since I am no longer a student and have no access to MATLAB since the license expired.


The equation: 0 = (1/M**2)*(((2/(ga+1))*(1+((ga-1)/2)*M**2))**((ga+1)/(ga-1)))-AR**2
where (just as an example):
ga = 1.147
AR = 45


Reference here: http://www.joshtheengineer.com/2016/11/1...-relation/



Everything has been defined already except for the Mach number, M. What this step in the code does is just figure out what Mach number is required given the other predetermined parameters. Obviously it is quadratic, so there will be two solutions. One will be between 0 and 1, which would be the subsonic solution while the other is the supersonic solution. The supersonic solution will be anywhere from 1 to 5 ish. I just need assistance on how to have this equation solved for those two values of M, and give me the value that is greater than or equal to 1. I may technically be a rocket scientist, but we did not get enough exposure to complex mathematical coding in my Aerospace Engineering program.

Any help is greatly appreciated!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question written RK solving same equation with different graphs acbshinn 1 339 Feb-09-2024, 12:33 PM
Last Post: Gribouillis
  Solving an equation by brute force within a range alexfrol86 3 2,699 Aug-09-2022, 09:44 AM
Last Post: Gribouillis
  remove zeros at the end of a number Frankduc 7 2,102 Feb-25-2022, 03:48 PM
Last Post: Frankduc
  Solving equation equal to zero: How to resolve the syntax error? alexfrol86 3 1,893 Feb-21-2022, 08:58 AM
Last Post: deanhystad
  Dataframe Removes Zeros JoeDainton123 2 4,317 Sep-17-2020, 12:47 PM
Last Post: scidam
  How to Solving non-linear equation using scipy.optimize fsolve with variable list djhak 3 4,382 Jun-10-2020, 04:12 PM
Last Post: Gribouillis
  How to keep leading zeros with pandas? eeps24 1 6,469 May-20-2020, 07:51 PM
Last Post: deanhystad
  Asking for help in solving a single variable nonlinear equation using Python ! NDP 0 1,965 Feb-15-2019, 12:03 PM
Last Post: NDP
  Probs with leading zeros falling away :-) Badosc 2 2,826 Dec-04-2018, 08:57 PM
Last Post: Badosc
  Controlling trailing zeros with rounding? RedSkeleton007 1 24,407 Jan-25-2018, 07:23 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020