Rev 7597 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7597 | Rev 7693 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | (* |
1 | (* |
2 | Copyright 2013, 2014, 2018 Anton Krotov |
2 | Copyright 2013, 2014, 2018, 2019 Anton Krotov |
Line 3... | Line 3... | ||
3 | 3 | ||
4 | This program is free software: you can redistribute it and/or modify |
4 | This program is free software: you can redistribute it and/or modify |
5 | it under the terms of the GNU Lesser General Public License as published by |
5 | it under the terms of the GNU Lesser General Public License as published by |
6 | the Free Software Foundation, either version 3 of the License, or |
6 | the Free Software Foundation, either version 3 of the License, or |
Line 249... | Line 249... | ||
249 | RETURN arctan2(x, 1.0) |
249 | RETURN arctan2(x, 1.0) |
250 | END arctan; |
250 | END arctan; |
Line 251... | Line 251... | ||
251 | 251 | ||
252 | - | ||
253 | PROCEDURE sinh* (x: REAL): REAL; |
- | |
254 | VAR |
- | |
255 | res: REAL; |
252 | |
256 | 253 | PROCEDURE sinh* (x: REAL): REAL; |
|
257 | BEGIN |
- | |
258 | IF IsZero(x) THEN |
- | |
259 | res := 0.0 |
254 | BEGIN |
260 | ELSE |
- | |
261 | res := (exp(x) - exp(-x)) / 2.0 |
- | |
262 | END |
255 | x := exp(x) |
Line 263... | Line 256... | ||
263 | RETURN res |
256 | RETURN (x - 1.0 / x) * 0.5 |
264 | END sinh; |
- | |
265 | - | ||
266 | - | ||
267 | PROCEDURE cosh* (x: REAL): REAL; |
257 | END sinh; |
268 | VAR |
258 | |
269 | res: REAL; |
- | |
270 | - | ||
271 | BEGIN |
259 | |
272 | IF IsZero(x) THEN |
- | |
273 | res := 1.0 |
- | |
274 | ELSE |
260 | PROCEDURE cosh* (x: REAL): REAL; |
Line 275... | Line 261... | ||
275 | res := (exp(x) + exp(-x)) / 2.0 |
261 | BEGIN |
276 | END |
- | |
277 | RETURN res |
- | |
278 | END cosh; |
- | |
279 | 262 | x := exp(x) |
|
280 | 263 | RETURN (x + 1.0 / x) * 0.5 |
|
281 | PROCEDURE tanh* (x: REAL): REAL; |
264 | END cosh; |
- | 265 | ||
- | 266 | ||
282 | VAR |
267 | PROCEDURE tanh* (x: REAL): REAL; |
- | 268 | BEGIN |
|
283 | res: REAL; |
269 | IF x > 15.0 THEN |
284 | 270 | x := 1.0 |
|
- | 271 | ELSIF x < -15.0 THEN |
|
285 | BEGIN |
272 | x := -1.0 |
286 | IF IsZero(x) THEN |
273 | ELSE |
Line 287... | Line 274... | ||
287 | res := 0.0 |
274 | x := exp(2.0 * x); |
288 | ELSE |
275 | x := (x - 1.0) / (x + 1.0) |
289 | res := sinh(x) / cosh(x) |
276 | END |
Line 290... | Line 277... | ||
290 | END |
277 | |
291 | RETURN res |
278 | RETURN x |
292 | END tanh; |
279 | END tanh; |
Line 293... | Line 280... | ||
293 | 280 | ||
294 | 281 | ||
295 | PROCEDURE arcsinh* (x: REAL): REAL; |
282 | PROCEDURE arsinh* (x: REAL): REAL; |
Line 296... | Line 283... | ||
296 | RETURN ln(x + sqrt((x * x) + 1.0)) |
283 | RETURN ln(x + sqrt(x * x + 1.0)) |
297 | END arcsinh; |
284 | END arsinh; |
Line 313... | Line 300... | ||
313 | res := -SYSTEM.INF() |
300 | res := -SYSTEM.INF() |
314 | ELSE |
301 | ELSE |
315 | res := 0.5 * ln((1.0 + x) / (1.0 - x)) |
302 | res := 0.5 * ln((1.0 + x) / (1.0 - x)) |
316 | END |
303 | END |
317 | RETURN res |
304 | RETURN res |
318 | END arctanh; |
305 | END artanh; |
Line 319... | Line 306... | ||
319 | 306 | ||
320 | 307 | ||
321 | PROCEDURE floor* (x: REAL): REAL; |
308 | PROCEDURE floor* (x: REAL): REAL; |
Line 372... | Line 359... | ||
372 | ELSIF x < 0.0 THEN |
359 | ELSIF x < 0.0 THEN |
373 | res := -1 |
360 | res := -1 |
374 | ELSE |
361 | ELSE |
375 | res := 0 |
362 | res := 0 |
376 | END |
363 | END |
- | 364 | ||
377 | RETURN res |
365 | RETURN res |
378 | END sgn; |
366 | END sgn; |
Line -... | Line 367... | ||
- | 367 | ||
- | 368 | ||
- | 369 | PROCEDURE fact* (n: INTEGER): REAL; |
|
- | 370 | VAR |
|
- | 371 | res: REAL; |
|
- | 372 | ||
- | 373 | BEGIN |
|
- | 374 | res := 1.0; |
|
- | 375 | WHILE n > 1 DO |
|
- | 376 | res := res * FLT(n); |
|
- | 377 | DEC(n) |
|
- | 378 | END |
|
- | 379 | ||
- | 380 | RETURN res |
|
- | 381 | END fact; |
|
379 | 382 | ||
380 | 383 |