# Question:how to make Maple use exp(n*x) instead of exp(x)^n where n is integer?

## Question:how to make Maple use exp(n*x) instead of exp(x)^n where n is integer?

Maple 2020

Both exp(x)^2 and exp(2*x) are correct and the same.

simplify(exp(x)^2 - exp(2*x))

0

But I can't figure how to make Maple always use exp(2*x) instead. This is for exponent  in integers. This covers 90% of all cases in the Latex I generate.

This is only for Latex purposes and for typesetting only as it looks much better and more standard to use exp(2*x) than exp(x)^2.

Here is an example

```restart;
expr:=-(2*x+1)*exp(-x)/(exp(-2*x))+(2*x+1)/exp(-2*x);
expand(expr)
```

The latex for the above looks like

The Latex take much larger vertical space on the line. Compare the above to the same expression, but written with exponent inside

`expr:=-2*exp(x)*x - exp(x) + 2*exp(2*x)*x + exp(2*x)`

Which generates Latex

Which is much more pleasent to read and has less height as well.

Is there a way to automatically make Maple do that? Could I add my own `Latex\function` ? As described in

https://www.maplesoft.com/support/help/Maple/view.aspx?path=latex%2ffunctions

How? Also, I am using Physics:-Latex and not :-latex, so I do not know if the above page would even apply here.

it will be hard to write code to manually fix this, by may be string searching and fix it as the program is running.

Any suggestions? Note that Mathematica automatically does this when the exponent is integer

Update

Thanks to the hint by Axel Voget below, I tried to use combine, but only target it to exp(x)^n part of the whole expression, as I do not want to apply combine to each expression. This is what I came up with

```restart;
expr := -2*exp(x)*x - exp(x) + 2*exp(x)^2*x + exp(x)^2 + sin(x)^3 + cos(x)^2;
subsindets(expr,'exp(anything)^(anything)',f->combine(f));
```

Which seems to do what I want. It only applies to exp(x)^n and no other part. Compare this to applying combine to the whole expression

combine(expr)

Which might not be what I wanted.

I still need to test the above more, as may be I did not check for other cases. But if this works, then this will solve my problem. I can add this in one place, where it does this just before emitting the Latex. All my Latex generation is done inside one function which is called from everywhere. So I could easily add this there without changing anything else in the program.

﻿