-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsci_o.py
More file actions
executable file
·48 lines (33 loc) · 765 Bytes
/
sci_o.py
File metadata and controls
executable file
·48 lines (33 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# FileName: sci_o.py
#
# Description:
#
# Version: 1.0
# Created: 2018-07-04 16:48:28
# Last Modified: 2019-09-03 17:41:21
# Revision: none
# Compiler: gcc
#
# Author: zt ()
# Organization:
import scipy.optimize as opt
import scipy.integrate as inte
def f2(p):
x, y = p
return [(x - 5)**2 + (y - 5)**2 - 5**2, x**2 + (y - 10)**2 - 10**2]
r1 = opt.fsolve(f2, [0, 0])
r2 = opt.fsolve(f2, [10, 10])
x1 = r1[0]
x2 = r2[0]
print(x1)
print(x2)
def ff1(x):
return 2 * (5**2 - (x - 5)**2)**0.5
s1 = inte.quad(ff1, 0, x1)
print(s1)
def ff2(x):
return (5**2 - (x - 5)**2)**0.5 + 5 + (10**2 - x**2)**0.5 - 10
s2 = inte.quad(ff2, x1, x2)
print(s2)