Opened 11 years ago

# Wrap Maxima's demoivre and exponentialize

Reported by: Owned by: mpatel burcin major sage-6.4 symbolics kcrisman, fmaltey N/A

### Description

Sage does not appear to have easily accesible analogues of Mathematica's `TrigToExp` and `ExpToTrig`. From AskSage:

```sage: x = var('x')
sage: t1 = cos(x)
sage: t2 = e^(I * x) / 2 / I - e^(-I * x) / 2 / I
sage: sageobj(t1._maxima_().exponentialize())
1/2*e^(-I*x) + 1/2*e^(I*x)
sage: sageobj(t2._maxima_().demoivre())
sin(x)
```

### comment:1 follow-up: ↓ 2 Changed 11 years ago by burcin

You can use `maxima_methods()` to access the maxima functions easily.

```sage: x = var('x')
sage: t1 = cos(x)
sage: t2 = e^(I * x) / 2 / I - e^(-I * x) / 2 / I
sage: res = t1.maxima_methods().exponentialize(); res
1/2*e^(-I*x) + 1/2*e^(I*x)
sage: type(res)
<type 'sage.symbolic.expression.Expression'>
sage: t2.maxima_methods().demoivre()
sin(x)
```

I am very much against wrapping each maxima function for manipulating symbolic expressions individually from Sage. Even though maxima provides a lot of functionality, their user interface is far from intuitive.

IMHO, the user interface to these functions should be something like:

```sage: t1.rewrite(exp)
1/2*e^(-I*x) + 1/2*e^(I*x)
sage: t2.rewrite(sin)
sin(x)
```

BTW, it would be great if we could think about how to provide basic functionality like this directly in Sage without relying on maxima. It's possible that this requires wrapping more of pynac's features, for example

but it's well worth the effort.

### comment:2 in reply to: ↑ 1 Changed 11 years ago by kcrisman

• Milestone set to sage-4.6.1

You can use `maxima_methods()` to access the maxima functions easily.

Yes, thanks for that reminder!

I am very much against wrapping each maxima function for manipulating symbolic expressions individually from Sage. Even though maxima provides a lot of functionality, their user interface is far from intuitive.

I don't see why we can't provide a more intuitive user interface for some of them, though. Just because a ticket is opened doesn't mean it will ever be fulfilled, but at least it's here now if enough people want it.

IMHO, the user interface to these functions should be something like:

```sage: t1.rewrite(exp)
1/2*e^(-I*x) + 1/2*e^(I*x)
sage: t2.rewrite(sin)
sin(x)
```

This seems awkward, esp. if you don't know ahead of time whether it's sin or cos. I think that `simplify_*` makes sense, the way we have it now. For now it's not worth having the discussion - I doubt anyone has time to do this right now. But if someone does, maybe it's time to revisit that.

BTW, it would be great if we could think about how to provide basic functionality like this directly in Sage without relying on

Yes, of course. If only we could have that Sage Days solely about symbolics...

but it's well worth the effort.

### comment:3 Changed 8 years ago by jdemeyer

• Milestone changed from sage-5.11 to sage-5.12

### comment:4 Changed 8 years ago by vbraun_spam

• Milestone changed from sage-6.1 to sage-6.2

### comment:5 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.2 to sage-6.3

### comment:6 Changed 7 years ago by vbraun_spam

• Milestone changed from sage-6.3 to sage-6.4
Note: See TracTickets for help on using tickets.