marksfuncs 0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1317 @@
1
+ # importar llibreríes
2
+ import numpy as np
3
+ import matplotlib.pyplot as plt
4
+ import scipy
5
+
6
+ class Linear:
7
+ # funcions
8
+ def __init__(self, m=None, b=None, x_values_list=None):
9
+ self.m = m
10
+ self.b = b
11
+ self.x_values_list= x_values_list
12
+ if any(param is None for param in [m, b, x_values_list]):
13
+ raise ValueError("All parameters must be provided.")
14
+ def graph(self):
15
+ # crear rang de valors per x
16
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1] , self.x_values_list[2])
17
+
18
+ # calcular els valors de y usant la funció lineal
19
+ # f(x) = mx + b
20
+ y_values = y_values = self.m * x_values + self.b
21
+
22
+ # graph la funció lineal
23
+ plt.figure("Linear Function")
24
+ plt.plot(x_values, y_values, label=f'f(x) = {self.m}x + {self.b}')
25
+ plt.xlabel('x')
26
+ plt.ylabel('f(x)')
27
+ plt.title('Linear Function')
28
+ plt.grid(True)
29
+ plt.legend()
30
+ plt.show()
31
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
32
+ return f"Graph displayed with attributes: {attribute_names}"
33
+
34
+
35
+ def __str__(self):
36
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
37
+ return f"Parameters of the Linear Function: {attribute_names}"
38
+
39
+ class Quadratic:
40
+ def __init__(self, a=None, b=None, c=None, x_values_list=None):
41
+ self.a = a
42
+ self.b = b
43
+ self.c = c
44
+ self.x_values_list = x_values_list
45
+ if any(param is None for param in [a, b, c, x_values_list]):
46
+ raise ValueError("All parameters must be provided.")
47
+
48
+ def graph(self):
49
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
50
+ # f(x) = ax ** 2 + bx + c
51
+ y_values = self.a * x_values ** 2 + self.b * x_values + self.c
52
+
53
+ plt.figure("Quadratic Function")
54
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a}x^2 + {self.b}x + {self.c}')
55
+ plt.xlabel('x')
56
+ plt.ylabel('f(x)')
57
+ plt.title('Quadratic Function')
58
+ plt.grid(True)
59
+ plt.legend()
60
+ plt.show()
61
+
62
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
63
+ return f"Graph displayed with attributes: {attribute_names}"
64
+
65
+ def __str__(self):
66
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
67
+ return f"Parameters of the Quadratic Function: {attribute_names}"
68
+ class Exponential:
69
+ def __init__(self, a=None, b=None, x_values_list=None):
70
+ self.a = a
71
+ self.b = b
72
+ self.x_values_list = x_values_list
73
+ if any(param is None for param in [a, b, x_values_list]):
74
+ raise ValueError("All parameters must be provided.")
75
+
76
+ def graph(self):
77
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
78
+ # f(x) = a * exp(bx)
79
+ y_values = self.a * np.exp(self.b * x_values)
80
+
81
+ plt.figure("Exponential Function")
82
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * exp({self.b}x)')
83
+ plt.xlabel('x')
84
+ plt.ylabel('f(x)')
85
+ plt.title('Exponential Function')
86
+ plt.grid(True)
87
+ plt.legend()
88
+ plt.show()
89
+
90
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
91
+ return f"Graph displayed with attributes: {attribute_names}"
92
+
93
+ def __str__(self):
94
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
95
+ return f"Parameters of the Exponential Function: {attribute_names}"
96
+ class Logarithmic:
97
+ def __init__(self, a=None, b=None, x_values_list=None):
98
+ self.a = a
99
+ self.b = b
100
+ self.x_values_list = x_values_list
101
+ if any(param is None for param in [a, b, x_values_list]):
102
+ raise ValueError("All parameters must be provided.")
103
+
104
+ def graph(self):
105
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
106
+ # f(x) = a * log(bx)
107
+ y_values = np.empty_like(x_values)
108
+ for i, x in enumerate(x_values):
109
+ if x <= 0:
110
+ y_values[i] = np.nan
111
+ else:
112
+ y_values[i] = self.a * np.log(self.b * x)
113
+
114
+ plt.figure("Logarithmic Function")
115
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * log({self.b}x)')
116
+ plt.xlabel('x')
117
+ plt.ylabel('f(x)')
118
+ plt.title('Logarithmic Function')
119
+ plt.grid(True)
120
+ plt.legend()
121
+ plt.show()
122
+
123
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
124
+ return f"Graph displayed with attributes: {attribute_names}"
125
+
126
+ def __str__(self):
127
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
128
+ return f"Parameters of la funció logarítmica: {attribute_names}"
129
+ class Trigonometric:
130
+ def __init__(self, a=None, b=None, x_values_list=None):
131
+ self.a = a
132
+ self.b = b
133
+ self.x_values_list = x_values_list
134
+ if any(param is None for param in [a, b, x_values_list]):
135
+ raise ValueError("All parameters must be provided.")
136
+
137
+ def graph(self):
138
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
139
+ # f(x) = a * sin(bx)
140
+ y_values = self.a * np.sin(self.b * x_values)
141
+
142
+ plt.figure("Trigonometric Function (Senosoidal)")
143
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * sin({self.b}x)')
144
+ plt.xlabel('x')
145
+ plt.ylabel('f(x)')
146
+ plt.title('Trigonometric Function (Senosoidal)')
147
+ plt.grid(True)
148
+ plt.legend()
149
+ plt.show()
150
+
151
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
152
+ return f"Graph displayed with attributes: {attribute_names}"
153
+
154
+ def __str__(self):
155
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
156
+ return f"Parameters of the Trigonometric Function (Senosoidal): {attribute_names}"
157
+ class Polynomial:
158
+ def __init__(self, coeficients=None, x_values_list=None):
159
+ self.coeficients = coeficients
160
+ self.x_values_list = x_values_list
161
+ if any(param is None for param in [coeficients, x_values_list]):
162
+ raise ValueError("All parameters must be provided.")
163
+
164
+ def graph(self):
165
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
166
+ y_values = np.polyval(self.coeficients, x_values)
167
+
168
+ plt.figure("Polynomial Function")
169
+ plt.plot(x_values, y_values, label=f'f(x) = {np.poly1d(self.coeficients)}')
170
+ plt.xlabel('x')
171
+ plt.ylabel('f(x)')
172
+ plt.title('Polynomial Function')
173
+ plt.grid(True)
174
+ plt.legend()
175
+ plt.show()
176
+
177
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
178
+ return f"Graph displayed with attributes: {attribute_names}"
179
+
180
+ def __str__(self):
181
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
182
+ return f"Parameters of the Polynomial Function: {attribute_names}"
183
+ class Hyperbolic:
184
+ def __init__(self, a=None, b=None, x_values_list=None):
185
+ self.a = a
186
+ self.b = b
187
+ self.x_values_list = x_values_list
188
+ if any(param is None for param in [a, b, x_values_list]):
189
+ raise ValueError("All parameters must be provided.")
190
+
191
+ def graph(self):
192
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
193
+ # f(x) = a * sinh(bx)
194
+ y_values = self.a * np.sinh(self.b * x_values)
195
+
196
+ plt.figure("Hyperbolic Function")
197
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * sinh({self.b}x)')
198
+ plt.xlabel('x')
199
+ plt.ylabel('f(x)')
200
+ plt.title('Hyperbolic Function')
201
+ plt.grid(True)
202
+ plt.legend()
203
+ plt.show()
204
+
205
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
206
+ return f"Graph displayed with attributes: {attribute_names}"
207
+
208
+ def __str__(self):
209
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
210
+ return f"Parameters of the Hyperbolic Function: {attribute_names}"
211
+ class InverseTrigonometric:
212
+ def __init__(self, a=None, b=None, x_values_list=None):
213
+ self.a = a
214
+ self.b = b
215
+ self.x_values_list = x_values_list
216
+ if any(param is None for param in [a, b, x_values_list]):
217
+ raise ValueError("All parameters must be provided.")
218
+
219
+ def graph(self):
220
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
221
+ # f(x) = a * arcsin(bx)
222
+ y_values = self.a * np.arcsin(self.b * x_values)
223
+
224
+ plt.figure("Inverse Trigonometric Function (Arcosine)")
225
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * arcsin({self.b}x)')
226
+ plt.xlabel('x')
227
+ plt.ylabel('f(x)')
228
+ plt.title('Inverse Trigonometric Function (Arcosine)')
229
+ plt.grid(True)
230
+ plt.legend()
231
+ plt.show()
232
+
233
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
234
+ return f"Graph displayed with attributes: {attribute_names}"
235
+
236
+ def __str__(self):
237
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
238
+ return f"Parameters of the Inverse Trigonometric Function (Arcosine): {attribute_names}"
239
+ class Rational:
240
+ def __init__(self, a=None, b=None, x_values_list=None):
241
+ self.a = a
242
+ self.b = b
243
+ self.x_values_list = x_values_list
244
+ if any(param is None for param in [a, b, x_values_list]):
245
+ raise ValueError("All parameters must be provided.")
246
+
247
+ def graph(self):
248
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
249
+ # f(x) = a / (bx)
250
+ y_values = self.a / (self.b * x_values)
251
+
252
+ plt.figure("Rational Function")
253
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} / ({self.b}x)')
254
+ plt.xlabel('x')
255
+ plt.ylabel('f(x)')
256
+ plt.title('Rational Function')
257
+ plt.grid(True)
258
+ plt.legend()
259
+ plt.show()
260
+
261
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
262
+ return f"Graph displayed with attributes: {attribute_names}"
263
+
264
+ def __str__(self):
265
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
266
+ return f"Parameters of the Rational Function: {attribute_names}"
267
+ class Radical:
268
+ def __init__(self, a=None, b=None, x_values_list=None):
269
+ self.a = a
270
+ self.b = b
271
+ self.x_values_list = x_values_list
272
+ if any(param is None for param in [a, b, x_values_list]):
273
+ raise ValueError("All parameters must be provided.")
274
+
275
+ def graph(self):
276
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
277
+ # f(x) = a * √bx
278
+ y_values = self.a * np.sqrt(np.maximum(self.b * x_values, 0))
279
+
280
+ plt.figure("Radical Function")
281
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * sqrt({self.b}x)')
282
+ plt.xlabel('x')
283
+ plt.ylabel('f(x)')
284
+ plt.title('Radical Function')
285
+ plt.grid(True)
286
+ plt.legend()
287
+ plt.show()
288
+
289
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
290
+ return f"Graph displayed with attributes: {attribute_names}"
291
+
292
+ def __str__(self):
293
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
294
+ return f"Parameters of the Radical Function: {attribute_names}"
295
+ class Power:
296
+ def __init__(self, a=None, b=None, x_values_list=None):
297
+ self.a = a
298
+ self.b = b
299
+ self.x_values_list = x_values_list
300
+ if any(param is None for param in [a, b, x_values_list]):
301
+ raise ValueError("All parameters must be provided.")
302
+
303
+ def graph(self):
304
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
305
+ # f(x) = a * x**b
306
+ y_values = self.a * (x_values ** self.b)
307
+
308
+ plt.figure("Power Function")
309
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * x^{self.b}')
310
+ plt.xlabel('x')
311
+ plt.ylabel('f(x)')
312
+ plt.title('Power Function')
313
+ plt.grid(True)
314
+ plt.legend()
315
+ plt.show()
316
+
317
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
318
+ return f"Graph displayed with attributes: {attribute_names}"
319
+
320
+ def __str__(self):
321
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
322
+ return f"Parameters of the Power Function: {attribute_names}"
323
+ class Absolute:
324
+ def __init__(self, a=None, b=None, x_values_list=None):
325
+ self.a = a
326
+ self.b = b
327
+ self.x_values_list = x_values_list
328
+ if any(param is None for param in [a, b, x_values_list]):
329
+ raise ValueError("All parameters must be provided.")
330
+
331
+ def graph(self):
332
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
333
+ # f(x) = a * |bx|
334
+ y_values = self.a * np.abs(self.b * x_values)
335
+
336
+ plt.figure("Absolute Function")
337
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * |{self.b}x|')
338
+ plt.xlabel('x')
339
+ plt.ylabel('f(x)')
340
+ plt.title('Absolute Function')
341
+ plt.grid(True)
342
+ plt.legend()
343
+ plt.show()
344
+
345
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
346
+ return f"Graph displayed with attributes: {attribute_names}"
347
+
348
+ def __str__(self):
349
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
350
+ return f"Parameters of the Absolute Function: {attribute_names}"
351
+ class UnitStep:
352
+ def __init__(self, a=None, b=None, x_values_list=None):
353
+ self.a = a
354
+ self.b = b
355
+ self.x_values_list = x_values_list
356
+ if any(param is None for param in [a, b, x_values_list]):
357
+ raise ValueError("All parameters must be provided.")
358
+
359
+ def graph(self):
360
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
361
+ # f(X) = a * u(bx)
362
+ y_values = self.a * np.heaviside(self.b * x_values, 0.5)
363
+
364
+ plt.figure("Unit Step Function")
365
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * u({self.b}x)')
366
+ plt.xlabel('x')
367
+ plt.ylabel('f(x)')
368
+ plt.title('Unit Step Function')
369
+ plt.grid(True)
370
+ plt.legend()
371
+ plt.show()
372
+
373
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
374
+ return f"Graph displayed with attributes: {attribute_names}"
375
+
376
+ def __str__(self):
377
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
378
+ return f"Parameters of the Unit Step Function: {attribute_names}"
379
+ class Sigmoid:
380
+ def __init__(self, a=None, b=None, c=None, x_values_list=None):
381
+ self.a = a
382
+ self.b = b
383
+ self.c = c
384
+ self.x_values_list = x_values_list
385
+ if any(param is None for param in [a, b, c, x_values_list]):
386
+ raise ValueError("All parameters must be provided.")
387
+
388
+ def graph(self):
389
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
390
+ # f(x) = a / (1 + exp(-b * (x - c)))
391
+ y_values = self.a / (1 + np.exp(-self.b * (x_values - self.c)))
392
+
393
+ plt.figure("Sigmoid Function")
394
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} / (1 + exp(-{self.b}(x - {self.c})))')
395
+ plt.xlabel('x')
396
+ plt.ylabel('f(x)')
397
+ plt.title('Sigmoid Function')
398
+ plt.grid(True)
399
+ plt.legend()
400
+ plt.show()
401
+
402
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
403
+ return f"Graph displayed with attributes: {attribute_names}"
404
+
405
+ def __str__(self):
406
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
407
+ return f"Parameters of the Sigmoid Function: {attribute_names}"
408
+ class Heaviside:
409
+ def __init__(self, x_values_list=None):
410
+ self.x_values_list = x_values_list
411
+ if x_values_list is None:
412
+ raise ValueError("The range of values ​​of x must be provided.")
413
+
414
+ def graph(self):
415
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
416
+ # f(x) = u(x)
417
+ y_values = np.heaviside(x_values, 0.5)
418
+
419
+ plt.figure("Heaviside Function")
420
+ plt.plot(x_values, y_values, label='f(x) = u(x)')
421
+ plt.xlabel('x')
422
+ plt.ylabel('f(x)')
423
+ plt.title("Heaviside Function")
424
+ plt.grid(True)
425
+ plt.legend()
426
+ plt.show()
427
+
428
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
429
+ return f"Graph displayed with attributes: {attribute_names}"
430
+
431
+ def __str__(self):
432
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
433
+ return f"Parameters of the Heaviside Function: {attribute_names}"
434
+ class Dirichlet:
435
+ def __init__(self, a=None, b=None, x_values_list=None):
436
+ self.a = a
437
+ self.b = b
438
+ self.x_values_list = x_values_list
439
+ if any(param is None for param in [a, b, x_values_list]):
440
+ raise ValueError("All parameters must be provided.")
441
+
442
+ def graph(self):
443
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
444
+ # f(x) = sinc(ax - b)
445
+ y_values = np.sinc(self.a * x_values - self.b)
446
+
447
+ plt.figure("Dirichlet Function")
448
+ plt.plot(x_values, y_values, label=f'f(x) = sinc({self.a}x - {self.b})')
449
+ plt.xlabel('x')
450
+ plt.ylabel('f(x)')
451
+ plt.title('Dirichlet Function')
452
+ plt.grid(True)
453
+ plt.legend()
454
+ plt.show()
455
+
456
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
457
+ return f"Graph displayed with attributes: {attribute_names}"
458
+
459
+ def __str__(self):
460
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
461
+ return f"Parameters of the Dirichlet Function: {attribute_names}"
462
+ class Gauss:
463
+ def __init__(self, a=None, b=None, c=None, x_values_list=None):
464
+ self.a = a
465
+ self.b = b
466
+ self.c = c
467
+ self.x_values_list = x_values_list
468
+ if any(param is None for param in [a, b, c, x_values_list]):
469
+ raise ValueError("All parameters must be provided.")
470
+
471
+ def graph(self):
472
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
473
+ # f(x) = a * exp(-((x - b ** 2) / (2 * c ** 2)))
474
+ y_values = self.a * np.exp(-((x_values - self.b) ** 2) / (2 * self.c ** 2))
475
+
476
+ plt.figure("Gauss Function")
477
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * exp(-((x - {self.b})^2) / (2 * {self.c}^2))')
478
+ plt.xlabel('x')
479
+ plt.ylabel('f(x)')
480
+ plt.title('Gauss Function')
481
+ plt.grid(True)
482
+ plt.legend()
483
+ plt.show()
484
+
485
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
486
+ return f"Graph displayed with attributes: {attribute_names}"
487
+
488
+ def __str__(self):
489
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
490
+ return f"Parameters of the Gauss Function: {attribute_names}"
491
+ class Planck:
492
+ def __init__(self, h=None, k=None, c=None, T=None, x_values_list=None):
493
+ self.h = h
494
+ self.k = k
495
+ self.c = c
496
+ self.T = T
497
+ self.x_values_list = x_values_list
498
+ if any(param is None for param in [h, k, c, T, x_values_list]):
499
+ raise ValueError("All parameters must be provided.")
500
+
501
+ def graph(self):
502
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
503
+ # f(x) = 1 / (exp((hc) / (ktx) - 1)
504
+ expo = self.h * self.c / (self.k * self.T * x_values)
505
+ y_values = 1 / (np.exp(expo) - 1)
506
+
507
+ plt.figure("Planck Function")
508
+ plt.plot(x_values, y_values, label=f'f(x) = 1 / (exp(({self.h} * {self.c}) / ({self.k} * {self.T}x) - 1)')
509
+ plt.xlabel('x')
510
+ plt.ylabel('f(x)')
511
+ plt.title('Planck Function')
512
+ plt.grid(True)
513
+ plt.legend()
514
+ plt.show()
515
+
516
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
517
+ return f"Graph displayed with attributes: {attribute_names}"
518
+
519
+ def __str__(self):
520
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
521
+ return f"Parameters of the Planck Function: {attribute_names}"
522
+ class Triangular:
523
+ def __init__(self, a=None, b=None, c=None, x_values_list=None):
524
+ self.a = a
525
+ self.b = b
526
+ self.c = c
527
+ self.x_values_list = x_values_list
528
+ if any(param is None for param in [a, b, c, x_values_list]):
529
+ raise ValueError("All parameters must be provided.")
530
+
531
+ def graph(self):
532
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
533
+ # f(x) = max(0, a - |x - b| / c)
534
+ y_values = np.maximum(0, self.a - np.abs(x_values - self.b) / self.c)
535
+
536
+ plt.figure("Triangular Function")
537
+ plt.plot(x_values, y_values, label=f'f(x) = max(0, {self.a} - |x - {self.b}| / {self.c})')
538
+ plt.xlabel('x')
539
+ plt.ylabel('f(x)')
540
+ plt.title('Triangular Function')
541
+ plt.grid(True)
542
+ plt.legend()
543
+ plt.show()
544
+
545
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
546
+ return f"Graph displayed with attributes: {attribute_names}"
547
+
548
+ def __str__(self):
549
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
550
+ return f"Parameters of the Triangular Function: {attribute_names}"
551
+ class Sign:
552
+ def __init__(self, x_values_list=None):
553
+ self.x_values_list = x_values_list
554
+ if x_values_list is None:
555
+ raise ValueError("The range of values ​​of x must be provided.")
556
+
557
+ def graph(self):
558
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
559
+ # f(x) = sign(x)
560
+ y_values = np.sign(x_values)
561
+
562
+ plt.figure("Sign Function")
563
+ plt.plot(x_values, y_values, label='f(x) = sign(x)')
564
+ plt.xlabel('x')
565
+ plt.ylabel('f(x)')
566
+ plt.title('Sign Function')
567
+ plt.grid(True)
568
+ plt.legend()
569
+ plt.show()
570
+
571
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
572
+ return f"Graph displayed with attributes: {attribute_names}"
573
+
574
+ def __str__(self):
575
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
576
+ return f"Parameters of the Sign Function: {attribute_names}"
577
+ class SawTooth:
578
+ def __init__(self, a=None, b=None, x_values_list=None):
579
+ self.a = a
580
+ self.b = b
581
+ self.x_values_list = x_values_list
582
+ if any(param is None for param in [a, b, x_values_list]):
583
+ raise ValueError("All parameters must be provided.")
584
+
585
+ def graph(self):
586
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
587
+ # f(x) = a(x - 2π*floor(x/2π))
588
+ period = 2 * np.pi / self.b
589
+ y_values = self.a * (x_values - period * np.floor(x_values / period))
590
+
591
+ plt.figure("Sawtooth Function")
592
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a}(x - 2π*floor(x/2π))')
593
+ plt.xlabel('x')
594
+ plt.ylabel('f(x)')
595
+ plt.title('Sawtooth Function')
596
+ plt.grid(True)
597
+ plt.legend()
598
+ plt.show()
599
+
600
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
601
+ return f"Graph displayed with attributes: {attribute_names}"
602
+
603
+ def __str__(self):
604
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
605
+ return f"Parameters of the Sawtooth Function: {attribute_names}"
606
+ class SquareWave:
607
+ def __init__(self, a=None, b=None, x_values_list=None):
608
+ self.a = a
609
+ self.b = b
610
+ self.x_values_list = x_values_list
611
+ if any(param is None for param in [a, b, x_values_list]):
612
+ raise ValueError("All parameters must be provided.")
613
+
614
+ def graph(self):
615
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
616
+ # f(x) = a(1 -2(floor(x/2π) % 2))
617
+ period = 2 * np.pi / self.b
618
+ y_values = self.a * (1 - 2 * (np.floor(x_values / period) % 2))
619
+
620
+ plt.figure("Square Wave Function")
621
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a}(1 - 2(floor(x/2pi) % 2))')
622
+ plt.xlabel('x')
623
+ plt.ylabel('f(x)')
624
+ plt.title('Square Wave Function')
625
+ plt.grid(True)
626
+ plt.legend()
627
+ plt.show()
628
+
629
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
630
+ return f"Graph displayed with attributes: {attribute_names}"
631
+
632
+ def __str__(self):
633
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
634
+ return f"Parameters of the Square Wave Function: {attribute_names}"
635
+ class SincDirichlet:
636
+ def __init__(self, a=None, x_values_list=None):
637
+ self.a = a
638
+ self.x_values_list = x_values_list
639
+ if any(param is None for param in [a, x_values_list]):
640
+ raise ValueError("All parameters must be provided.")
641
+
642
+ def graph(self):
643
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
644
+ # f(x) = sinc(ax)
645
+ y_values = np.sinc(self.a * x_values)
646
+
647
+ plt.figure("Sinc Dirichlet Function")
648
+ plt.plot(x_values, y_values, label=f'f(x) = sinc({self.a}x)')
649
+ plt.xlabel('x')
650
+ plt.ylabel('f(x)')
651
+ plt.title('Sinc Dirichlet Function')
652
+ plt.grid(True)
653
+ plt.legend()
654
+ plt.show()
655
+
656
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
657
+ return f"Graph displayed with attributes: {attribute_names}"
658
+
659
+ def __str__(self):
660
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
661
+ return f"Parameters of the Sinc Dirichlet Function: {attribute_names}"
662
+ class HyperbolicTangent:
663
+ def __init__(self, a=None, x_values_list=None):
664
+ self.a = a
665
+ self.x_values_list = x_values_list
666
+ if any(param is None for param in [a, x_values_list]):
667
+ raise ValueError("All parameters must be provided.")
668
+
669
+ def graph(self):
670
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
671
+ # f(x) = a * tanh(x)
672
+ y_values = self.a * np.tanh(x_values)
673
+
674
+ plt.figure("Hyperbolic Tangent Function")
675
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * tanh(x)')
676
+ plt.xlabel('x')
677
+ plt.ylabel('f(x)')
678
+ plt.title('Hyperbolic Tangent Function')
679
+ plt.grid(True)
680
+ plt.legend()
681
+ plt.show()
682
+
683
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
684
+ return f"Graph displayed with attributes: {attribute_names}"
685
+
686
+ def __str__(self):
687
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
688
+ return f"Parameters of the Sinc Dirichlet Function: {attribute_names}"
689
+ class BesselOrdre0:
690
+ def __init__(self, x_values_list=None):
691
+ self.x_values_list = x_values_list
692
+ if x_values_list is None:
693
+ raise ValueError("The range of values ​​of x must be provided.")
694
+
695
+ def graph(self):
696
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
697
+ # f(x) = J0(x)
698
+ y_values = scipy.special.jn(0, x_values)
699
+
700
+ plt.figure("Bessel Function of Order 0")
701
+ plt.plot(x_values, y_values, label='f(x) = J0(x)')
702
+ plt.xlabel('x')
703
+ plt.ylabel('f(x)')
704
+ plt.title("Bessel Function of Order 0")
705
+ plt.grid(True)
706
+ plt.legend()
707
+ plt.show()
708
+
709
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
710
+ return f"Graph displayed with attributes: {attribute_names}"
711
+
712
+ def __str__(self):
713
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
714
+ return f"Parameters of the Bessel Function of Order 0: {attribute_names}"
715
+ class Error:
716
+ def __init__(self, x_values_list=None):
717
+ self.x_values_list = x_values_list
718
+ if x_values_list is None:
719
+ raise ValueError("The range of values ​​of x must be provided.")
720
+
721
+ def graph(self):
722
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
723
+ # f(x) = erf(x)
724
+ y_values = scipy.special.erf(x_values)
725
+
726
+ plt.figure("Error Function")
727
+ plt.plot(x_values, y_values, label='f(x) = erf(x)')
728
+ plt.xlabel('x')
729
+ plt.ylabel('f(x)')
730
+ plt.title('Error Function')
731
+ plt.grid(True)
732
+ plt.legend()
733
+ plt.show()
734
+
735
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
736
+ return f"Graph displayed with attributes: {attribute_names}"
737
+
738
+ def __str__(self):
739
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
740
+ return f"Parameters of the Error Function: {attribute_names}"
741
+ class SineFresnel:
742
+ def __init__(self, x_values_list=None):
743
+ self.x_values_list = x_values_list
744
+ if x_values_list is None:
745
+ raise ValueError("The range of values ​​of x must be provided.")
746
+
747
+ def graph(self):
748
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
749
+ # f(x) = S(x)
750
+ y_values = scipy.special.fresnel(x_values)[0]
751
+
752
+ plt.figure("Fresnel Sine Function")
753
+ plt.plot(x_values, y_values, label='f(x) = S(x)')
754
+ plt.xlabel('x')
755
+ plt.ylabel('f(x)')
756
+ plt.title('Fresnel Sine Function')
757
+ plt.grid(True)
758
+ plt.legend()
759
+ plt.show()
760
+
761
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
762
+ return f"Graph displayed with attributes: {attribute_names}"
763
+
764
+ def __str__(self):
765
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
766
+ return f"Parameters of the Fresnel Sine Function: {attribute_names}"
767
+ class CosineFresnel:
768
+ def __init__(self, x_values_list=None):
769
+ self.x_values_list = x_values_list
770
+ if x_values_list is None:
771
+ raise ValueError("The range of values ​​of x must be provided.")
772
+
773
+ def graph(self):
774
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
775
+ # f(x) = C(x)
776
+ y_values = scipy.special.fresnel(x_values)[1]
777
+
778
+ plt.figure("Fresnel Cosine Function")
779
+ plt.plot(x_values, y_values, label='f(x) = C(x)')
780
+ plt.xlabel('x')
781
+ plt.ylabel('f(x)')
782
+ plt.title('Fresnel Cosine Function')
783
+ plt.grid(True)
784
+ plt.legend()
785
+ plt.show()
786
+
787
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
788
+ return f"Graph displayed with attributes: {attribute_names}"
789
+
790
+ def __str__(self):
791
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
792
+ return f"Parameters of the Fresnel Cosine Function: {attribute_names}"
793
+ class Airy:
794
+ def __init__(self, x_values_list=None):
795
+ self.x_values_list = x_values_list
796
+ if x_values_list is None:
797
+ raise ValueError("The range of values ​​of x must be provided.")
798
+
799
+ def graph(self):
800
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
801
+ # f(x) = Ai(x)
802
+ y_values = scipy.special.airy(x_values)[0]
803
+
804
+ plt.figure("Airy Function")
805
+ plt.plot(x_values, y_values, label='f(x) = Ai(x)')
806
+ plt.xlabel('x')
807
+ plt.ylabel('f(x)')
808
+ plt.title('Airy Function')
809
+ plt.grid(True)
810
+ plt.legend()
811
+ plt.show()
812
+
813
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
814
+ return f"Graph displayed with attributes: {attribute_names}"
815
+
816
+ def __str__(self):
817
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
818
+ return f"Parameters of the Airy Function: {attribute_names}"
819
+ class Logistic:
820
+ def __init__(self, a=None, b=None, c=None, x_values_list=None):
821
+ self.a = a
822
+ self.b = b
823
+ self.c = c
824
+ self.x_values_list = x_values_list
825
+ if any(param is None for param in [a, b, c, x_values_list]):
826
+ raise ValueError("All parameters must be provided.")
827
+
828
+ def graph(self):
829
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
830
+ # f(x) = c / (1 + exp(-b(x - a)))
831
+ expo = -self.b * (x_values - self.a)
832
+ y_values = self.c / (1 + np.exp(expo))
833
+
834
+ plt.figure("Logistic Function")
835
+ plt.plot(x_values, y_values, label=f'f(x) = {self.c} / (1 + exp(-{self.b}(x - {self.a})))')
836
+ plt.xlabel('x')
837
+ plt.ylabel('f(x)')
838
+ plt.title('Logistic Function')
839
+ plt.grid(True)
840
+ plt.legend()
841
+ plt.show()
842
+
843
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
844
+ return f"Graph displayed with attributes: {attribute_names}"
845
+
846
+ def __str__(self):
847
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
848
+ return f"Parameters of the Logistic Function: {attribute_names}"
849
+ class Ackermann:
850
+ def __init__(self, m=None, n=None, x_values_list=None):
851
+ self.m = m
852
+ self.n = n
853
+ self.x_values_list = x_values_list
854
+ if any(param is None for param in [m, n, x_values_list]):
855
+ raise ValueError("All parameters must be provided.")
856
+
857
+ def graph(self):
858
+ def ack(m, n):
859
+ if m == 0:
860
+ return n + 1
861
+ elif n == 0:
862
+ return ack(m - 1, 1)
863
+ else:
864
+ return ack(m - 1, ack(m, n - 1))
865
+
866
+ # Calcular algunos puntos de la función de Ackermann para valores pequeños de m y n
867
+ m_values = np.arange(0, self.m + 1)
868
+ n_values = np.arange(0, self.n + 1)
869
+ ackermann_values = np.array([[ack(m, n) for n in n_values] for m in m_values])
870
+
871
+ # Crear una malla para el gráfico
872
+ M, N = np.meshgrid(m_values, n_values)
873
+
874
+ # Mostrar los puntos en un gráfico de dispersión
875
+ plt.figure("Ackermann Function")
876
+ plt.scatter(M, N, c=ackermann_values, cmap='viridis', marker='s', s=200)
877
+ plt.colorbar(label="Ackermann Value")
878
+ plt.xlabel('m')
879
+ plt.ylabel('n')
880
+ plt.title("Ackermann Function")
881
+ plt.grid(True)
882
+ plt.show()
883
+
884
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
885
+ return f"Graph displayed with attributes: {attribute_names}"
886
+
887
+ def __str__(self):
888
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
889
+ return f"Parameters of the Ackermann Function: {attribute_names}"
890
+ class Fibonacci:
891
+ def __init__(self, n=None, x_values_list=None):
892
+ self.n = n
893
+ self.x_values_list = x_values_list
894
+ if any(param is None for param in [n, x_values_list]):
895
+ raise ValueError("All parameters must be provided.")
896
+
897
+ def graph(self):
898
+ def fib(n):
899
+ if n <= 1:
900
+ return n
901
+ else:
902
+ return fib(n - 1) + fib(n - 2)
903
+
904
+ # Calcular algunos puntos de la función de Fibonacci para valores pequeños de n
905
+ n_values = np.arange(0, self.n + 1)
906
+ fibonacci_values = np.array([fib(n) for n in n_values])
907
+
908
+ # Mostrar los puntos en un gráfico de dispersión
909
+ plt.figure("Fibonacci Function")
910
+ plt.plot(n_values, fibonacci_values, marker='o', linestyle='-')
911
+ plt.xlabel('n')
912
+ plt.ylabel('Fib(n)')
913
+ plt.title('Fibonacci Function')
914
+ plt.grid(True)
915
+ plt.show()
916
+
917
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
918
+ return f"Graph displayed with attributes: {attribute_names}"
919
+
920
+ def __str__(self):
921
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
922
+ return f"Parameters of the Fibonacci Function: {attribute_names}"
923
+ class Legendre:
924
+ def __init__(self, grade=None, x_values_list=None):
925
+ self.grade = grade
926
+ self.x_values_list = x_values_list
927
+ if any(param is None for param in [grade, x_values_list]):
928
+ raise ValueError("All parameters must be provided.")
929
+
930
+ def graph(self):
931
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
932
+ # f(x) = P_n(x)
933
+ y_values = scipy.special.eval_legendre(int(self.grade), x_values)
934
+
935
+ plt.figure(f"Legendre Function of Grade {self.grade}")
936
+ plt.plot(x_values, y_values, label=f'P_{self.grade}(x)')
937
+ plt.xlabel('x')
938
+ plt.ylabel('f(x)')
939
+ plt.title(f"Legendre Function of Grade {self.grade}")
940
+ plt.grid(True)
941
+ plt.legend()
942
+ plt.show()
943
+
944
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
945
+ return f"Graph displayed with attributes: {attribute_names}"
946
+
947
+ def __str__(self):
948
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
949
+ return f"Parameters of the Legendre Function of Grade {self.grade}: {attribute_names}"
950
+ class Gaussian:
951
+ def __init__(self, mu=None, sigma=None, x_values_list=None):
952
+ self.mu = mu
953
+ self.sigma = sigma
954
+ self.x_values_list = x_values_list
955
+ if any(param is None for param in [mu, sigma, x_values_list]):
956
+ raise ValueError("All parameters must be provided.")
957
+
958
+ def graph(self):
959
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
960
+ # f(x) = e ** (-((x - mu ** 2) / (2 * sigma ** 2)) / (sigma * √2π))
961
+ y_values = np.exp(-((x_values - self.mu) ** 2) / (2 * self.sigma ** 2)) / (self.sigma * np.sqrt(2 * np.pi))
962
+
963
+ plt.figure("Gaussian Function")
964
+ plt.plot(x_values, y_values, label=f'f(x) = e^(-((x - {self.mu})^2) / (2 * {self.sigma}^2)) / ({self.sigma} * sqrt(2 * π))')
965
+ plt.xlabel('x')
966
+ plt.ylabel('f(x)')
967
+ plt.title('Gaussian Function')
968
+ plt.grid(True)
969
+ plt.legend()
970
+ plt.show()
971
+
972
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
973
+ return f"Graph displayed with attributes: {attribute_names}"
974
+
975
+ def __str__(self):
976
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
977
+ return f"Parameters of the Gaussian Function: {attribute_names}"
978
+ class GeneralizedLogistics:
979
+ def __init__(self, a=None, b=None, c=None, d=None, x_values_list=None):
980
+ self.a = a
981
+ self.b = b
982
+ self.c = c
983
+ self.d = d
984
+ self.x_values_list = x_values_list
985
+ if any(param is None for param in [a, b, c, d, x_values_list]):
986
+ raise ValueError("All parameters must be provided.")
987
+
988
+ def graph(self):
989
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
990
+ # f(x) = d / (1 + exp(-b * (x - a)) + c)
991
+ expo = -self.b * (x_values - self.a)
992
+ y_values = self.d / (1 + np.exp(expo)) + self.c
993
+
994
+ plt.figure("Generalized Logistics Functions")
995
+ plt.plot(x_values, y_values, label=f'f(x) = {self.d} / (1 + exp(-{self.b}(x - {self.a}))) + {self.c}')
996
+ plt.xlabel('x')
997
+ plt.ylabel('f(x)')
998
+ plt.title('Generalized Logistics Functions')
999
+ plt.grid(True)
1000
+ plt.legend()
1001
+ plt.show()
1002
+
1003
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1004
+ return f"Graph displayed with attributes: {attribute_names}"
1005
+
1006
+ def __str__(self):
1007
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1008
+ return f"Atributos de the Generalized Logistics Functions: {attribute_names}"
1009
+ class LogSineProduct:
1010
+ def __init__(self, x_values_list=None):
1011
+ self.x_values_list = x_values_list
1012
+ if x_values_list is None:
1013
+ raise ValueError("The range of values ​​of x must be provided.")
1014
+
1015
+ def graph(self):
1016
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1017
+ # f(x) = log|sin(x)|
1018
+ y_values = np.log(np.abs(np.sin(x_values)))
1019
+
1020
+ plt.figure("Sine Product Logarithm Function")
1021
+ plt.plot(x_values, y_values, label='f(x) = log|sin(x)|')
1022
+ plt.xlabel('x')
1023
+ plt.ylabel('f(x)')
1024
+ plt.title('Sine Product Logarithm Function')
1025
+ plt.grid(True)
1026
+ plt.legend()
1027
+ plt.show()
1028
+
1029
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1030
+ return f"Graph displayed with attributes: {attribute_names}"
1031
+
1032
+ def __str__(self):
1033
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1034
+ return f"Parameters of the Sine Product Logarithm Function: {attribute_names}"
1035
+ class LogGamma:
1036
+ def __init__(self, x_values_list=None):
1037
+ self.x_values_list = x_values_list
1038
+ if x_values_list is None:
1039
+ raise ValueError("The range of values ​​of x must be provided.")
1040
+
1041
+ def graph(self):
1042
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1043
+ # f(x) = ln(Γ(x))
1044
+ y_values = scipy.special.gammaln(x_values)
1045
+
1046
+ plt.figure("Gamma Logarithm Function")
1047
+ plt.plot(x_values, y_values, label='f(x) = ln(Γ(x))')
1048
+ plt.xlabel('x')
1049
+ plt.ylabel('f(x)')
1050
+ plt.title('Gamma Logarithm Function')
1051
+ plt.grid(True)
1052
+ plt.legend()
1053
+ plt.show()
1054
+
1055
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1056
+ return f"Graph displayed with attributes: {attribute_names}"
1057
+
1058
+ def __str__(self):
1059
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1060
+ return f"Parameters of the Gamma Logarithm Function: {attribute_names}"
1061
+ class GeneralizedExponential:
1062
+ def __init__(self, a=None, b=None, c=None, x_values_list=None):
1063
+ self.a = a
1064
+ self.b = b
1065
+ self.c = c
1066
+ self.x_values_list = x_values_list
1067
+ if any(param is None for param in [a, b, c, x_values_list]):
1068
+ raise ValueError("All parameters must be provided.")
1069
+
1070
+ def graph(self):
1071
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1072
+ # f(x) = a * exp(-(x - b) ** 2 / (2c ** 2))
1073
+ y_values = self.a * np.exp(-(x_values - self.b)**2 / (2 * self.c**2))
1074
+
1075
+ plt.figure("Generalized Exponential Function")
1076
+ plt.plot(x_values, y_values, label=f'f(x) = {self.a} * exp(-((x - {self.b})^2) / (2 * {self.c}^2))')
1077
+ plt.xlabel('x')
1078
+ plt.ylabel('f(x)')
1079
+ plt.title("Generalized Exponential Function")
1080
+ plt.grid(True)
1081
+ plt.legend()
1082
+ plt.show()
1083
+
1084
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1085
+ return f"Graph displayed with attributes: {attribute_names}"
1086
+
1087
+ def __str__(self):
1088
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1089
+ return f"Parameters of the Generalized Exponential Function: {attribute_names}"
1090
+ class ModifiedAckermann:
1091
+ def __init__(self, m=None, n=None, x_values_list=None):
1092
+ self.m = m
1093
+ self.n = n
1094
+ self.x_values_list = x_values_list
1095
+ if any(param is None for param in [m, n, x_values_list]):
1096
+ raise ValueError("All parameters must be provided.")
1097
+
1098
+ def graph(self):
1099
+ def ack_modificada(m, n):
1100
+ if m == 0:
1101
+ return n + 1
1102
+ elif n == 0:
1103
+ return ack_modificada(m - 1, 1)
1104
+ elif m == 1:
1105
+ return n + 2
1106
+ elif m == 2:
1107
+ return 2 * n + 3
1108
+ elif m == 3:
1109
+ return 2 ** (n + 3) - 3
1110
+ else:
1111
+ raise ValueError("La funció modificada d'Ackermann només es defineix per m = 0, 1, 2, 3.")
1112
+
1113
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1114
+ # f(x) = Ack_mod(m, x)
1115
+ y_values = np.array([ack_modificada(int(self.m), int(n)) for n in x_values])
1116
+
1117
+ plt.figure("Modified Akermann Function")
1118
+ plt.plot(x_values, y_values, label=f'Ack_mod({self.m}, x)')
1119
+ plt.xlabel('x')
1120
+ plt.ylabel('f(x)')
1121
+ plt.title("Modified Akermann Function")
1122
+ plt.grid(True)
1123
+ plt.legend()
1124
+ plt.show()
1125
+
1126
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1127
+ return f"Graph displayed with attributes: {attribute_names}"
1128
+
1129
+ def __str__(self):
1130
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1131
+ return f"Parameters of the Modified Akermann Function: {attribute_names}"
1132
+ class Floor:
1133
+ def __init__(self, x_values_list=None):
1134
+ self.x_values_list = x_values_list
1135
+ if x_values_list is None:
1136
+ raise ValueError("The range of values ​​of x must be provided.")
1137
+
1138
+ def graph(self):
1139
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1140
+ # f(x) = floor(x)
1141
+ y_values = np.floor(x_values)
1142
+
1143
+ plt.figure("Floor Function")
1144
+ plt.plot(x_values, y_values, label='floor(x)')
1145
+ plt.xlabel('x')
1146
+ plt.ylabel('f(x)')
1147
+ plt.title("Floor Function")
1148
+ plt.grid(True)
1149
+ plt.legend()
1150
+ plt.show()
1151
+
1152
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1153
+ return f"Graph displayed with attributes: {attribute_names}"
1154
+
1155
+ def __str__(self):
1156
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1157
+ return f"Parameters of the Floor Function: {attribute_names}"
1158
+ class Ceil:
1159
+ def __init__(self, x_values_list=None):
1160
+ self.x_values_list = x_values_list
1161
+ if x_values_list is None:
1162
+ raise ValueError("The range of values ​​of x must be provided.")
1163
+
1164
+ def graph(self):
1165
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1166
+ y_values = np.ceil(x_values)
1167
+
1168
+ plt.figure("Ceil Function")
1169
+ plt.plot(x_values, y_values, label='ceil(x)')
1170
+ plt.xlabel('x')
1171
+ plt.ylabel('f(x)')
1172
+ plt.title("Ceil Function")
1173
+ plt.grid(True)
1174
+ plt.legend()
1175
+ plt.show()
1176
+
1177
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1178
+ return f"Graph displayed with attributes: {attribute_names}"
1179
+
1180
+ def __str__(self):
1181
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1182
+ return f"Parameters of the Ceil Function: {attribute_names}"
1183
+ class Identity:
1184
+ def __init__(self, x_values_list=None):
1185
+ self.x_values_list = x_values_list
1186
+ if x_values_list is None:
1187
+ raise ValueError("The range of values ​​of x must be provided.")
1188
+
1189
+ def graph(self):
1190
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1191
+ # f(x) = x
1192
+ y_values = x_values
1193
+
1194
+ plt.figure("Identity Function")
1195
+ plt.plot(x_values, y_values, label='f(x) = x')
1196
+ plt.xlabel('x')
1197
+ plt.ylabel('f(x)')
1198
+ plt.title("Identity Function")
1199
+ plt.grid(True)
1200
+ plt.legend()
1201
+ plt.show()
1202
+
1203
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1204
+ return f"Graph displayed with attributes: {attribute_names}"
1205
+
1206
+ def __str__(self):
1207
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1208
+ return f"Parameters of the Identity Function: {attribute_names}"
1209
+ class BesselOrder1:
1210
+ def __init__(self, x_values_list=None):
1211
+ self.x_values_list = x_values_list
1212
+ if x_values_list is None:
1213
+ raise ValueError("The range of values ​​of x must be provided.")
1214
+
1215
+ def graph(self):
1216
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1217
+ # f(x) = J1(x)
1218
+ y_values = scipy.special.jv(1, x_values)
1219
+
1220
+ plt.figure("Bessel Function of Order 1")
1221
+ plt.plot(x_values, y_values, label='J1(x)')
1222
+ plt.xlabel('x')
1223
+ plt.ylabel('f(x)')
1224
+ plt.title("Bessel Function of Order 1")
1225
+ plt.grid(True)
1226
+ plt.legend()
1227
+ plt.show()
1228
+
1229
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1230
+ return f"Graph displayed with attributes: {attribute_names}"
1231
+
1232
+ def __str__(self):
1233
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1234
+ return f"Parameters of the Bessel Function of Order 1: {attribute_names}"
1235
+ class DiracDelta:
1236
+ def __init__(self, x_values_list=None):
1237
+ self.x_values_list = x_values_list
1238
+ if x_values_list is None:
1239
+ raise ValueError("The range of values ​​of x must be provided.")
1240
+
1241
+ def graph(self):
1242
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1243
+ # f(x) = δ(x)
1244
+ y_values = np.zeros_like(x_values)
1245
+ y_values[len(x_values) // 2] = 1
1246
+
1247
+ plt.figure("Dirac Delta Function")
1248
+ plt.stem(x_values, y_values, label='δ(x)')
1249
+ plt.xlabel('x')
1250
+ plt.ylabel('f(x)')
1251
+ plt.title("Dirac Delta Function")
1252
+ plt.grid(True)
1253
+ plt.legend()
1254
+ plt.show()
1255
+
1256
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1257
+ return f"Graph displayed with attributes: {attribute_names}"
1258
+
1259
+ def __str__(self):
1260
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1261
+ return f"Parameters of the Dirac Delta Function: {attribute_names}"
1262
+ class ComplexExponential:
1263
+ def __init__(self, a=None, b=None, x_values_list=None):
1264
+ self.a = a
1265
+ self.b = b
1266
+ self.x_values_list = x_values_list
1267
+ if any(param is None for param in [a, b, x_values_list]):
1268
+ raise ValueError("All parameters must be provided.")
1269
+
1270
+ def graph(self):
1271
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1272
+ # f(x) = a * exp(j * bx)
1273
+ y_values = self.a * np.exp(1j * self.b * x_values)
1274
+
1275
+ plt.figure("Complex Exponential Function")
1276
+ plt.plot(x_values, np.real(y_values), label=f'Real: {self.a} * exp(j * {self.b} * x)')
1277
+ plt.plot(x_values, np.imag(y_values), label=f'Imaginary: {self.a} * exp(j * {self.b} * x)')
1278
+ plt.xlabel('x')
1279
+ plt.ylabel('f(x)')
1280
+ plt.title("Complex Exponential Function")
1281
+ plt.grid(True)
1282
+ plt.legend()
1283
+ plt.show()
1284
+
1285
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1286
+ return f"Graph displayed with attributes: {attribute_names}"
1287
+
1288
+ def __str__(self):
1289
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1290
+ return f"Parameters of the Complex Exponential Function: {attribute_names}"
1291
+ class TopHat:
1292
+ def __init__(self, a=None, b=None, x_values_list=None):
1293
+ self.a = a
1294
+ self.b = b
1295
+ self.x_values_list = x_values_list
1296
+ if any(param is None for param in [a, b, x_values_list]):
1297
+ raise ValueError("All parameters must be provided.")
1298
+
1299
+ def graph(self):
1300
+ x_values = np.linspace(self.x_values_list[0], self.x_values_list[1], self.x_values_list[2])
1301
+ y_values = np.where((x_values >= self.a) & (x_values <= self.b), 1, 0)
1302
+
1303
+ plt.figure("Top Hat Function")
1304
+ plt.plot(x_values, y_values, label=f'Caja({self.a}, {self.b})')
1305
+ plt.xlabel('x')
1306
+ plt.ylabel('f(x)')
1307
+ plt.title("Top Hat Function")
1308
+ plt.grid(True)
1309
+ plt.legend()
1310
+ plt.show()
1311
+
1312
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1313
+ return f"Graph displayed with attributes: {attribute_names}"
1314
+
1315
+ def __str__(self):
1316
+ attribute_names = ", ".join(f"{key} = {value}" for key, value in vars(self).items())
1317
+ return f"Parameters of the Top Hat Function: {attribute_names}"