extensions:eantic

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Last revisionBoth sides next revision
extensions:eantic [2021/07/08 00:06] – created jordanextensions:eantic [2021/07/10 16:42] jordan
Line 36: Line 36:
 ===== Examples ===== ===== Examples =====
  
-There also is jupyter notebook file ''demo/introduction.ipynb'' covering the basic usage of this extension. This example is taken from there.+Most of this extension's capabilities reside within the application ''common''; only the client ''regular_n_gon'' is part of the application ''polytope''
 + 
 +For further explanations we refer to the jupyter notebook file ''demo/introduction.ipynb'' which is covering the basic usage of this extension. This example is taken from there
 + 
 +We create the number field $\mathbb{Q}\left[\phi\right]$ generated by the **golden ratio** $\phi$, positive root of $a^2 - a - 1$. Therefore we make use of the constructor ''NumberField(UniPolynomial p, double m, double r)'' where ''p'' is the defining polynomial and the interval is described by a combination of the midpoint ''m'' and the radius ''r''
 + 
 +<code> 
 +> $p = new UniPolynomial<Rational,Int>("x^2 - x - 1"); 
 +> $nf = new NumberField($p, 1.61803, .00001); 
 +> print $nf; 
 +NumberField(a^2 - 1*a - 1, [1.618033988749894848205 +/- 6.52e-22]) 
 +</code> 
 + 
 +Equivalently, the polynomial can be given by a combination of two `String`s, one of which is the pretty string representation and the other one specifies the variable name: 
 + 
 +<code> 
 +$nf = new NumberField("a^2 - a - 1", "a", 1.61803, .00001); 
 +</code> 
 + 
 +An element of a number field can be constructed by stating its parent number field together with its value. This value can either trivially be given as another Scalar type, e.g. `Int`, or as a polynomial over the generator of the number field. This polynomial can either be given as an ''UniPolynomial<Rational,Int>'' or a pretty ''String''
 + 
 +<code> 
 +> $a = new NumberFieldElement($nf, "a"); 
 + 
 +> $p2 = new UniPolynomial<Rational,Int>("1 - x"); 
 +> $nfe_pol = new NumberFieldElement($nf, $p2); 
 + 
 +> $nfe_one = new NumberFieldElement($nf, 1); 
 + 
 +> $r = new Rational("inf"); 
 +> $nfe_inf = new NumberFieldElement($nf, $r); 
 + 
 +> print join("\n", $a, $nfe_pol, $nfe_one, $nfe_inf); 
 +(a ~ 1.6180340) 
 +(-a+1 ~ -0.61803399) 
 +
 +inf 
 +</code> 
 + 
 +The output of printing values dependent on the generator of the number field (which is displayed as ''a'') is split by a ''~'' into two representations, the exact algebraic polynomial over ''a'' and an approximate float. 
 + 
 +Further, these ''NumberFieldElement''s can be handled intuitively using operators for arithmetic and comparison.
  • extensions/eantic.txt
  • Last modified: 2021/08/07 23:09
  • by jordan