[genius] Wed Oct 16 00:33:17 2013 Jiri (George) Lebl <jirka 5z com>
- From: George Lebl <jirka src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [genius] Wed Oct 16 00:33:17 2013 Jiri (George) Lebl <jirka 5z com>
- Date: Wed, 16 Oct 2013 05:43:23 +0000 (UTC)
commit e426a865c95160ae82494fddf11acb5e4983913d
Author: Jiri (George) Lebl <jirka 5z com>
Date: Wed Oct 16 00:43:04 2013 -0500
Wed Oct 16 00:33:17 2013 Jiri (George) Lebl <jirka 5z com>
* src/symbolic.c: add some derivatives for Bessel functions and
for the Lambert W functions
* help/C/genius.xml: document LambertW, LambertWm1, NewtonsMethod,
and some other minor improvements
* lib/equation_solving/newton.gel, lib/functions/elementary.gel:
improve help string for the Newton's method functions
* pixmaps/Makefile.am: pass -t to gtk-update-icon-cache to avoid
failing if no theme index file
ChangeLog | 14 ++++++
NEWS | 3 +-
help/C/genius.xml | 88 +++++++++++++++++++++++++++++++++++++-
lib/equation_solving/newton.gel | 4 +-
lib/functions/elementary.gel | 4 +-
lib/library-strings.c | 4 +-
pixmaps/Makefile.am | 2 +-
src/symbolic.c | 10 ++++-
8 files changed, 117 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a42ab7b..d0c8492 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+Wed Oct 16 00:33:17 2013 Jiri (George) Lebl <jirka 5z com>
+
+ * src/symbolic.c: add some derivatives for Bessel functions and
+ for the Lambert W functions
+
+ * help/C/genius.xml: document LambertW, LambertWm1, NewtonsMethod,
+ and some other minor improvements
+
+ * lib/equation_solving/newton.gel, lib/functions/elementary.gel:
+ improve help string for the Newton's method functions
+
+ * pixmaps/Makefile.am: pass -t to gtk-update-icon-cache to avoid
+ failing if no theme index file
+
Tue Oct 15 18:17:58 2013 Jiri (George) Lebl <jirka 5z com>
* lib/functions/lambert.gel, lib/equation_solving/newton.gel: Add
diff --git a/NEWS b/NEWS
index 2b31812..0c8f827 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
Changes to 1.0.18
-* Implement KroneckerProduct (alias TensorProduct) for matrices
+* New functions: KroneckerProduct (alias TensorProduct), NewtonsMethod,
+ LambertW, LambertWm1
* New PlotCanvasFreeze/PlotCanvasThaw functions to improve flicker
if doing animations with genius.
* Allow setting color in LinePlotDrawLine with RGB vector.
diff --git a/help/C/genius.xml b/help/C/genius.xml
index e8a7b43..e1cf9dc 100644
--- a/help/C/genius.xml
+++ b/help/C/genius.xml
@@ -7401,7 +7401,8 @@ and has period <userinput>b-a</userinput>.</para>
<para>The Gamma function. Currently only implemented for real values.</para>
<para>
See
- <ulink url="http://planetmath.org/encyclopedia/GammaFunction.html">Planetmath</ulink> for more
information.
+ <ulink url="http://planetmath.org/encyclopedia/GammaFunction.html">Planetmath</ulink> or
+ <ulink url="http://en.wikipedia.org/wiki/Gamma_function">Wikipedia</ulink> for more information.
</para>
</listitem>
</varlistentry>
@@ -7415,6 +7416,45 @@ and has period <userinput>b-a</userinput>.</para>
</varlistentry>
<varlistentry>
+ <term><anchor id="gel-function-LambertW"/>LambertW</term>
+ <listitem>
+ <synopsis>LambertW (x)</synopsis>
+ <para>
+ The principal branch of Lambert W function computed for only
+ real values greater than or equal to <userinput>-1/e</userinput>.
+ That is, <function>LambertW</function> is the inverse of
+ the expression <userinput>x*e^x</userinput>. Even for
+ real <varname>x</varname> this expression is not one to one and
+ therefore has two branches over <userinput>[-1/e,0)</userinput>.
+ See <link linkend="gel-function-LambertWm1"><function>LambertWm1</function></link> for the
other real branch.
+ </para>
+ <para>
+ See
+ <ulink url="http://en.wikipedia.org/wiki/Lambert_W_function">Wikipedia</ulink> for more
information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><anchor id="gel-function-LambertWm1"/>LambertWm1</term>
+ <listitem>
+ <synopsis>LambertWm1 (x)</synopsis>
+ <para>
+ The minus-one branch of Lambert W function computed for only
+ real values greater than or equal to <userinput>-1/e</userinput>
+ and less than 0.
+ That is, <function>LambertWm1</function> is the second
+ branch of the inverse of <userinput>x*e^x</userinput>.
+ See <link linkend="gel-function-LambertW"><function>LambertW</function></link> for the
principal branch.
+ </para>
+ <para>
+ See
+ <ulink url="http://en.wikipedia.org/wiki/Lambert_W_function">Wikipedia</ulink> for more
information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><anchor id="gel-function-MinimizeFunction"/>MinimizeFunction</term>
<listitem>
<synopsis>MinimizeFunction (func,x,incr)</synopsis>
@@ -7506,7 +7546,8 @@ and has period <userinput>b-a</userinput>.</para>
<para>The Riemann zeta function. Currently only implemented for real values.</para>
<para>
See
- <ulink url="http://planetmath.org/encyclopedia/RiemannZetaFunction.html">Planetmath</ulink> for
more information.
+ <ulink url="http://planetmath.org/encyclopedia/RiemannZetaFunction.html">Planetmath</ulink> or
+ <ulink url="http://en.wikipedia.org/wiki/Riemann_zeta_function">Wikipedia</ulink> for more
information.
</para>
</listitem>
</varlistentry>
@@ -7693,6 +7734,31 @@ and has period <userinput>b-a</userinput>.</para>
</varlistentry>
<varlistentry>
+ <term><anchor id="gel-function-NewtonsMethod"/>NewtonsMethod</term>
+ <listitem>
+ <synopsis>NewtonsMethod (f,df,guess,epsilon,maxn)</synopsis>
+ <para>Find zeros using Newton's method. <varname>f</varname> is
+ the function and <varname>df</varname> is the derivative of
+ <varname>f</varname>. <varname>guess</varname> is the initial
+ guess. The function returns after two successive values are
+ within <varname>epsilon</varname> of each other, or after <varname>maxn</varname> tries, in
which case the function returns <constant>null</constant> indicating failure.
+ </para>
+ <para>
+ See also <link
linkend="gel-function-NewtonsMethodPoly"><function>NewtonsMethodPoly</function></link> and <link
linkend="gel-function-SymbolicDerivative"><function>SymbolicDerivative</function></link>.
+ </para>
+ <para>
+ Example to find the square root of 10:
+ <screen><prompt>genius></prompt>
<userinput>NewtonsMethod(`(x)=x^2-10,`(x)=2*x,3,10^-10,100)</userinput>
+</screen>
+ </para>
+ <para>
+ See
+ <ulink url="http://en.wikipedia.org/wiki/Newtons_method">Wikipedia</ulink> for more information.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
<term><anchor id="gel-function-PolynomialRoots"/>PolynomialRoots</term>
<listitem>
<synopsis>PolynomialRoots (p)</synopsis>
@@ -7981,7 +8047,23 @@ and has period <userinput>b-a</userinput>.</para>
<term><anchor id="gel-function-NewtonsMethodPoly"/>NewtonsMethodPoly</term>
<listitem>
<synopsis>NewtonsMethodPoly (poly,guess,epsilon,maxn)</synopsis>
- <para>Run newton's method on a polynomial to attempt to find a root, returns after two successive
values are within epsilon or after maxn tries (then returns <constant>null</constant>).</para>
+ <para>Find a root of a polynomial using Newton's method. <varname>poly</varname> is
+ the polynomial as a vector and <varname>guess</varname> is the initial
+ guess. The function returns after two successive values are
+ within <varname>epsilon</varname> of each other, or after <varname>maxn</varname> tries, in
which case the function returns <constant>null</constant> indicating failure.
+ </para>
+ <para>
+ See also <link linkend="gel-function-NewtonsMethod"><function>NewtonsMethod</function></link>.
+ </para>
+ <para>
+ Example to find the square root of 10:
+ <screen><prompt>genius></prompt> <userinput>NewtonsMethodPoly([-10,0,1],3,10^-10,100)</userinput>
+</screen>
+ </para>
+ <para>
+ See
+ <ulink url="http://en.wikipedia.org/wiki/Newtons_method">Wikipedia</ulink> for more information.
+ </para>
</listitem>
</varlistentry>
diff --git a/lib/equation_solving/newton.gel b/lib/equation_solving/newton.gel
index 3975311..34449fa 100644
--- a/lib/equation_solving/newton.gel
+++ b/lib/equation_solving/newton.gel
@@ -1,11 +1,11 @@
# Newton's method
-SetHelp("NewtonsMethod","equation_solving","Run Newton's method on a function to attempt to find a root,
returns after two successive values are within epsilon or after maxn tries (then returns null)")
+SetHelp("NewtonsMethod","equation_solving","Attempt to find a zero of a functionf with derivative df using
Newton's method, returning after two successive values are within epsilon or after maxn tries (then returns
null)")
function NewtonsMethod(f,df,guess,epsilon,maxn) = (
guess := float(guess);
for n=1 to maxn do (
dfg := df(guess);
- if dfg == 0 then (
+ if dfg == 0.0 then (
error ("NewtonsMethod: division by zero");
bailout
);
diff --git a/lib/functions/elementary.gel b/lib/functions/elementary.gel
index 44d7cb0..9c3a315 100644
--- a/lib/functions/elementary.gel
+++ b/lib/functions/elementary.gel
@@ -263,14 +263,14 @@ erf = ErrorFunction
SetHelpAlias ("ErrorFunction", "erf");
#FIXME: Should probably be in a separate source file
-SetHelp("NewtonsMethodPoly","polynomial","Run newton's method on a polynomial to attempt to find a root,
returns after two successive values are within epsilon or after maxn tries (then returns null)")
+SetHelp("NewtonsMethodPoly","polynomial","Attempt to find a root of a polynomial using Newton's method,
returning after two successive values are within epsilon or after maxn tries (then returns null)")
function NewtonsMethodPoly(poly,guess,epsilon,maxn) = (
pf := PolyToFunction (poly);
pdf := PolyToFunction (PolyDerivative (poly));
guess := float(guess);
for n=1 to maxn do (
pdfg := pdf(guess);
- if pdfg == 0 then (
+ if pdfg == 0.0 then (
error ("NewtonsMethodPoly: division by zero");
bailout
);
diff --git a/lib/library-strings.c b/lib/library-strings.c
index 0f5d62d..103df5f 100644
--- a/lib/library-strings.c
+++ b/lib/library-strings.c
@@ -237,7 +237,7 @@ char *fake = N_("Find root of a function using the bisection method to within TO
char *fake = N_("Find root of a function using the method of false position to within TOL tolerance in up to
N iterations. f(a) and f(b) must have opposite signs.");
char *fake = N_("Find root of a function using the Muller's method");
char *fake = N_("Find root of a function using the secant method to within TOL tolerance in up to N
iterations. f(a) and f(b) must have opposite signs.");
-char *fake = N_("Run Newton's method on a function to attempt to find a root, returns after two successive
values are within epsilon or after maxn tries (then returns null)");
+char *fake = N_("Attempt to find a zero of a functionf with derivative df using Newton's method, returning
after two successive values are within epsilon or after maxn tries (then returns null)");
char *fake = N_("Find roots of a polynomial (given as vector of coefficients)");
char *fake = N_("Find roots of a quartic polynomial (given as vector of coefficients)");
char *fake = N_("Use classical non-adaptive Runge-Kutta of fourth order method to numerically solve
y'=f(x,y) for initial x0,y0 going to x1 with n increments, returns y at x1");
@@ -252,7 +252,7 @@ char *fake = N_("Calculate median of each row in a matrix");
char *fake = N_("Calculate the population standard deviations of rows of a matrix and return a vertical
vector");
char *fake = N_("Calculate the standard deviations of rows of a matrix and return a vertical vector");
char *fake = N_("Calculate the standard deviation of a whole matrix");
-char *fake = N_("Run newton's method on a polynomial to attempt to find a root, returns after two successive
values are within epsilon or after maxn tries (then returns null)");
+char *fake = N_("Attempt to find a root of a polynomial using Newton's method, returning after two
successive values are within epsilon or after maxn tries (then returns null)");
char *fake = N_("Returns a set where every element of X appears only once");
char *fake = N_("Returns a set theoretic union of X and Y (X and Y are vectors pretending to be sets)");
char *fake = N_("For a Hilbert function that is c for degree d, given the Macaulay bound for the Hilbert
function of degree d+1 (The c^<d> operator from Green's proof)");
diff --git a/pixmaps/Makefile.am b/pixmaps/Makefile.am
index 4f0d7fc..0b937dd 100644
--- a/pixmaps/Makefile.am
+++ b/pixmaps/Makefile.am
@@ -9,4 +9,4 @@ EXTRA_DIST = \
$(image_DATA)
install-data-hook:
- $(GTK_UPDATE_ICON_CACHE) -q $(datadir)/icons/hicolor
+ $(GTK_UPDATE_ICON_CACHE) -q -t $(datadir)/icons/hicolor
diff --git a/src/symbolic.c b/src/symbolic.c
index 604b74a..531e325 100644
--- a/src/symbolic.c
+++ b/src/symbolic.c
@@ -1,5 +1,5 @@
/* GENIUS Calculator
- * Copyright (C) 1997-2012 Jiri (George) Lebl
+ * Copyright (C) 1997-2013 Jiri (George) Lebl
*
* Author: Jiri (George) Lebl
*
@@ -125,6 +125,14 @@ gel_differentiate_func1_expr (GelToken *tok)
DERIVATIVE_ENTRY ("sinc", "cos(x)*x^(-1)-sinc(x)*x^(-1)");
+ DERIVATIVE_ENTRY ("BesselJ0", "-BesselJ1(x)");
+ DERIVATIVE_ENTRY ("BesselJ1", "(1/2)*(BesselJ0(x)-BesselJn(2,x))");
+ DERIVATIVE_ENTRY ("BesselY0", "-BesselY1(x)");
+ DERIVATIVE_ENTRY ("BesselY1", "(1/2)*(BesselY0(x)-BesselYn(2,x))");
+
+ DERIVATIVE_ENTRY ("LambertW", "LambertW(x)/(x*(1+LambertW(x)))");
+ DERIVATIVE_ENTRY ("LambertWm1", "LambertWm1(x)/(x*(1+LambertWm1(x)))");
+
/* FIXME: check these, I don't trust the CRC handbook */
DERIVATIVE_ENTRY_ALIAS ("asin", "arcsin", "1/sqrt(1-x^2)");
DERIVATIVE_ENTRY_ALIAS ("asinh", "arcsinh", "1/sqrt(1+x^2)");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]