Functions as arguments of other functions

Functions as arguments of other functions - Messages

#1 Posted: 7/7/2021 8:08:40 AM
Paweł Wierzba

Paweł Wierzba

0 likes in 6 posts.

Group: 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 Posted: 7/7/2021 8:32:56 AM
Davide Carpi

Davide Carpi

1417 likes in 2873 posts.

Group: 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 Posted: 7/7/2021 9:31:23 AM
Paweł Wierzba

Paweł Wierzba

0 likes in 6 posts.

Group: 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 Posted: 7/7/2021 9:36:02 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Make it infinite algo style.

InfiniteAlgoStyle.PNG
#5 Posted: 7/7/2021 10:11:06 AM
Paweł Wierzba

Paweł Wierzba

0 likes in 6 posts.

Group: 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 Posted: 7/7/2021 10:49:47 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 Posted: 7/7/2021 1:23:49 PM
Laurent Fournier

Laurent Fournier

9 likes in 66 posts.

Group: 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 Posted: 7/7/2021 1:28:17 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

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

Algo.PNG
#9 Posted: 7/7/2021 1:31:32 PM
Oscar Campo

Oscar Campo

124 likes in 298 posts.

Group: 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 Posted: 7/7/2021 3:22:21 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: 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 Posted: 7/7/2021 3:31:59 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 Posted: 7/7/2021 6:02:38 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

sanity.PNG
#13 Posted: 7/7/2021 8:17:37 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

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

sanitysanity.PNG
#14 Posted: 7/7/2021 8:56:00 PM
overlord

overlord

554 likes in 1333 posts.

Group: 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 Posted: 7/8/2021 8:36:54 AM
Paweł Wierzba

Paweł Wierzba

0 likes in 6 posts.

Group: 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 Posted: 7/8/2021 9:45:19 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 Posted: 7/8/2021 2:44:44 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: 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 KiB) downloaded 65 time(s).
Integral 00000000 MASTER ToolBox.sm (477 KiB) downloaded 62 time(s).

#18 Posted: 7/8/2021 4:25:50 PM
overlord

overlord

554 likes in 1333 posts.

Group: 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 Posted: 7/8/2021 5:21:01 PM
Alvaro Diaz Falconi

Alvaro Diaz Falconi

992 likes in 1674 posts.

Group: 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.

  • New Posts New Posts
  • No New Posts No New Posts