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

$Assumptions

48 views
Skip to first unread message

Ruth Lazkoz Sáez

unread,
Oct 8, 2008, 6:38:02 AM10/8/08
to
Dear all,

I seem to be unable to change some default options globally.

At the top of my notebook I have

$Assumptions = {MaxRecursion -> 30, AccuracyGoal -> 10};

Then we I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}]
I get 4.78196*10^-176

But if I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}, MaxRecursion -> 30,
AccuracyGoal -> 10]
I get quite a different value, 1.36703*10^-177

I had the same problem trying to change the options for fonts in plots,
and then I had to add the options I wanted
in every plot, I mean evaluation something like $TextStyle ={whatever}
before doing the plots did not work.

Hope you can help me. Thanks,

Ruth Lazkoz

Albert Retey

unread,
Oct 9, 2008, 6:34:13 AM10/9/08
to
Hi,

> I seem to be unable to change some default options globally.
>
> At the top of my notebook I have
>
> $Assumptions = {MaxRecursion -> 30, AccuracyGoal -> 10};

If you want to change default options, use SetOptions. Changing
$Assumptions will not have any effect on NIntegrate, except that you
might introduce unintended side effects. This should do what you want:

SetOptions[NIntegrate,MaxRecursion -> 30, AccuracyGoal -> 10]

you can even check that this has been succesful by evaluating:

Options[NIntegrate]

> Then we I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}]
> I get 4.78196*10^-176
>
> But if I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}, MaxRecursion -> 30,
> AccuracyGoal -> 10]
> I get quite a different value, 1.36703*10^-177
>
> I had the same problem trying to change the options for fonts in plots,
> and then I had to add the options I wanted
> in every plot, I mean evaluation something like $TextStyle ={whatever}
> before doing the plots did not work.

Same story here: You need to change the Options of Plot:

SetOptions[Plot, BaseStyle -> {FontSize -> 20}]

>From the documentation:
"As of Version 6.0, $TextStyle has been superseded by BaseStyle and
other options."

There have been complaints about the documentation, but still I think it
is a good idea to first look there if something doesn't work as expected...

hth,

albert

Szabolcs Horvat

unread,
Oct 9, 2008, 6:34:24 AM10/9/08
to
Ruth Lazkoz Sáez wrote:
> Dear all,
>
> I seem to be unable to change some default options globally.
>
> At the top of my notebook I have
>
> $Assumptions = {MaxRecursion -> 30, AccuracyGoal -> 10};
>

$Assumptions is for mathematica assumptions about symbols, not for
options. Please read the documentation page of $Assumptions.

> Then we I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}]
> I get 4.78196*10^-176
>
> But if I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}, MaxRecursion -> 30,
> AccuracyGoal -> 10]
> I get quite a different value, 1.36703*10^-177

Use

SetOptions[NIntegrate, MaxRecursion -> 30, AccuracyGoal -> 10]

etc.

Peter Breitfeld

unread,
Oct 9, 2008, 6:35:07 AM10/9/08
to
Ruth Lazkoz Sáez schrieb:

If you evaluate

NIntegrate[Exp[-x^2], {x, 20, 40}, Assumptions -> True]

you will get the error message:

NIntegrate::optx: Unknown option Assumptions in \
NIntegrate[E^-x^2,{x,20,40},Assumptions->True].

This means, that NIntegrate doesn't have an Assumptions option.

Setting $Assumtions to any value works only for functions with an
Assumtions optin which must default to $Assumptions.

The function Assuming works similiar to construct like this:

Assuming[assum_,expr_]:=Block[{$Assumptions=assum},expr]

so using Assuming won't work with NItegrate either.

The following function, which I found in this group, lists all
functions in the System-context, which have an Assumptions option:

hatOption[option_] :=
ToExpression /@
Quiet[Select[Names["System`*"],
MemberQ[ToExpression[#, StandardForm,
Options[Unevaluated[#]] &][[All, 1]], option] &]];
hA = hatOption[Assumptions]

The only function of these, which has not Assumptions->$Assumptions
as default option is PowerExpand. It's Assumptions Option defaults
to Automatic. So PowerExpand too will not reacht on setting
$Assumptions or using Assuming.

Gruss Peter
--
==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==-==
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

Jean-Marc Gulliet

unread,
Oct 9, 2008, 6:36:09 AM10/9/08
to
Ruth Lazkoz Sáez wrote:

What you want is *SetOptions* (Note that $Assumptions has nothing to do
with options but with assumptions such as x > 0 or Element[n, Integers])

In[166]:=
SetOptions[NIntegrate, {MaxRecursion -> 30, AccuracyGoal -> 10}];

NIntegrate[Exp[-x^2], {x, 20., 40.}]

Out[167]= 1.36703*10^-177

Regards,
-- Jean-Marc

Jens-Peer Kuska

unread,
Oct 9, 2008, 6:39:49 AM10/9/08
to
Hi,

and option in *not* an assumption. Assumptions are for symbols/variables
options are a way to do something.

Use SetOptions[]

Regards
Jens

Ruth Lazkoz S=E1ez wrote:
> Dear all,
>
> I seem to be unable to change some default options globally.
>
> At the top of my notebook I have
>
> $Assumptions = {MaxRecursion -> 30, AccuracyGoal -> 10};
>
> Then we I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}]
> I get 4.78196*10^-176
>

> But if I evaluate NIntegrate[Exp[-x^2], {x, 20., 40.}, MaxRecursion ->=


30,
> AccuracyGoal -> 10]
> I get quite a different value, 1.36703*10^-177
>

> I had the same problem trying to change the options for fonts in plots,=

> and then I had to add the options I wanted

> in every plot, I mean evaluation something like $TextStyle ={whatever=

0 new messages