Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Basisfuncties Implementeren in Python | Functies en Hun Eigenschappen
Wiskunde voor Data Science

bookBasisfuncties Implementeren in Python

Functies definiëren relaties tussen invoer en uitvoer, waardoor ze fundamenteel zijn in de wiskunde, programmeren en datawetenschap. In Python kunnen we verschillende typen functies definiëren en visualiseren, zoals één-op-één, veel-op-één, op, in, en bijectieve functies.

Typen functies in Python

Eén-op-één (Injectieve) Functie

Een één-op-één functie zorgt ervoor dat elke invoer naar een unieke uitvoer wordt afgebeeld. Zoals je zult zien, hebben geen twee invoerwaarden dezelfde uitvoer.

123456789
# One-to-One Function: f(x) = x def one_to_one(x): return x # Example Outputs print("One-to-One Function Outputs:") print(one_to_one(2)) # Output is 2 print(one_to_one(5)) # Output is 5
copy

Veel-op-één functie

Een veel-op-één functie staat toe dat meerdere invoerwaarden naar dezelfde uitvoerwaarde worden afgebeeld.

12345678
# Many-to-One Function: f(x) = x^2 def many_to_one(x): return x ** 2 # Example Outputs print("\nMany-to-One Function Outputs:") print(many_to_one(3)) # Output is 9 print(many_to_one(-3)) # Output is also 9 (Same output for different inputs)
copy

Op (Surjectieve) functie

Een op functie zorgt ervoor dat elke mogelijke uitvoer in het codomein door ten minste één invoer wordt afgebeeld.

1234567891011
import numpy as np # Onto Function: f(x) = tan(x) def onto(x): return np.tan(x) # Example Outputs print("\nOnto Function Outputs:") print(onto(1)) # Output is approximately 1.557 print(onto(-1)) # Output is approximately -2.185
copy

Into-functie

Een into-functie betekent dat niet alle waarden in het codomein worden bereikt—sommige uitkomsten blijven ongebruikt.

12345678910
import numpy as np # Into Function: f(x) = sin(x) (Only outputs between -1 and 1) def into(x): return np.sin(x) # Example Outputs print("\nInto Function Outputs:") print(into(0)) # Output is approximately 0 print(into(np.pi / 2)) # Output is approximately 1
copy

Bijectieve functie (Een-op-een & Surjectief)

Een bijectieve functie is zowel een-op-een als surjectief, wat betekent dat deze inverteerbaar is.

12345678
# Bijective Function: f(x) = x def bijective(x): return x # Example Outputs print("\nBijective Function Outputs:") print(bijective(3)) # Output is 3 print(bijective(-4)) # Output is -4
copy
question mark

Wat zal de volgende functie retourneren voor f(4)f(4)?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 3

Vraag AI

expand

Vraag AI

ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

Awesome!

Completion rate improved to 1.96

bookBasisfuncties Implementeren in Python

Veeg om het menu te tonen

Functies definiëren relaties tussen invoer en uitvoer, waardoor ze fundamenteel zijn in de wiskunde, programmeren en datawetenschap. In Python kunnen we verschillende typen functies definiëren en visualiseren, zoals één-op-één, veel-op-één, op, in, en bijectieve functies.

Typen functies in Python

Eén-op-één (Injectieve) Functie

Een één-op-één functie zorgt ervoor dat elke invoer naar een unieke uitvoer wordt afgebeeld. Zoals je zult zien, hebben geen twee invoerwaarden dezelfde uitvoer.

123456789
# One-to-One Function: f(x) = x def one_to_one(x): return x # Example Outputs print("One-to-One Function Outputs:") print(one_to_one(2)) # Output is 2 print(one_to_one(5)) # Output is 5
copy

Veel-op-één functie

Een veel-op-één functie staat toe dat meerdere invoerwaarden naar dezelfde uitvoerwaarde worden afgebeeld.

12345678
# Many-to-One Function: f(x) = x^2 def many_to_one(x): return x ** 2 # Example Outputs print("\nMany-to-One Function Outputs:") print(many_to_one(3)) # Output is 9 print(many_to_one(-3)) # Output is also 9 (Same output for different inputs)
copy

Op (Surjectieve) functie

Een op functie zorgt ervoor dat elke mogelijke uitvoer in het codomein door ten minste één invoer wordt afgebeeld.

1234567891011
import numpy as np # Onto Function: f(x) = tan(x) def onto(x): return np.tan(x) # Example Outputs print("\nOnto Function Outputs:") print(onto(1)) # Output is approximately 1.557 print(onto(-1)) # Output is approximately -2.185
copy

Into-functie

Een into-functie betekent dat niet alle waarden in het codomein worden bereikt—sommige uitkomsten blijven ongebruikt.

12345678910
import numpy as np # Into Function: f(x) = sin(x) (Only outputs between -1 and 1) def into(x): return np.sin(x) # Example Outputs print("\nInto Function Outputs:") print(into(0)) # Output is approximately 0 print(into(np.pi / 2)) # Output is approximately 1
copy

Bijectieve functie (Een-op-een & Surjectief)

Een bijectieve functie is zowel een-op-een als surjectief, wat betekent dat deze inverteerbaar is.

12345678
# Bijective Function: f(x) = x def bijective(x): return x # Example Outputs print("\nBijective Function Outputs:") print(bijective(3)) # Output is 3 print(bijective(-4)) # Output is -4
copy
question mark

Wat zal de volgende functie retourneren voor f(4)f(4)?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 1. Hoofdstuk 3
some-alt