Message Boards Message Boards

0
|
2920 Views
|
1 Reply
|
3 Total Likes
View groups...
Share
Share this post:

How to avoid numerical evaluation inside CForm?

Posted 2 years ago

Hi, I need to obtain listings of numerous formulae (in CForm) that contain some symbolic variables and also numerical floating point data, but I need to do it in such a way that the various floating point coefficients are not simplified. Here is a simple example containing a symbolic (unevaluated) variable s:

CForm[(N[5/3])*(s/N[1/9])^(N[1/13])]

Here I only want the terms N[5/3], N[1/9] and N[1/13] to be evaluated separately, without dividing N[5/3] by N[1/9]^N[1/13]. Normally this division is automatically performed. Is there any way to achieve this goal? Lesław

POSTED BY: Leslaw Bieniasz

Perhaps change Times to another function

res = CForm[mult[(N[5/3]), (s/N[1/9])^(N[1/13])]]

later then

res /. mult -> Times
POSTED BY: Hans Dolhaine
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract