# Re: Determining the inverse function operation from a function definition

## "Dr. Diettrich" <drdiettrich@compuserve.de>13 May 2005 17:56:43 -0400

From comp.compilers

Related articles
[2 earlier articles]
Re: Determining the inverse function operation from a function definit mailbox@dmitry-kazakov.de (Dmitry A. Kazakov) (2005-04-28)
Re: Determining the inverse function operation from a function definit lfinsto1@gwdg.de (Laurence Finston) (2005-04-28)
Re: Determining the inverse function operation from a function definit wyrmwif@tsoft.org (SM Ryan) (2005-04-28)
Re: Determining the inverse function operation from a function definit drdiettrich@compuserve.de (Dr. Diettrich) (2005-04-28)
Re: Determining the inverse function operation from a function definit nmm1@cus.cam.ac.uk (2005-04-30)
Re: Determining the inverse function operation from a function definit gah@ugcs.caltech.edu (glen herrmannsfeldt) (2005-04-30)
Re: Determining the inverse function operation from a function definit drdiettrich@compuserve.de (Dr. Diettrich) (2005-05-13)
| List of all articles for this month |

 From: "Dr. Diettrich" Newsgroups: comp.compilers Date: 13 May 2005 17:56:43 -0400 Organization: Compilers Central References: 05-04-067 Keywords: theory Posted-Date: 13 May 2005 17:56:43 EDT

Ron Foster wrote:
>
> Hi.
> I am working on a small project to evaluate and execute unit conversion
> expressions. I started wondering whether it was possible to determine what
> the reverse conversion rules might blook like.
>
> For example, one might want to define the classic Celsius to Fahrenheit
> convesrion expression along the lines of:
>
> F( c ) = ( 9 / 5 ) * c + 32.
>
> It seems as though there's enough information there to deduce the inverse
> Fahrenheit to Celsius conversion:
>
> C( f ) = ( f - 32 ) / ( 5 / 9 )

You did a bit too much, using my school math the result should read:
C( f ) = ( f - 32 ) / ( 9 / 5 )

There should't exist too many linear conversion formulas, so a table
with the constants and the two conversion functions should be feasable.
Perhaps all you need is y=a*x+b and y=a/x+b, with the according inverse
functions. Things will become a bit more complicated with
exponentiation, sine, or other non-linear functions.

In the general case you can build an expression tree and implement a
transformation procedure for the reverse expression. Using an
appropriate language with built-in list manipulation will simplify
things a lot. I remember one of my first LISP exercises, a conversion
from/to RPN...