Cun Zhang’s Blog

January 13, 2008

solve nonlinear equations in Maxima

Filed under: Math — Tags: , , — Cun Zhang @ 23:47

mnewton is an implementation of Newton’s method for solving nonlinear equations in one or more variables.

Function: mnewton (FuncList,VarList,GuessList)

Multiple nonlinear functions solution using the Newton method. FuncList is the list of functions to solve, VarList is the list of variable names, and GuessList is the list of initial approximations.The solution is returned in the same format that solve() returns. If the solution isn’t found, [] is returned.This function is controlled by global variables newtonepsilon and newtonmaxiter.

(%i1) load("mnewton")$
(%i2) mnewton([x1+3*log(x1)-x2^2, 2*x1^2-x1*x2-5*x1+1],
[x1, x2], [5, 5]);
(%o2) [[x1 = 3.756834008012769, x2 = 2.779849592817897]]
(%i3) mnewton([2*a^a-5],[a],[1]);
(%o3)[[a = 1.70927556786144]]
(%i4) mnewton([2*3^u-v/u-5, u+2^v-4], [u, v], [2, 2]);
(%o4) [[u = 1.066618389595407, v = 1.552564766841786]]

To use this function write first load("mnewton"). See also newtonepsilon and newtonmaxiter.

January 12, 2008

Wordpress LaTeX test

Filed under: latex — Cun Zhang @ 1:20

f(x)=\int_0^1 e^{-t^2}dt

\sin^2 x+\cos^2 x =1

January 11, 2008

wp-slimstat make WordPress database error

Filed under: wp — Tags: , , — Cun Zhang @ 14:44

wp-slimstat is a simple web stats analyser for wordpress.

in the version 0.9.2,it display wordpress database error:

WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 3]
SELECT `tp`.`post_title` FROM `wp_posts` AS `tp` WHERE (1 = 1) AND `tp`.`ID` =

I google this problem and find then answer at http://silverfox.name/archive/category/computer/network in Chinese.

I changed wp-slimstat.php as that article said,then it works fine.

at the line 1716 of wp-slimstat.php,the original code as follow:

" AND `tp`.`ID` = " . $myFieldsList [ $aFieldIndex ];

modification:

" AND `tp`.`ID` = " . $myFieldsList [ $aFieldIndex-1 ];

The reason leading this error is:

This plugin will read WordPress’s Option “permalink_structure”,for example,my is “/archive/%post_id%”,so the Regular Expressions  is

$myPermalinkRegEx = "/archive/([0-9]+)"

matching the content of $resource,creating $myFieldsList. For exampl,"/archive/147”,

$myFieldsList = array("0"="/archive/147", "1"="147")

corresponding is :

$myPermalinkArray = array("0"="", "1"="archive", "2"="%post_id%")

so it needs $aFieldIndex -1 to choose the value of  myFieldsList 147. 

Slimstat set local time

Filed under: wp — Tags: , , — Cun Zhang @ 8:45

I install Slimstat(simple web stats analyser ) plugin for my wp.But I find it display this server time,not my local time.
I google and find the answer from http://www.deepjiveinterests.com/2006/08/07/how-to-get-wp-slimstat-to-recognize-your-local-timezone/.
I put a line of code (as follow) into wp-slimstat.php,then it works fine. Thanks for Deep Jive’s share.
I use Beijing time,so I need change timezone to “Asia/Shanghai’.Then the code is:
date_default_timezone_set (”Asia/Shanghai”);

So why can he find the answer?
I think he must find than Slimstat is writed by php,so we can find the answer from php.THIS IS THE KEY.This also can be used to solve any problem!

Thank for Deep Jive. ^_^

here is the original post link:
http://www.deepjiveinterests.com/2006/07/30/about/

January 9, 2008

Secret messages hidden inside equations

Filed under: Math — Tags: , — Cun Zhang @ 21:19

This’s an interesting article from http://www.matrix67.com/blog/article.asp?id=456.

I use Maxima to re-plot that picture.

f(x,y):=exp(-x^2-y^2/2)*cos(4*x)+exp(-3*((x+0.5)^2+y^2/2));
plot3d(’(if(f(x,y)>0.001)then 0.001 else if(f(x,y)<0)then 0 else f(x,y)),[x,-3,3],[y,-5,5]);
my_preamble: "unset surface";
plot3d(’(if(f(x,y)>0.001)then 0.001 else if(f(x,y)<0)then 0 else f(x,y)),[x,-3,3],[y,-5,5],[gnuplot_preamble,my_preamble]);

link:Chinese Version http://www.matrix67.com/blog/article.asp?id=456

English Version http://www.walkingrandomly.com/?p=19

Older Posts »

Powered by WordPress