Functions as arguments of other functions

Functions as arguments of other functions - Сообщения

#1 Опубликовано: 07.07.2021 08:08:40
Paweł Wierzba

Paweł Wierzba

0 сообщений из 6 понравились пользователям.

Группа: User

Hi,

in my recent calculations I needed to have a function that takes two funtions as parameters
and calculates some values. Something like:

k_f(s;c)=s(1)*c(8)

k_f(sin; cos)=

Trying this in SMath Studio unfortunately failed.

Is is possible to implement such a thing in SMath Studio?

Yours,

Pawel Wierzba







#2 Опубликовано: 07.07.2021 08:32:56
Davide Carpi

Davide Carpi

1417 сообщений из 2873 понравились пользователям.

Группа: Moderator

Yes it is possible, see the attached image

2021-07-07 13_32_01-SMath Studio - [Documento1_].png
If you like my plugins please consider to support the program buying a license; for personal contributions to me: paypal.me/dcprojects
#3 Опубликовано: 07.07.2021 09:31:23
Paweł Wierzba

Paweł Wierzba

0 сообщений из 6 понравились пользователям.

Группа: User

Thank you very much. Indeed, it works, even with functions with more arguments than one.

Sorry for asking a question about something that has already been implemented.
#4 Опубликовано: 07.07.2021 09:36:02
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Make it infinite algo style.

InfiniteAlgoStyle.PNG
#5 Опубликовано: 07.07.2021 10:11:06
Paweł Wierzba

Paweł Wierzba

0 сообщений из 6 понравились пользователям.

Группа: User

Thank you for the advice. Fortunately, standard way of defining functions is well known to me.
Unfortunately, I had to pass functions as arguments, rather than define them the "standard way".

I had several functions and some coefficients to be calculated, based on them.
Something like the example below.
[albumimg]1638[/albumimg]

If done the standard way, it would involve a LOT of writing.
#6 Опубликовано: 07.07.2021 10:49:47
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Unfortunately, I had to pass functions as arguments, rather than define them the "standard way".
I had several functions and some coefficients to be calculated, based on them.
Something like the example below.


Attach the document for understanding that mystic doing.
#7 Опубликовано: 07.07.2021 13:23:49
Laurent Fournier

Laurent Fournier

9 сообщений из 66 понравились пользователям.

Группа: User

Wrote

Yes it is possible, see the attached image

2021-07-07 13_32_01-SMath Studio - [Documento1_].png



Beautiful!
I wonder why Jean is not so enthousiastic?
#8 Опубликовано: 07.07.2021 13:28:17
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

... should have been posted ~ 2 hours ago.

Algo.PNG
#9 Опубликовано: 07.07.2021 13:31:32
Oscar Campo

Oscar Campo

124 сообщений из 298 понравились пользователям.

Группа: Moderator

Wrote

Thank you for the advice. Fortunately, standard way of defining functions is well known to me.
Unfortunately, I had to pass functions as arguments, rather than define them the "standard way".

I had several functions and some coefficients to be calculated, based on them.
Something like the example below.
[albumimg]1638[/albumimg]

If done the standard way, it would involve a LOT of writing.



Great!
SMath has that awesome characteristic, so you can use that "standard way" for defining functions.

Good luck with your job!
#10 Опубликовано: 07.07.2021 15:22:21
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Wrote

...
I had several functions and some coefficients to be calculated, based on them.
Something like the example below.
...
If done the standard way, it would involve a LOT of writing.



Hi. You can try a for loop with something like this in the body

Clipboard01.jpg

Best regards.
Alvaro.
#11 Опубликовано: 07.07.2021 15:31:59
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

If done the standard way, it would involve a LOT of writing.


Make it algo style as exemplified.
At this point, you are missing a link ... what link ?
Before integration, you must plot the integrand.
That will avoid the Simpson integrator to result scrap.
Visit/search 'Samples' for more integrators [Adaptive, Romberg].


#12 Опубликовано: 07.07.2021 18:02:38
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

sanity.PNG
#13 Опубликовано: 07.07.2021 20:17:37
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

... Smath is a CAS, an advanced CAS
i.e: like competitive CAS, Smath is not a click_click_done.

sanitysanity.PNG
#14 Опубликовано: 07.07.2021 20:56:00
overlord

overlord

554 сообщений из 1333 понравились пользователям.

Группа: Moderator

Wrote

Yes it is possible, see the attached image


Interesting solution, promising to be very useful.
I wonder if it could be done with other functions.
It would really shorten a lot of thing if was possible.
Especially with external plugins function calls.

Regards

2021-07-08_02-52.png
#15 Опубликовано: 08.07.2021 08:36:54
Paweł Wierzba

Paweł Wierzba

0 сообщений из 6 понравились пользователям.

Группа: User

Wrote


At this point, you are missing a link ... what link ?
Before integration, you must plot the integrand.
That will avoid the Simpson integrator to result scrap.
Visit/search 'Samples' for more integrators [Adaptive, Romberg].



Wrote

... Smath is a CAS, an advanced CAS
i.e: like competitive CAS, Smath is not a click_click_done.



Thank you for help, especially the comment about potential problems
with the integrator and illustrative examples.

Starting to study other integrators [Adaptive, Romberg], as advised.

I wish I could click a few "THANK" buttons for help, but on my two browsers
(Opera and Edge) they simply generate an error message.

#16 Опубликовано: 08.07.2021 09:45:19
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Thank you for help, especially the comment about potential problems
with the integrator and illustrative examples.


I posted the wrong image ... that's the right one.
Don't drop dead by how far simple integration can fly in the blue !

SanityIntegration.PNG
#17 Опубликовано: 08.07.2021 14:44:44
Jean Giraud

Jean Giraud

983 сообщений из 6866 понравились пользователям.

Группа: User

Wrote

Thank you for help, especially the comment about potential problems with the integrator and illustrative examples.


The 'thanks' button' never worked.
1. The previous image as *,sm
2. My Integration tool box.
Please, don't hesitate for + ... Jean

Integral 000000000000 vectorsf(j,k,a,b).sm (13 КиБ) скачан 69 раз(а).
Integral 00000000 MASTER ToolBox.sm (477 КиБ) скачан 67 раз(а).

#18 Опубликовано: 08.07.2021 16:25:50
overlord

overlord

554 сообщений из 1333 понравились пользователям.

Группа: Moderator

Looks like line() mysteriously solve the issue.
I have come across similar to this behavior before.

Regards

2021-07-08_22-24.png
#19 Опубликовано: 08.07.2021 17:21:01
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 сообщений из 1675 понравились пользователям.

Группа: User

Wrote

Looks like line() mysteriously solve the issue.
...



Hi. For help understanding what's happen: that behavior is similar to the SetDelayed in Wolfram Mathematica language: https://www.wolfram.com/language/elementary-introduction/2nd-ed/39-immediate-and-delayed-values.html

Best regards.
Alvaro.

  • Новые сообщения Новые сообщения
  • Нет новых сообщений Нет новых сообщений