Message Boards Message Boards

0
|
7374 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:
GROUPS:

Use Mathematica to simplify a function with repeating subexpression?

Posted 10 years ago

I have a large function (~2800 characters) with a high degree of nesting with parenthesis (more than 32 levels). I need to get it into a more simple form so it's parseable by other programs. I know that there are repeating subexpressions within the function that if eliminated (or "simplified" in some way) could allow the nesting level to drop low enough - but I don't know what the subexpression are, only that they exist.

However, I'm running into some issues. I'm mainly working with the Simplify function, but it doesn't seem to quite understand what I want. Below is an example formula for illustration (note that it doesn't happen to contain repeating subexpressions):

y = 0.61 + 0.12x(1)cos(84.54x(2)) + 0.55gauss(2.46 - 17.36sin(sinh(x(2)))cos(2.75sin(sinh(x(2)))))/(1.39 + 0.13x(2)cos(84.54x(2)))

x(1) and x(2) are each distinct variables, which Mathematica seemed to have difficulty with at first so I replaced them with a coding that I can later reverse, as shown below:

y = 0.61 + 0.12x\ $a\$cos(84.54x\ $b\$) + 0.55gauss(2.46 - 17.36sin(sinh(x\ $b\$))cos(2.75sin(sinh(x\ $b\$))))/(1.39 + 0.13x\ $b\$cos(84.54x\ $b\$))

That fix seemed to work. However, the problem I'm stuck on is that Matematica doesn't seem to understand the difference between functions and variables; i.e. running Simplify on the formula above produces the formula below, which breaks some rules (for example; cos, sin, sinh don't seem to have inputs anymore).

y = 0.61 + 10.14cosx\ $a\$x\ $b\$ + (gauss(0.12 - 2.39cossin^2sinh^2x\ $b\$^2))/ (0.13 + 1.cosx\ $b\$^2)

Can anyone give me some advice on how to solve this?

POSTED BY: Tim Burton
2 Replies
Posted 10 years ago

You might look at this Common subexpression eliminator which seems close to what you are looking for.

POSTED BY: Bill Simpson
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