I am trying to get my head around Options
, OptionsPattern
, etc. - I have looked e.g. here and here but am still struggling.
Say I want to create a "customised" version of FullSimplify
, (call it fs
) which is supposed to
- always use a certain set of assumptions
- allow for the input of additional assumptions.
Example: always assume a<0
, sometimes add b>0
. So the desired result would be:
Column[{
FullSimplify[Sqrt[a^2]],
fs[Sqrt[a^2]],
fs[Sqrt[a^2 b^2],
fs[Sqrt[a^2 b^2],{b>0}]
}]
Sqrt[a]
-a
-a Sqrt[b]
-a b
Now my question is how to define fs
(and the "default" assumption) properly. My (lousy) current attempt is something like
std:={a<0}; (* or "=" instead? *)
Options[fs]=OptionsPattern[Assumptions -> {a < 0}];
(* do I need to parse the other options of FullSimplify as well? *)
fs[x_,opts:OptionsPattern[]]:=FullSimplify[x,...]
(* how do I add the option {b>0} s.t. it becomes an _additional_ assumption? *)