MathGroup Archive 2009

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

Search the Archive

Re: Log[]//TraditionalForm


Hi,

> It is very very simple, Lui, you should practise yourself. :)
> 
> BTW, Log vs. ln is an aesthetic problem. The serious troubles are caused by 
> CForm and FortranForm. These "forms" produces output unreadable by 
> compilers. Therefore it is not possible to use Mathematica to generate 
> source code in C language. You need a proof?  Here is an example:
> 
> In[1]:= Series[Sin[x],{x,0,5}]
> Out[1]= x-x^3/6+x^5/120+O[x]^6
> In[2]:= Series[Sin[x],{x,0,5}]//CForm
> Out[2]//CForm=
> SeriesData(x,0,List(1,0,-0.16666666666666666,0,0.008333333333333333),1,
>    6,1)
> In[3]:= Series[Sin[x],{x,0,5}]//FortranForm
> Out[3]//FortranForm=
>         SeriesData(x,0,List(1,0,-0.16666666666666666,0,
>      -   0.008333333333333333),1,6,1)
> 
> Neither C/C++ nor Fortran (II/IV/77/95) have got "List" or "SeriesData".

If you want something not to work, there are many possibilities to make
it fail. The documentation states clearly that only some standard stuff
will be translated and you might need some additional definitions.

This will work with most compilers I know, provided x is defined as
float or double and you include mdefs.h for the C code:

Series[Sin[x], {x, 0, 5}] // Normal // CForm

Series[Sin[x], {x, 0, 5}] // Normal // FortranForm

albert


PS: I found that Mathematicas performance in general increases a lot
when using the option Brain -> On for $User. I'm not sure whether the
user installed on your system supports that option, but most users do,
so I would give it a try.


  • Prev by Date: Re: Surface fitting error while using Fit
  • Next by Date: Re: Surface fitting error while using Fit
  • Previous by thread: Re: Log[]//TraditionalForm
  • Next by thread: Re: Re: Log[]//TraditionalForm