Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Avoid the use of certain functions

245 views
Skip to first unread message

Sam Takoy

unread,
Jul 17, 2010, 8:16:56 AM7/17/10
to
Hi,

Is there a way to ask Mathematica to avoid expressing answers in terms
of certain functions. For example, I can stand Sec, Csc, Sech, and Csch
and would rather see Sec^-1, etc.

Thanks!

Murray Eisenberg

unread,
Jul 18, 2010, 1:02:51 AM7/18/10
to
I don't think I understand your question, given that Sec^-1 means
ArcSec. Which are you trying to avoid, ArcSec or hyperbolic functions
Sech, etc.?

If you're just trying to avoid hyperbolic functions, you could use
TrigToExp, e.g.:

TrigToExp[Sech[x]] // InputForm
2/(E^(-x) + E^x)

[For purposes of text messages in this newsgroup, I used InputForm there
just in order to produce a 1-dimensional output instead of an actual
2-dimensional built-up (compound) fraction.]

Similary:

TrigToExp[ArcSech[x]]
Log[Sqrt[-1 + x^(-1)]*Sqrt[1 + x^(-1)] + x^(-1)]

--
Murray Eisenberg mur...@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305

David Park

unread,
Jul 18, 2010, 1:02:29 AM7/18/10
to
You could always do something like this:

MakeBoxes[Csc[x_], form : (StandardForm | TraditionalForm)] :=
InterpretationBox[#1, #2] & @@ {MakeBoxes[HoldForm[1/Sin[x]]],
Csc[x]}

1/Sin[x]
% // FullForm

Use

MakeBoxes[Csc[x_], form : (StandardForm | TraditionalForm)] =.

to clear the definition.

Frankly, I wouldn't do that kind of formatting because it is too special and
is hiding what Mathematica is actually working on and may not give the
intended result with more complicated expressions.

Clearly, you are trying to use Mathematica in a way that gives clearer
results in a textbook form. This is a good idea. If you gave some specific
examples you might obtain better answers.


David Park
djm...@comcast.net
http://home.comcast.net/~djmpark/

AES

unread,
Jul 19, 2010, 2:10:15 AM7/19/10
to
> From: Sam Takoy [mailto:sam....@yahoo.com]
>
> Hi,
>
> Is there a way to ask Mathematica to avoid expressing answers in terms
> of certain functions. For example, I [can't?] stand Sec, Csc, Sech, and Csch
> and would rather see Sec^-1, etc.

I'm with you on this one: always hated Sec and Csc (and never
understood the backward naming of these functions -- why isn't Sec =
1/Sin and Csc = 1/Cos?)

So, I'd like the various Simplifiy and XxxToYyy functions in Mathematica to
always give precedence to Sin and Cos by default, and avoid using Sec
and Csc whenever possible, even if this produces some "1 overs" in the
output expression.

But I suspect trying to implement this at this point would require more
complexity than it would be worth.

Andrzej Kozlowski

unread,
Jul 20, 2010, 3:43:15 AM7/20/10
to

On 19 Jul 2010, at 08:10, AES wrote:

>> From: Sam Takoy [mailto:sam....@yahoo.com]
>>
>> Hi,
>>
>> Is there a way to ask Mathematica to avoid expressing answers in terms
>> of certain functions. For example, I [can't?] stand Sec, Csc, Sech, and Csch
>> and would rather see Sec^-1, etc.
>
> I'm with you on this one: always hated Sec and Csc (and never

> understood the backward naming of these functions -- why isn't Sec ==
> 1/Sin and Csc == 1/Cos?)

Have you never noticed this:

1+ Tan[x]^2====Sec[x]^2

1+Cot[x]^2====Csc[x]^2

?

Andrzej Kozlowski

David Bailey

unread,
Jul 20, 2010, 3:43:59 AM7/20/10
to

Your description is a bit confused, but I take it you would like to see
an expression output in terms of Sin rather than Csc, but the normal
evaluation process defeats you:

In[1]:= 1/Sin[x]

Out[1]= Csc[x]

One answer to this, is to make a replacement that uses your own function
- say sin[x] for which Mathematica knows nothing. So for example:

In[2]:= Csc[x]^3 /. Csc[z_] -> 1/sin[z]

Out[2]= 1/sin[x]^3

If you need to re-input such expressions, you can use another
transformation to replace sin with Sin.

BTW, if you do a lot of this sort of manipulation, it can be convenient
to collect several rules in one variable:

displayNicely={ Csc[z_] -> 1/sin[z],Sec[z_]->1/cos[z]}

Then you can just append /.displayNicely to any calculation to obtain
this effect!

David Bailey

http://www.dbaileyconsultancy.co.uk

Murray Eisenberg

unread,
Jul 20, 2010, 3:45:57 AM7/20/10
to
One should not be so quick to condemn the world when it does not conform
to your own preconceptions and preferences!

There is a good geometric reason that sec is an appropriate name for the
reciprocal of cos rather than of sin. Draw the unit circle, center at
the origin O. Mark off a central angle of theta from the positive
x-axis, and let P be the corresponding point on the circle. Draw the
vertical line L through the point (1,0). Extend the ray OP until it
intersects L at a point Q. Then the length of OQ is sec (theta). That
line segment OQ cuts across the circle.

[See, e.g., http://en.wikipedia.org/wiki/Trigonometric_functions. (I
thought I remembered also some Wolfram Demonstration of this, but I
cannot locate it now.)]

Furthermore, in the usual list of the 6 trig functions

sin
cos
tan
cot
sec
csc

there is a symmetry of pairs around the middle: cot = 1/tan, sec =
1/cos, csc = 1/sin.

Finally, what's wrong with sec and csc? Mathematical expressions are
often simpler when expressed in terms of them, since this avoids
(explicit) use of fractions for the functions.

On 7/19/2010 2:10 AM, AES wrote:
>> From: Sam Takoy [mailto:sam....@yahoo.com]
>>

>> Hi,
>>
>> Is there a way to ask Mathematica to avoid expressing answers in terms

>> of certain functions. For example, I [can't?] stand Sec, Csc, Sech, and Csch


>> and would rather see Sec^-1, etc.
>

> I'm with you on this one: always hated Sec and Csc (and never

> understood the backward naming of these functions -- why isn't Sec =
> 1/Sin and Csc = 1/Cos?)
>
> So, I'd like the various Simplifiy and XxxToYyy functions in Mathematica to
> always give precedence to Sin and Cos by default, and avoid using Sec
> and Csc whenever possible, even if this produces some "1 overs" in the
> output expression.
>
> But I suspect trying to implement this at this point would require more
> complexity than it would be worth.
>

--

0 new messages