comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Transforming a nonlinear equation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Transforming a nonlinear equation [message #55214] Tue, 07 August 2007 10:37 Go to next message
wlandsman is currently offline  wlandsman
Messages: 743
Registered: June 2000
Senior Member
Very nice. Thanks.

I now realize that I actually have a nonlinear function of two
variables f(x,y) and need to find the new coefficients under linear
transformations of x-->x' and y-->y'. So I'll need to first find
the new X coefficients for each term in Y, and then find the new Y
coefficients for each term in X'. But it should be straightforward,
if tedious. --Wayne

> then the following code should deliver the new coefficients of the
> y-polynomial:
>
> degree=n_elements(a)-1
>
> newarray=a*0
>
> FOR i=0,degree DO BEGIN
> FOR j=0,i DO BEGIN
> newarray[j]=newarray[j]+a[i]*binomial(j,i)*alpha^j*beta^(i-j )
> ENDFOR
> ENDFOR
>
> where the binomial(j,n) function returns
> factorial(n)/(factorial(j)*factorial(n-j))
>
> Ciao,
> Paolo
Re: Transforming a nonlinear equation [message #55217 is a reply to message #55214] Tue, 07 August 2007 09:12 Go to previous messageGo to next message
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
wlandsman wrote:
> The following task probably can't be done with IDL, but maybe some IDL
> users can point me in the right direction.
>
> I have a nonlinear equation in x, e.g.
>
> (1) y = 3.2 + 1.2*x + 3.1*x^2 - 4.2*x^3
>
> and I have a linear transformation in x: x' = 1.2*x + 0.4
> so I want to find the new coefficients of equation (1) under the
> transformation. If I were to do this with pencil and paper, I
> would put the transformation equation into (1), and collect all the
> cubic terms, quadratic terms etc. to find the new coefficients.
>
> I presume (but am not certain) that this is something that is very
> simple to do with Mathematica or Maple. But right now I only
> need it for a couple of equations so I'd prefer not to have to learn
> Mathematica (or do it by hand). Thanks, --Wayne
>

This should be feasible using the binomial expansion formula

(a+b)^n =sum_i^n binomial(i,n) * a^i * b^(n-i)

If the original polynomial is given by an array a with the coefficients
index equal its order, and x=alpha*y+beta is the linear transformation,
then the following code should deliver the new coefficients of the
y-polynomial:

degree=n_elements(a)-1

newarray=a*0

FOR i=0,degree DO BEGIN
FOR j=0,i DO BEGIN
newarray[j]=newarray[j]+a[i]*binomial(j,i)*alpha^j*beta^(i-j )
ENDFOR
ENDFOR


where the binomial(j,n) function returns
factorial(n)/(factorial(j)*factorial(n-j))


Ciao,
Paolo
Re: Transforming a nonlinear equation [message #55239 is a reply to message #55217] Thu, 09 August 2007 22:53 Go to previous message
Marshall Perrin is currently offline  Marshall Perrin
Messages: 44
Registered: December 2005
Member
Hi Wayne,

wlandsman <wlandsman@gmail.com> wrote:
> I presume (but am not certain) that this is something that is very
> simple to do with Mathematica or Maple. But right now I only
> need it for a couple of equations so I'd prefer not to have to learn
> Mathematica (or do it by hand). Thanks, --Wayne

At the risk of telling you precisely what you asked not to hear,
the amount of Mathematica you would need to learn in order to solve
this is miniscule. I expect all you would need to do is type
in the equations and call "Simplify[y']".

It'd almost certainly be faster than pencil and paper or the binomial
theorem. I'd be happy to walk you through the syntax if you change
your mind...

- Marshall
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: byte offset in POINT_LUN
Next Topic: Re: the last line of a large file

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:51:36 PDT 2025

Total time taken to generate the page: 0.00943 seconds