This post will be updated from time to time as soon as any neat trick come out. Generate a an iterated logistic map I didn't come out this method, it's in the official documentation of mathematica. ListPlot[Table[Thread[{r, Nest[r # (1 - #) &, Range[0, 1, 0.01], 1000]}], {r, 0, 4, 0.01}]] output Count the number of Wednesdays on Dec 25th in 400 yrs Tally[DayName /@ Tuples[{Range[0, 399], Range[12, 12], {25}}]] Output: {{Monday, 56}, {Tuesday, 58}, {Wednesday, 57}, {Thursday, 57}, {Saturday, 56}, {Sunday, 58}, {Friday, 58}} Find the kth Chebyshev Polynomial Nest[{2 x #[[2]] - #[[1]], 2 x (2 x #[[2]] - #[[1]]) - #[[2]]} &, {1, x}, 3][[2]]// Expand Output: -7 x + 56 x^3 - 112 x^5 + 64 x^7 (The 7th Chebyshev Polynomial)
Index Lab2 - Direct Methods for Solving Linear EquationsLab3 - Inverse Power Method to Solve EigenvalueLab4 - Jacobi Method to Solve EigenvalueLab 5 - Cubic Spline InterpolationLab 6 - FFT & IFFTLab 7 - Romberg Integral Lab2 - Direct Methods for Solving Linear Equations Description Use C/C++, implement the following algorithms: Gaussian EliminationDoolittle Decomposition Implement Predefinition and Useful functions #include <stdio.h> #include <stdlib.h> #include <string.h> #include <iostream> #include <fstream> #include <math.h> using namespace std; #define SUCCESS 0 #define FAILURE 1 #define INPUTPATH "./InputData.txt" typedef int Status; typedef double* Vector; typedef double** Matrix; Status PrintMatrix(int n, Matrix A){ /* * === FUNCTION ====================================================================== * Name: PrintMatrix * Description: Print the Matrix A to the terminal. n is the Dimension of A. * ===================================================================================== */ for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ printf("%.2lf\t", A[i][j]); } printf("\n"); } return SUCCESS; } Status PrintVector(int n, Vector v){ /* * === FUNCTION ====================================================================== * Name: PrintVector * Description: Print the Vector v to the terminal(in row form). n is the Dimension…
Description Design a crawler for problems of poj.org, crawl 100 problem details, and save as *.json file. Preparation The lab can be divided into these sections: Send a request and receive a responseParse the response and save the desired dataRepeatedly doing 1 and 2. Observation on url pattern The URLs of problems on poj all follow this format: http://poj.org/problem?id=<id> where <id> is an integer starting at 1000. So when we only need to send a request to this pattern, when <id> ranges from 1000 to 1099. Strategies against anti-crawler As a friendly crawler, we should not put much pressure on poj's server. This is something we should think about before we start coding. To avoid being banned, here are some simple strategies: Use fake UserAgents.Sleep for some seconds between 2 requests.If still get banned, we have to implement an ip-pool. Coding Parse response and save the data we want We can manually obtain the HTML code of websites using Firefox's view-source function. So we will start with the parsing. In this section, we will import…
This is just a simple record. About the configuring process on Windows, here is another blog. Version Info Vi IMproved 8.1 (2018 May 18) Huge version with GTK3 GUI. .vimrc[ref]无插件Vim配置文件vimrc推荐与各VIM配置项解释[/ref] " All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by " the call to :runtime you can find below. If you wish to change any of those " settings, you should do it in this file (/etc/vim/vimrc), since debian.vim " will be overwritten everytime an upgrade of the vim packages is performed. " It is recommended to make changes after sourcing debian.vim since it alters " the value of the 'compatible' option. runtime! debian.vim " Vim will load$VIMRUNTIME/defaults.vim if the user does not have a vimrc. " This happens after /etc/vim/vimrc(.local) are loaded, so it will override " any settings in these files. " If you don't want that to happen, uncomment the below line to prevent " defaults.vim from being loaded. let g:skip_defaults_vim = 1 " Uncomment the next line to make Vim more Vi-compatible " NOTE: debian.vim sets 'nocompatible'. Setting 'compatible'…
Introduction Beginning to learn Python, @Zei_Wai and I want to do some simple tasks, instead of diving into the sea of the documentation of Python. Then we chose this: generating a WordCloud picture of the lyrics of NeteaseMusic Songlist. Using urllib package First we found an api of Netease: https://music.163.com/api/song/lyric?id=<song.id>&lv=1&kv=1&tv=-1 where <song.id> is the id of songs in Netease database. When we use web client to play music, the URL of music playing page contains this id. For a simple example, if we want to get the lyrics of Bad Apple!! we just need to do like this: Then we just need to get the songs' id in a automatic way, then we can generate a text file. But when we use this method to send request to Netease Songlist page, what it returns doesn't contain songid. This is the code we use:[ref]【python爬虫自学笔记】-----爬取网易云歌单中歌曲歌词[/ref] import json import requests import re import urllib from bs4 import * def get_html(url): myheaders = { "User-Agent": "Mozilla/5.0 (X11; U; Linux i686) Gecko/20071127 Firefox/2.0.0.11 ", "Referer": "http://music.163.com/", "Host": "music.163.com" } try:…
Introduction I already have Windows 10 installed on my computer, and want to install Linux to dual boot. Preparation I don't have any experience on installing a new OS. So I have to investigate enough to minimize the probability that emergencies happen. Distro I choose Linux Mint 20.03(Edge). This stable edition is distributed on Jan. 17, 2022. Some videos that helps to choose a distro (provided by @Erik): Linux HATES Me – Daily Driver CHALLENGE Pt.1 - YouTube Linus BREAKS Linux! - Daily Driver Challenge Reaction - YouTube Creating a bootable USB Stick[ref]Create the bootable media[/ref] Download the iso image from mirrors. I chose the one the SJTUG site provided. Download the iso file. Remember to check the file integrity using SHA256.[ref]Verify your ISO image[/ref] As I am now operating on Windows, call cmd and type command:[ref]How to verify the ISO image on Windows[/ref] CertUtil -hashfile <filename.iso> SHA256 where the <filename.iso> is the file name of the iso file. screenshot of my SHA256 check Download Etcher, install and run it. 16GB UDisk, after flashing Fundamental…