Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Re: Converting Power terms to Times terms

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88046] Re: [mg88036] Re: Converting Power terms to Times terms
  • From: Reza Farrahi Moghaddam <imriss at yahoo.com>
  • Date: Wed, 23 Apr 2008 04:06:08 -0400 (EDT)

Hi Jens and Daniel,
Thank you. It was exactly what I was looking for.
Reza


----- Original Message ----
From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
To: mathgroup at smc.vnet.net
Sent: Tuesday, April 22, 2008 6:29:48 AM
Subject: [mg88046] [mg88036] Re: Converting Power terms to Times terms

Hi,

no, but you can redefine the output of Power[], so that it
look like a*a*a, i.e.

Unprotect[Power]
Format[Power[a_, n_Integer],
  FortranForm] := (HoldForm @@ {Table[a, {n}]}) /. List -> Times

Protect[Power]

and

FortranForm[a*b^4*Sin[w^2]]

gives

a*(b*b*b*b)*Sin(w*w)


Regards
  Jens

Reza Farrahi Moghaddam wrote:
> Hello,
>  
> I am using Dolfin/FFC for solving finite element problems. I want to use Mathematica for generating the linear and bilinear terms of the weak equation. After computing the terms, I use the "InputForm", and then give the results to FFC compiler. The problem is that FFC does not accept "power" function. Therefore, terms such as "a^2" must be written as "a*a". Because there are many terms in the weak form of my problem, manual conversion of power terms takes a long time (and probably is subject to errors).
>  
> Is there any way to disable "power" function, or stop "times" function to be simplified in the "power" form?
>  
> Any other solution?
>  
> Thanks,
> Reza
> 
> 



  • Prev by Date: Probably memory problem
  • Next by Date: Re: Problem with RegionFunction
  • Previous by thread: Re: Converting Power terms to Times terms
  • Next by thread: need help with Plot