Suppose you wanted to define a constant whose value was Zeta[3]
, and call it AperysConstant. If you want to make AperysConstant behave like E, Pi
, etc., you would do:
SetAttributes[AperysConstant, Constant];
NumericQ[AperysConstant] = True;
N[AperysConstant, _] = Zeta[3];
Then, AperysConstant behaves like Pi
. Below I give some examples:
N
N[AperysConstant]
N[Pi]
N[AperysConstant, 20]
N[Pi, 20]
(* 1.20206 *)
(* 3.14159 *)
(* 1.2020569031595942854 *)
(* 3.1415926535897932385 *)
Dt
Dt[x^AperysConstant,x]
Dt[x^Pi, x]
Dt[x^y, x]
(* AperysConstant x^(-1+AperysConstant) *)
(* \[Pi] x^(-1+\[Pi]) *)
(* x^y (y/x+Dt[y,x] Log[x]) *)
Note the difference between AperysConstant and y above.
Less
1 < AperysConstant < 2
3 < Pi < 4
(* True *)
(* True *)
Sign
Sign[AperysConstant-2]
Sign[Pi-4]
(* -1 *)
(* -1 *)
Inexact arithmetic
AperysConstant + 1.1`20
Pi + 1.1`20
(* 2.3020569031595942854 *)
(* 4.2415926535897932385 *)
Variables
Variables[1 + Pi x + x^2]
Variables[1 + AperysConstant x + x^2]
(* {x} *)
(* {x} *)