อาร์คคอสเป็นฟังก์ชันที่มีหลายค่า:สำหรับแต่ละ x จะมีตัวเลข z จำนวนมากจนนับไม่ถ้วน ซึ่ง cos(z)=x แบบแผนคือการคืนค่ามุม z ที่มีส่วนจริงอยู่ใน [0, pi] cos ผกผันเรียกอีกอย่างว่า acos หรือ cos^-1
สำหรับประเภทข้อมูลอินพุตมูลค่าจริง arccos จะส่งคืนเอาต์พุตจริงเสมอ สำหรับแต่ละค่าที่ไม่สามารถแสดงเป็นจำนวนจริงหรืออนันต์ ได้ค่า nan และตั้งค่าสถานะข้อผิดพลาดทศนิยมที่ไม่ถูกต้อง สำหรับอินพุตที่มีค่าเชิงซ้อน arccos เป็นฟังก์ชันการวิเคราะห์ที่ซับซ้อนซึ่งมีการตัดกิ่ง [-inf, -1] และ [1, inf] และต่อเนื่องกันจากด้านบนบนอดีตและจากด้านล่างในส่วนหลัง
ในการค้นหาโคไซน์ผกผันตรีโกณมิติขององค์ประกอบอาร์เรย์ ให้ใช้เมธอด numpy.arccos() ในPython Numpy เมธอดจะคืนค่ามุมของอาร์เรย์ที่ตัดกับวงกลมหนึ่งหน่วยที่เรเดียน xcoordinatein ที่กำหนด [0, pi] นี่คือสเกลาร์ถ้า x เป็นสเกลาร์
พารามิเตอร์ที่ 1 x คือพิกัด x บนวงกลมหน่วย สำหรับอาร์กิวเมนต์จริง โดเมนคือ [-1, 1] พารามิเตอร์ที่ 2 และ 3 เป็นทางเลือก พารามิเตอร์ตัวที่ 2 คือ ndarray ซึ่งเป็นตำแหน่งที่เก็บผลลัพธ์ หากมีให้ จะต้องมีรูปร่างที่อินพุตถ่ายทอดไป หากไม่ระบุหรือไม่มี ระบบจะส่งคืนอาร์เรย์ที่จัดสรรใหม่
พารามิเตอร์ที่ 3 คือเงื่อนไขที่ออกอากาศผ่านอินพุต ที่ตำแหน่งที่เงื่อนไขเป็น True อาร์เรย์ out จะถูกตั้งค่าเป็นผลลัพธ์ ufunc ที่อื่น Out Array จะคงค่าเดิมไว้
ขั้นตอน
ขั้นแรก นำเข้าไลบรารีที่จำเป็น -
import numpy as np
รับโคไซน์ผกผันตรีโกณมิติขององค์ประกอบอาร์เรย์ Array สร้างขึ้นโดยใช้เมธอด numpy.array() -
arr = np.array((1, -1, 0, 0.3))
กำลังแสดงอาร์เรย์ของเรา -
print("Array...\n",arr) รับประเภทข้อมูล -
print("\nArray datatype...\n",arr.dtype)
รับขนาดของอาร์เรย์ -
print("\nArray Dimensions...\n",arr.ndim) รับจำนวนขององค์ประกอบของอาร์เรย์ -
print("\nNumber of elements in the Array...\n",arr.size) การหาโคไซน์ผกผันตรีโกณมิติขององค์ประกอบอาร์เรย์ -
print("\nResult...",np.arccos(arr)) ตัวอย่าง
import numpy as np
# To find the Trigonometric inverse cosine of the array elements, use the numpy.arccos() method in Python Numpy
# The method returns the angle of the array intersecting the unit circle at the given x-coordinate in radians [0, pi]. This is a scalar if x is a scalar.
# The 1st parameter, x is the x-coordinate on the unit circle. For real arguments, the domain is [-1, 1].
print("Get the Trigonometric inverse cosine of the array elements...\n")
# Array created using the numpy.array() method
arr = np.array((1, -1, 0, 0.3))
# Display the array
print("Array...\n", arr)
# Get the type of the array
print("\nOur Array type...\n", arr.dtype)
# Get the dimensions of the Array
print("\nOur Array Dimensions...\n",arr.ndim)
# Get the number of elements in the Array
print("\nNumber of elements...\n", arr.size)
# Finding the Trigonometric inverse cosine of the array elements
print("\nResult...",np.arccos(arr)) ผลลัพธ์
Get the Trigonometric inverse cosine of the array elements... Array... [ 1. -1. 0. 0.3] Our Array type... float64 Our Array Dimensions... 1 Number of elements... 4 Result... [0. 3.14159265 1.57079633 1.26610367]