[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reverse function numerically
From: |
Montgomery-Smith, Stephen |
Subject: |
Re: Reverse function numerically |
Date: |
Wed, 31 Jan 2018 17:41:07 +0000 |
User-agent: |
Mozilla/5.0 (X11; FreeBSD amd64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 01/28/18 17:35, stn021 wrote:
> Hello,
>
> this is the same question I asked in my previous mail about an hour ago.
> I have added a code-example to illustrate what I mean.
>
> See at the bottom of this email.
> This is only meant as an example. It can be solved algebraically, so
> please simply assume that it cannot be solved,
>
>
> My question is this:
> I have 2 functions:
>
> y1 = f1( x1,x2 )
> y2 = f2( x1,x2 )
>
> also there is the reverse function
>
> x1 = g1( y1,y2 )
> x2 = g2( y1,y2 )
>
> in octave syntax:
> [ y1,y2 ] = f( [ x1,x2 ] )
> [ x1,x2 ] = g( [ y1,y2 ] )
>
>
> Both functions lead to exactly one distinct pair of results for each
> pair of input variables.
> That means that within predefined limits ( im my example all variables
> are >=0 and <=1 )
>
> this is true : f ( g ( [x1,x2] ) ) == [ x1,x2 ]
> and this also: ( f(a,b) == f(c,d) ) <=> ( a==c and b==d )
>
> I am not a mathmatician so I hope I got this one right :-)
>
>
> My problem is this: I can calculate f(x1,x2) but I cannot calculate g(y1,y2).
> Meaning that f( [x1,x2] ) cannot be algebraically reversed.
>
> I am looking for a way to calculate g( [y1,y2] ).
> The obvious solution would be some kind of approximation.
> (fft looks like a good choice)
>
> So far I could not piece together how to do that.
> Could you please give me a hint ?
>
> THX,stn
>
>
> code-example:
>
> # function [x1 x2] = g(y1,y2)
> # ...unclear...
> # end
>
> function [y1 y2] = f( x1,x2 )
> y1 = x1.^2 .* (2-x2) / 2 ;
> y2 = (2-x1) .* x2.^2 / 2 ;
> end
>
>
> x = 0:.025:1 ;
> [ x1 x2 ] = meshgrid( x,x ) ;
> [ y1 y2 ] = f( x1 , x2 ) ;
>
> plot3( x1,x2,y1,".g" ) ; hold on ;
> plot3( x1,x2,y2,".b" ) ;
> xlabel( "x1" ) ; ylabel( "x2" ) , zlabel( "y1 y2" ) ;
You can put the problem into Wolfram alpha:
https://www.wolframalpha.com/input/?i=Solve%5B%7By1%3D%3D1%2F2x1%5E2(2-x2),y2%3D%3D1%2F2(2-x1)x2%5E2%7D,%7Bx1,x2%7D%5D
then you will see it involves solving a quintic. As far as I know, the
best way to solve a quintic is using a numerical method, like fsolve.
So I think you are stuck using fsolve, or some other numerical method.
Another way I have seen is to use Neural Nets to find the coefficients
of a polynomial or rational function approximation to the inverse. That
would end up being rather fast once you have computed the coefficients.
I personally have no idea how to use Neural Nets, so I couldn't help you
any more than that. You could use some other optimization method to
compute the coefficients.
You would want to graph the inverse function to get some idea of what
the form of the polynomial or rational function should be, before you
start fitting coefficients.
- Reverse function numerically, stn021, 2018/01/28
- Re: Reverse function numerically, stn021, 2018/01/28
- Re: Reverse function numerically, Steven Dorsher, 2018/01/28
- Message not available
- Message not available
- Re: Reverse function numerically, stn021, 2018/01/28
- Re: Reverse function numerically, Montgomery-Smith, Stephen, 2018/01/28
- Message not available
- Fwd: Reverse function numerically, Juan Pablo Carbajal, 2018/01/31
- Re: Reverse function numerically, stn021, 2018/01/31
- Re: Reverse function numerically, Juan Pablo Carbajal, 2018/01/31
Re: Reverse function numerically,
Montgomery-Smith, Stephen <=