Tag: Mathematica

2 Posts

Neat examples of mathematica
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)
Probability of Christmas on Wednesday
Original Problem Proof: In the system of the current Common Era, the probability of Christmas on Wed. is not 1/7. What exactly the probability is In 400 years there are 303 non-leap years and 97 leap years. Total number of days: $$T = 303\cdot 365 + 97\cdot 366\equiv 303 + 97\cdot 2\equiv 0\pmod 7.$$ This means: If the Christmas is on Mon. in year x, then it would be on Mon. in year (x + 400). That's to say, there's a difference between a day of the week and another day of the week. Solve in C /* * ===================================================================================== * * Filename: LeapYear_Xmas.cpp * * Description: A program to count which day of the week does the X-mas falls. * * Version: 1.0 * Created: 2021/10/9 20:31:35 * Revision: none * Compiler: gcc * * Author: CuSO4_Deposit, CuSO4D@protonmail.com * * ===================================================================================== */ #include <stdio.h> #include <iostream> #define TRUE 1 #define FALSE 0 #define Status int #define SUCCESS 1 #define FAILURE 0 #define FEB29 59 #define DEC25_nonleap 358 //Function Declaration bool ifLeap(int year); Status RunCalendar(int…