# how to solve complex equation?

someone newsboost at gmail.com
Wed Jan 2 04:55:33 CET 2013

```On 01/01/2013 10:49 PM, Jens Thoms Toerring wrote:
> Usama Khan <usamazohad at gmail.com> wrote:
>> how to solve complex equation in pyhton? and then use it to make a program.
>> . i have created new post as my last post is i guessed ranked as a cheater.
>> .:(
>
>> i know very litle about python as well as programing. .
>
>> which equation am taliking u will be thinking. . i am giving u the link
>> kindly c that equation. . n kindly let me know the way. .
>
>> https://groups.google.com/forum/?fromgroups=#!topic/comp.lang.python/cxG7DLxXgmo
>
> First of all, the equation given there is unusable (even the number
> of parentheses doesn't match up). Propbably it's meant to be the
> one someone else posted a link to:
>
> http://classes.engr.oregonstate.edu/cce/winter2012/ce492/Modules/06_structural_design/06-3_body.htm
>
> This thingy can't be solved on paper so you need some iterative
> algorithm to find the solution. So waht you do is modify the equa-
> tion so that you have 0 on one side and then consider the other
> side to be a function of SN+1. Now the problem you're left with
> is to find the value(s) of SN+1 (and thus of SN) where the func-
> tion has a zero-crossing. A commonly use algorithms for finding
> zero-crossings is Newton's method. You can find lots of sites on
> the internet describing it in all neccessary detail. It boils
> down to start with some guess for the result and then calculate
> the next, better approximation via
>
>        xn+1 = xn - f(xn) / f'(xn)
>
> where f(xn)n) is the value of the function at point xn and
> f'(xn) the value of the derivative of f (with respect to x)
> also at xn. You repeat the process until the difference be-
> tween xn an the next, better approximation, xn+1, has become
> as small as you need it.
>
> So it's very simple to implement and the ugliest bit is pro-
> bably calculating the required derivative of the function with
> respect to SN+1 (wbich you can take to be x).

Exactly. I think a 5th semester engineering student should know this. If
not, it's not the python-skills that is the problem. It's the (lack of)
mathematical insight.

I think maybe the OP should not demand people here to "show the
solution", but begin with something much simpler and then as he becomes
better and better with python, he can move towards more programmatically
advanced code.

The basic idea about an iterating loop, defining an objective function
etc is not really advanced python.

But I think the OP should start out with something more simple than what
he tries to do here.

Just starting out by iteratingly finding the solution to x^2-9 = 0 is a
great starting place.

After having studied, googled python examples on the internet, I think
most people should be able to solve x^2-9=0 in a day for a guy who knows
about programming in an arbitrary programming language other than python.

It looks like laziness, when we don't see any attempts to show what has
been tried to do, from the OP's point of view.

The best way to get good feedback (IMHO) is to post some code and then
post any errors/warnings that python is giving back.

Don't just write: "Give me the code for doing this".

```

More information about the Python-list mailing list