[GO] Tohoku University 2020 First semester math exam (science) I tried to solve major questions 1 to 3 with Python

Nice to meet you, this is MatLaser! This is the first post of Qiita to commemorate, thank you! I usually use Python for research, but recently I've become interested in various technologies and am studying little by little. I've always wanted to do this post once, and GW has time, so I wrote it as a good opportunity. Due to lack of technology and knowledge, I think that there are inefficient coding and misunderstandings, but since it is written for beginners to output, I hope you can see it with warm eyes.

Please refer to the pdf of the questions and answers here. In this article as well, we will basically code according to how to solve the answer.

Problem Answer 1,4,5,6 Answer 2,3

First question

(1) You just use the cosine theorem.

(2) By properly setting the coordinates of the three points A, B, and C, the existence of the variable $ s $ can be set only to the $ y $ coordinates of the point P, which makes the calculation a little easier.

Below is the answer image. スクリーンショット (120).png

Let's code.

1.py



#Initial conditions
ab = 1
ac = 1
bc = 0.5

import numpy as np

# (1)
#Cosine theorem
cos_theta = (ab**2 + ac**2 - bc**2) / (2 * ab * ac)
sin_theta = np.sqrt(1 - cos_theta**2)
print(cos_theta, sin_theta) # 0.875 0.484 = 7/8 (√15)/8

# (2)
# func = AP^2 + BP^2 + CP^2
def func(s):
    return 25/32 + 15/64 * ((3 * (s - 2/3)**2) + 2/3)

lis = [] #A list that stores the value of the variable s and the func at that time as a tuple.

# 0<s<1 to 0.Change by 01 and search all
for s in np.arange(0,1,0.01):
    value = func(s)
    lis.append((s, value))

print(lis)
# min_Sort by value and output the first element
lis_sort = sorted(lis, key=lambda values: values[1])
print(lis_sort[0]) # (s, min_value) = (0.67, 0.9375)

Second question

(1) You can obediently find the intersection of straight lines L and M and substitute it for circle C.

(2) The subject is satisfied when the distance between the center of the circle C and the straight line L is smaller than the radius (a) of the circle C.

(3) Similar to (2), you can find the number of shared stores by comparing the distance between the point and the straight line and the radius of the circle C, and then just look up honestly. This only changes the inequality sign in (2), so I will omit it.

Below is the answer image. スクリーンショット (121).png

Let's code.

2.py



import sympy
x = sympy.Symbol('x')
y = sympy.Symbol('y')
a = sympy.Symbol('a')

# (1)
expr1 = -4 * x + 3 * y + a
expr2 = 3 * x + 4 * y - 7 * a
d = sympy.solve([expr1, expr2], [x,y])
# print(d) #The intersection of straight lines L and M(a, a)I understand

#In circle C (a,Substitute a)
sympy.var('x, y, a')
x = d[x] #Substitute the x coordinate of the intersection obtained above for x
y = d[y] #Substitute the y coordinate of the intersection obtained above for y
sol = sympy.solve (1 * x**2 - 2 * a * x + y**2 - 4 * y + 4, a)
sympy.init_printing()
print(sol) #Get a list of answers (only 1 this time)

# (2)
#The solution of the inequality sign can be set to the interval type with Interval and the union can be taken, but this time it ends with finding the boundary value from the equation.
dis = abs(6 - 3 * a)/5
# dis^2 = abs(a)Squared on both sides to solve
expr3 = 16 * a**2 + 36 * a - 36
d2 = sympy.solve([expr3])
print(d2) # [{a: -3}, {a: 3/4}]Boundary value where the number of shared stores changes

# (3)
#abridgement

Third question

(1) Looking at the problem statement, I think there are the following three solutions that come to mind. ・ Mathematical induction ・ Derivation of inequalities by formula transformation -Functionalization: As $ f (n) = 3 ^ n- (2 ^ n + n ^ 2 + 8) $, it is shown that $ n ≥ 3 $ and $ f (n)> 0 $. The answer uses mathematical induction, but from the perspective of solving it by programming, I think it is the easiest to make it a function.

(2) Since (1) shows that $ n ≧ 3 $ and $ f (n)> 0 $, at least $ n <3 $ is required for $ f (n) ≦ 0 $. Must be. Also, since $ n $ is a positive integer this time, we can see that $ n = 1,2 $ is a candidate solution. Once you know this, all you have to do is actually substitute and see if the subject holds.

(3) Since $ a, b, n $ are all 0 or more, the equation $ 2 ^ n + n ^ 2 + 8 = 3 ^ n + an + b $ holds for $ n = 1 $ or $ 2. $ Only.

Below is the answer image. image.png

Let's code.

3.py



# (1)
import math

# f(n)
def func(n):
    return 3**n - (2**n + n**2 + 8)

# f'(n)
def func_p1(n):
    return 3**n * math.log(3) - (2**n * math.log(2) + 2 * n)

# f''(n)
def func_p2(n):
    return 3**n * math.log(3)**2 - 2**n * math.log(2)**2

# print(func_p2(3)) # 28.74 ← 0 or more
#And n>3 at func_p2(n) >0 (∵ 3**n >> 2**n)

#Therefore n>3 at func_p1(n)Is monotonously increasing...(1)
#Also print(func_p1(3)) # 18.11 ← 0 or more...(2)

# (1),(2)More n>3 at func(n)Also monotonously increasing...(3)
#Further print(func(3)) #2 ← 0 or more...(4)

#Therefore,(3),(4)More n>=3 at func(n) > 0 
# Q.E.D

# (2)
print(func(1), func(2)) # -8 -7 Therefore f(n) <0, therefore n that satisfies the subject is 1,2

# (3)

lis = [] #Solution list
for a in range(9): # n,a,b >=From 0, a,b is 0~8 is enough
    for b in range(9):
        # n=When 1
        jouken1 = a + b # joken1 = 8

        # n=2 o'clock
        jouken2 = 2 * a + b # joken2 = 7

        if jouken1 == 8:
            lis.append((a,b,1))
        elif jouken2 == 7:
            lis.append((a,b,2))
        else:
            continue

print(lis)
#[(0, 7, 2), (0, 8, 1), (1, 5, 2), (1, 7, 1), (2, 3, 2), (2, 6, 1), (3, 1, 2), (3, 5, 1), (4, 4, 1), (5, 3, 1), (6, 2, 1), (7, 1, 1), (8, 0, 1)]

This time I would like to end here. I might do the rest of the problems if I'm too free to die ww I solved simultaneous equations using Python for the first time, which is wonderful. You can really do anything, Python is amazing! If you come up with something you want to try again or something that looks interesting, I will do it loosely.

Thank you for visiting.

Recommended Posts

Tohoku University 2020 First semester math exam (science) I tried to solve major questions 1 to 3 with Python
I tried to solve the first question of the University of Tokyo 2019 math entrance exam with python sympy
I tried to solve the soma cube with python
I tried to solve AOJ's number theory with Python
I tried to solve the ant book beginner's edition with python
I wanted to solve ABC160 with Python
I tried to solve TSP with QAOA
I wanted to solve ABC172 with Python
[Data science basics] I tried saving from csv to mysql with python
How to write offline real time I tried to solve E11 with python
How to write offline real time I tried to solve E12 with python
I wanted to solve NOMURA Contest 2020 with Python
I tried to get CloudWatch data with Python
I want to solve APG4b with Python (Chapter 2)
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part 5/22]
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part7 / 22]
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part 4/22]
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part3 / 22]
[Python] I tried to solve 100 past questions that beginners and intermediates should solve [Part 6/22]
I tried to implement Minesweeper on terminal with python
I tried to get started with blender python script_Part 01
I tried to touch the CSV file with Python
I tried to draw a route map with Python
I tried to get started with blender python script_Part 02
I tried to implement an artificial perceptron with python
I tried to automatically generate a password with Python3
I tried to analyze J League data with Python
The 15th offline real-time I tried to solve the problem of how to write with python
I tried to find the entropy of the image with python
I tried fp-growth with python
I tried scraping with Python
I tried to simulate how the infection spreads with Python
I wanted to solve the Panasonic Programming Contest 2020 with Python
I tried to make various "dummy data" with Python faker
I tried various methods to send Japanese mail with Python
Mayungo's Python Learning Episode 3: I tried to print numbers with print
I tried gRPC with Python
I tried to divide the file into folders with Python
[5th] I tried to make a certain authenticator-like tool with python
[2nd] I tried to make a certain authenticator-like tool with python
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
[3rd] I tried to make a certain authenticator-like tool with python
[Python] A memo that I tried to get started with asyncio
I tried to create a list of prime numbers with python
[Pandas] I tried to analyze sales data with Python [For beginners]
I tried to fix "I tried stochastic simulation of bingo game with Python"
I tried to make a periodical process with Selenium and Python
I tried to find out if ReDoS is possible with Python
I tried to make a 2channel post notification application with Python
I wanted to solve the ABC164 A ~ D problem with Python
Python3 Engineer Certification Basic Exam-I tried to solve the mock exam-
I tried to summarize everyone's remarks on slack with wordcloud (Python)
I tried to make a todo application using bottle with python
[4th] I tried to make a certain authenticator-like tool with python
I tried to easily detect facial landmarks with python and dlib
[1st] I tried to make a certain authenticator-like tool with python
I tried to automatically collect images of Kanna Hashimoto with Python! !!
I tried to make an image similarity function with Python + OpenCV
I tried to touch Python (installation)
I tried web scraping with python.
I tried running prolog with python 3.8.2.