Re: How to get E**(-x), not 1/E**(x) ?
- To: mathgroup at smc.vnet.net
- Subject: [mg9786] Re: [mg9717] How to get E**(-x), not 1/E**(x) ?
- From: seanross at worldnet.att.net
- Date: Fri, 28 Nov 1997 05:35:02 -0500
- Sender: owner-wri-mathgroup at wolfram.com
ma zhanwen wrote: > > Hello, > > When I input an expression which containing natural logarithm exp(-x), > where x is a symbol, and I want to get the fortran form output. For > example, If the input is : > > FortranForm[ y*Exp[-x] ] where y is an arbitrary expression. > > the output will be : > > y/E**(x) > > Of course it is not wrong. But if I copy the output into a Fortran > program, when x is assigned a enough large positive value , the Fortran > program will overflow. But if it is y*E**(-x) , there will be no > problem. You may say that why not change y/E**(x) to be y*E**(-x) > yourself , It is because I have a great number of this kind of > expressions. It is a hard work to change them one by one and it is very > easy to make mistakes. > > So can you tell me how to force Mathematica to give me y*E**(-x), not > y/E**(x) ?? > > Many thanks for your help > > Zhanwen Ma > > Oak Ridge National Lab. > Physics Division > > Oak Ridge ,TN 37831-6354 Change the expression to a string and use a transformation. Since you are going to import this to a text file anyway, it doesn't matter if it is a string or a mathematica expression. StringReplace[ToString[FortranForm[ y*Exp[-x] ]],"/E**x"->"*E**(-x)"] -- Remove the _nospam_ in the return address to respond.