Python Forum
Solving nth degree simultaneous equations
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Solving nth degree simultaneous equations
#1
I am completely new to Python and just figuring my way around the language. However, I was wondering if there was a way of solving 'n'th degree simultaneous equation using Python.

For example:
If S=Skwedness from a known data set and K=Kurtosis from a known data set:

1=B²+2C²+6BD+15D²
S=8C³+B²C+72BCD+270CD²
K=3B**4+60B²C²+60C**4+936BC²D+630B²D²+3780BD³+10395*(D**4)-3

What would be the easiest way of solving equations of this nature on Python?
Reply
#2
Simply convert to a Python formula? For example  1=B²+2C²+6BD+15D² becomes I = B**2 + 2 * C**2 + 6 * B * D +15 * D**2 . Keeping in mind Pythons Operator Precedence, which may require one or more layers of parenthesis.
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
(Sep-28-2017, 01:17 PM)sparkz_alot Wrote: Simply convert to a Python formula? For example  1=B²+2C²+6BD+15D² becomes I = B**2 + 2 * C**2 + 6 * B * D +15 * D**2 . Keeping in mind Pythons Operator Precedence, which may require one or more layers of parenthesis.

[inline]from scipy.optimize import fsolve
import math

def equations(p):
b, c, d = p
return (b**2 +2 * c**2 + 6 * b * d + 15 * d**2-1, 8 * c**3 +6 b**2 * c +72 * b *c * d +270 * c * d**2-0.09313246, 3 * b**4+ 60 * b**2 * c**2+ 60 * c**4+ 60 * b**3 * d+ 936 * b * c**2 * d+ 630 * b**2 * d**2+ 4500 * c**2 * d**2+ 3780 * b * d**3+ 10395 * d**4-3-3.058328)

b, c, d = fsolve(equations, (1, 1, 1))

print equations((b, c,d))[/inline]

I tried the following code, using fsolve from numpy. However, it still says that I have a syntax error.
Reply
#4
It's ok, we'll wait for you to share the error :)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  construction of Neural Network for solving Differential equations arshad 0 1,615 Jun-04-2020, 09:20 AM
Last Post: arshad
  Need Help solving second order differential equations SkewedZone 2 3,103 Jun-25-2019, 12:14 PM
Last Post: SkewedZone

Forum Jump:

User Panel Messages

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