Welcome Guest! To enable all features please Login. New Registrations are disabled.

Notification

Icon
Error

Login


Options
Go to last post Go to first unread
Offline subseapark  
#1 Posted : 10 November 2017 23:13:58(UTC)
subseapark

Rank: Newbie

Groups: Registered
Joined: 07/09/2016(UTC)
Posts: 9
United States
Location: Houston

In the attached file I've calculated the frequency response of an electronic filter and plotted the result. The calculation time however is excessive, and takes anywhere from 30s to a minute to implement. This has made the calculation process (i.e. development and debugging) an agonisingly slow experience.

As I'm still learning the ins-and-outs of SMath, I'm curious to know if there is anything I've done (which could be done differently) that is causing the excessive recalculation time? And if so, what would be a more efficient method to implement the calculation be?

As a comparison, on implementing the same calculation in MathCAD 14, the re-calculation time was almost instantaneous.

Process time.jpg

SMath file: Filter Response.sm (97kb) downloaded 30 time(s).
MathCAD file: Filter Response.xmcd (128kb) downloaded 13 time(s).

Wanna join the discussion?! Login to your SMath Studio Forum forum account. New Registrations are disabled.

Online alyles  
#2 Posted : 11 November 2017 00:16:00(UTC)
alyles


Rank: Advanced Member

Groups: Registered
Joined: 23/03/2016(UTC)
Posts: 276
United States

Was thanked: 91 time(s) in 57 post(s)
I changed all of your assignments optimizations from Symbolic to Numeric.

It originally ran at 5.45 seconds on my machine. Now runs in 0.849 seconds. Filter Response_optimized.sm (97kb) downloaded 17 time(s).

You can right click on an assignment and there will be a menu for optimizations. You can choose symbolic, numeric or none.

I'm not exactly sure if what I'm about to say is true, but it is how I interpret those settings.

For what you are doing, when you assign a value to Z.d for example, you want the expression to be evaluated and assigned to Z.d. That is what numerical optimization does, I believe. You could also envelope everything in the eval() statement, but I think it does the same thing.

When the optimization is set to symbolic, the expression isn't evaluated right away. Instead it points to assignment and re-evaluates it whenever Z.d is called. So if you use Z.d multiple times it re-evaluates it every time. When you have multiple expressions that are symbolic and repeated you can see how this could stack up and cause some delay. The program might be evaluating Z.d 20 times, rather than just one.

Again, I don't know if I explained it right. I don't fully understand it myself. But I tend to have the feeling that numerical optimization evaluates the expression immediately while symbolic optimization will evaluate the expression whenever is it called later on.

Edited by user 11 November 2017 00:35:54(UTC)  | Reason: Not specified

Feel free to join the SMath Studio Users Discord Channel: https://discord.gg/PayZpJW
thanks 1 user thanked alyles for this useful post.
on 11/11/2017(UTC)
Offline Jean Giraud  
#3 Posted : 11 November 2017 00:35:00(UTC)
Jean Giraud

Rank: Guest

Groups: Registered
Joined: 04/07/2015(UTC)
Posts: 6,866
Canada

Was thanked: 981 time(s) in 809 post(s)
Originally Posted by: subseapark Go to Quoted Post
And if so, what would be a more efficient method to implement the calculation be?
Comments:
1. "i" from the palette is buit-in imaginary [though nothing wrong SQRT(-1)
2. once the you have evaluated results.... My Equation = you can disable
all local evaluations, they are in the "cryogenic register"
3. All the vectorized functions eval(,)

Something to review about the magenta/orange traces ... Maybe units ?


Timing dropped down from 45 sec down 7 !!!

Cheers Houston ...

Filter Response_1.sm (101kb) downloaded 42 time(s).

thanks 1 user thanked Jean Giraud for this useful post.
on 11/11/2017(UTC)
Offline subseapark  
#4 Posted : 11 November 2017 01:07:56(UTC)
subseapark

Rank: Newbie

Groups: Registered
Joined: 07/09/2016(UTC)
Posts: 9
United States
Location: Houston

I took Jean's file and changed all the assignment to Numeric; as suggested by alyles. This dropped the recalculation time a further 20%.

MAGNIFICENT

Thank you both!
Users browsing this topic
Guest
Similar Topics
Speeding up calculation time for Monte Carlo simulations (Questions)
by gth802s 01/12/2023 10:41:02(UTC)
Very long calculation time of absolute values (Questions)
by Xylene 20/01/2023 15:28:19(UTC)
Very slow calculation time (Questions)
by Lucas_MSA 17/11/2021 17:52:00(UTC)
Calculation time decrease of cam profile program (Questions)
by janclaeys 23/07/2021 16:16:49(UTC)
Long Calculation Times (Questions)
by Amimi 11/07/2020 01:23:57(UTC)
[SS-4593] Calculation time message overwritten by "Ready" (Bugs & Problems)
by Razonar 28/02/2019 00:28:28(UTC)
Sometimes VERY slow calculation time in program loops (Questions)
by themzlab 15/02/2017 17:52:49(UTC)
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.