Akar pangkat tiga dalam matematika python

Jika kita ingin mencari akar pangkat tiga dari bilangan bulat negatif. Kemudian kita harus melakukan beberapa perubahan pada trik di atas

a=-125 print(-(-a)**(1/3))-5.0

Berfungsi untuk mencari akar pangkat tiga menggunakan Python

Kita dapat mendefinisikan fungsi untuk akar pangkat tiga. Ketika pengguna memasukkan angka untuk akar pangkat tiga, maka secara otomatis akan mengembalikan akar pangkat tiga dari angka tersebut

def cube_root(x): return x**(1/3) print(cube_root(27))

Seperti yang bisa kita lihat, saya telah mendefinisikan fungsi akar pangkat tiga. Dan saya telah memanggil fungsi yang sama dengan input 27. Jadi itu akan mengembalikan akar pangkat tiga dari 27

Jika suatu bilangan dikalikan dengan dirinya sendiri dua kali (n*n*n), bilangan terakhirnya adalah pangkat tiga dari bilangan tersebut dan mencari akar pangkat tiga dari suatu bilangan adalah operasi kebalikan dari pangkat tiga bilangan tersebut. Jika x adalah akar pangkat tiga dari y, dapat dinyatakan seperti di bawah ini

Atau, itu juga dapat dinyatakan sebagai

x3 = y

Metode 1. Menggunakan operator eksponensial (**).

Eksponensial (**) operator Python dapat digunakan untuk menghitung akar pangkat tiga dari sebuah angka. Perhatikan contoh berikut

Cubic root of 3 is 1.44225 26Cubic root of 3 is 1.44225 27Cubic root of 3 is 1.44225 28Cubic root of 3 is 1.44225 29Cubic root of 3 is 1.44225 30

KeluaranCubic root of 3 is 1.44225 _

Kompleksitas Waktu. O(masuk)

Ruang Bantu. O(1) Silakan lihat artikel lengkap tentang Temukan akar pangkat tiga dari sebuah angka untuk detail lebih lanjut

Metode #2. Menggunakan fungsi power(**).

Python3




Cubic root of 3 is 1.44225 _31

Cubic root of 3 is 1.44225 _16

# of a number using Binary Search2# Python 3 program to find cubic root7 Cubic root of 3 is 1.44225 19

Cubic root of 3 is 1.44225 20# Returns the absolute value of1Cubic root of 3 is 1.44225 22Cubic root of 3 is 1.44225 23Cubic root of 3 is 1.44225 24Cubic root of 3 is 1.44225 25Cubic root of 3 is 1.44225 27Cubic root of 3 is 1.44225 77Cubic root of 3 is 1.44225 29________3______30

________21______2arr : [array_like] Input array or object whose elements, we need to square. 3 arr : [array_like] Input array or object whose elements, we need to square. 4arr : [array_like] Input array or object whose elements, we need to square. 5arr : [array_like] Input array or object whose elements, we need to square. 6________21______7________21______6arr : [array_like] Input array or object whose elements, we need to square. 9arr : [array_like] Input array or object whose elements, we need to square. 6An array with cube root of x for all x i.e. array elements 1________30_____0_________3

An array with cube root of x for all x i.e. array elements 4 An array with cube root of x for all x i.e. array elements 5An array with cube root of x for all x i.e. array elements 6An array with cube root of x for all x i.e. array elements 7

  

An array with cube root of x for all x i.e. array elements 9arr : [array_like] Input array or object whose elements, we need to square. 3 arr : [array_like] Input array or object whose elements, we need to square. 4cbrt Value of arr1 : [ 1. 30. 4. -10.] cbrt Value of arr2 : [ 10.0793684 -5.0396842] 2 ________21______6An array with cube root of x for all x i.e. array elements 1cbrt Value of arr1 : [ 1. 30. 4. -10.] cbrt Value of arr2 : [ 10.0793684 -5.0396842] 5An array with cube root of x for all x i.e. array elements 3

An array with cube root of x for all x i.e. array elements 4 An array with cube root of x for all x i.e. array elements 5cbrt Value of arr1 : [ 1. 30. 4. -10.] cbrt Value of arr2 : [ 10.0793684 -5.0396842] 9TypeError: ufunc 'cbrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''0

Keluaran

cbrt Value of arr1 : [ 1. 30. 4. -10.] cbrt Value of arr2 : [ 10.0793684 -5.0396842]

 
Kode #2. Bekerja dengan bilangan kompleks




# Python program explaining

# cbrt () function

  

import arr : [array_like] Input array or object whose elements, we need to square. 0

  

TypeError: ufunc 'cbrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''7arr : [array_like] Input array or object whose elements, we need to square. 3 TypeError: ufunc 'cbrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''9 Graphical Representation : [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285]0 Graphical Representation : [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285]1

An array with cube root of x for all x i.e. array elements 4An array with cube root of x for all x i.e. array elements 5Graphical Representation : [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285]4Graphical Representation : [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285]5

  

Graphical Representation : [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285]7arr : [array_like] Input array or object whose elements, we need to square. 3 Graphical Representation : [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285]9 Graphical Representation : [-1.70997595 2.30347441 3.08793243 3.60027433 3.99768384 4.3287262 4.61565763 4.87076238 5.10162421 5.31329285]0 # Python program explaining1

An array with cube root of x for all x i.e. array elements 4An array with cube root of x for all x i.e. array elements 5# Python program explaining4# Python program explaining5

Keluaran

TypeError: ufunc 'cbrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

 
Kode #3. Representasi grafis




# Python program explaining

# cbrt () function

  

import arr : [array_like] Input array or object whose elements, we need to square. 0

import # cbrt () function2

  

TypeError: ufunc 'cbrt' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''7arr : [array_like] Input array or object whose elements, we need to square. 3 # cbrt () function6arr : [array_like] Input array or object whose elements, we need to square. 3 An array with cube root of x for all x i.e. array elements 1________79______9  0arr : [array_like] Input array or object whose elements, we need to square. 3   2________21______6

Apa itu root () di Python?

sqrt() method mengembalikan akar kuadrat dari sebuah angka . Catatan. Angka harus lebih besar dari atau sama dengan 0.

Bagaimana Anda menulis angka potong dadu dengan Python?

2. Program python untuk mencari Kubus dari bilangan tertentu Menggunakan fungsi Cube() .
Ambil nomor input dari pengguna
Hitung pangkat tiga dari bilangan yang diberikan menggunakan fungsi
Cetak kubus dari nomor yang diberikan

Postingan terbaru

LIHAT SEMUA