SMath Studio Forum
»
SMath Studio
»
Feature Requests
»
Functions as arguments of other functions
Rank: Newbie
Groups: Registered
Joined: 09/08/2019(UTC) Posts: 6 Location: Gdańsk
|
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
|
|
|
|
Rank: Advanced Member Groups: Registered, Advanced Member Joined: 13/01/2012(UTC) Posts: 2,725 Location: Italy Was thanked: 1393 time(s) in 909 post(s)
|
Yes it is possible, see the attached image |
If you like my plugins consider to support SMath Studio buying a plan; to offer me a coffee: paypal.me/dcprojects |
|
|
|
Rank: Newbie
Groups: Registered
Joined: 09/08/2019(UTC) Posts: 6 Location: Gdańsk
|
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.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
Make it infinite algo style.
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 09/08/2019(UTC) Posts: 6 Location: Gdańsk
|
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. If done the standard way, it would involve a LOT of writing. Edited by user 07 July 2021 16:20:06(UTC)
| Reason: could not get the image to display
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
Originally Posted by: pwi 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.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 13/09/2011(UTC) Posts: 66 Location: Kolkata
Was thanked: 9 time(s) in 9 post(s)
|
Originally Posted by: Davide Carpi Yes it is possible, see the attached image Beautiful! I wonder why Jean is not so enthousiastic?
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
... should have been posted ~ 2 hours ago.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 10/12/2009(UTC) Posts: 284 Location: Cali, Colombia Was thanked: 119 time(s) in 81 post(s)
|
Originally Posted by: pwi 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. 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!
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,508 Was thanked: 974 time(s) in 609 post(s)
|
Originally Posted by: pwi ... 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 Best regards. Alvaro.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
Originally Posted by: pwi 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].
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
... Smath is a CAS, an advanced CAS i.e: like competitive CAS, Smath is not a click_click_done.
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,191 Was thanked: 544 time(s) in 366 post(s)
|
Originally Posted by: Davide Carpi 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
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 09/08/2019(UTC) Posts: 6 Location: Gdańsk
|
Originally Posted by: Jean Giraud 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].
Originally Posted by: Jean Giraud ... 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.
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
Originally Posted by: pwi 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 !
|
|
|
|
Rank: Guest
Groups: Registered
Joined: 04/07/2015(UTC) Posts: 6,866 Was thanked: 983 time(s) in 811 post(s)
|
Originally Posted by: pwi 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 (14kb) downloaded 15 time(s). Integral 00000000 MASTER ToolBox.sm (478kb) downloaded 14 time(s).
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 23/07/2013(UTC) Posts: 1,191 Was thanked: 544 time(s) in 366 post(s)
|
Looks like line() mysteriously solve the issue. I have come across similar to this behavior before. Regards Edited by user 08 July 2021 22:27:22(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member Groups: Registered
Joined: 28/08/2014(UTC) Posts: 1,508 Was thanked: 974 time(s) in 609 post(s)
|
Originally Posted by: overlord 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/...-and-delayed-values.html Best regards. Alvaro.
|
|
|
|
SMath Studio Forum
»
SMath Studio
»
Feature Requests
»
Functions as arguments of other functions
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.