Bypassing Default Values of Constants

Bypassing Default Values of Constants - Messages

#1 Posted: 3/10/2023 12:14:44 PM
ceakins

ceakins

0 likes in 2 posts.

Group: User

Hi all!

I'm sure this is a really simple thing, but I seem to not be searching the right question in my forum searches... I work in the Electrical Engineering field, and as many are aware, we use i to represent current, and j to represent the imaginary unit. I've been trying to figure out how to use i as a variable in smath, but it appears everything I've tried results in i being the imaginary unit rather than used as a variable.

How do you bypass the "constant" functionality built into i in the program and use it as a variable? Also, is there a way to permanently re-assign j to be the imaginary unit within the program?

Thanks in advance!
#2 Posted: 3/10/2023 2:15:17 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

How do you bypass the "constant" functionality built into i in the program and use it as a variable ? Also, is there a way to permanently re-assign j to be the imaginary unit within the program ?


Collapse or front end 'j' at the top of the document.
Use 'j' instead of built-in 'i'

imaginary.PNG
#3 Posted: 3/10/2023 3:33:00 PM
overlord

overlord

554 likes in 1333 posts.

Group: Moderator

You can't totally remove i assign.
Or swap i with j via editing Constants.xml.
It is hard-embedded to smath code.
Clear(i) gives 1, which falsely results as it worked.
But it won't actually be removed by Clear().
However, you can assign sqrt(-1) or i to j.
Results placeholder can be edited with j.
And you can reassign you i result to j.

Regards

2023-03-10_21-27.png
#4 Posted: 3/10/2023 5:31:59 PM
ceakins

ceakins

0 likes in 2 posts.

Group: User

Wrote

You can't totally remove i assign.
Or swap i with j via editing Constants.xml.
It is hard-embedded to smath code.
Clear(i) gives 1, which falsely results as it worked.
But it won't actually be removed by Clear().
However, you can assign sqrt(-1) or i to j.
Results placeholder can be edited with j.
And you can reassign you i result to j.

Regards

2023-03-10_21-27.png



Thanks for the assistance! Am I understanding correctly then that there isn't a real way to assign lower case i as a normal variable and use it for a real number then? Just double checking.

I've attached a screenshot to this post of an example calculation, I don't think it will be a huge deal to substitute capital I for i in most formulas, I just need to be aware of the limitation as I and i have different connotations in my work at times. Haven't dove into the units too much with smath yet, but I have had a hard time with similar programs in the past with similar formulas as it's hard to get it to mix SI & imperial units to a desired result (i.e., inputs in amps, feet, lbs, etc to result in a lb/ft or similar)

Screenshot 2023-03-10 142647.png
#5 Posted: 3/10/2023 7:34:36 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Am I understanding correctly then that there isn't a real way to assign lower case i as a normal variable and use it for a real number then ?


Here, 'i' is scalar wild real.

Plot.PNG
#6 Posted: 3/10/2023 7:39:56 PM
overlord

overlord

554 likes in 1333 posts.

Group: Moderator

Wrote

Thanks for the assistance! Am I understanding correctly then that there isn't a real way to assign lower case i as a normal variable and use it for a real number then? Just double checking.


Actually you can, but j won't constantly swap with i.
Every worksheet should have j:sqrt(-1) at top.
i will have what you assigned. variable, real, etc.
But when you calculate something which results as sqrt(-1),
it will considered as i again.
While i still has another value,
calculation still gives it as sqrt(-1).
But when you directly call i,
it will have what you assigned.

Regards

2023-03-11_01-31.png
#7 Posted: 3/12/2023 1:00:06 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

I'm sure this is a really simple thing, but I seem to not be searching the right question in my forum searches... I work in the Electrical Engineering field, and as many are aware, we use i to represent current, and j to represent the imaginary unit. I've been trying to figure out how to use i as a variable in smath, but it appears everything I've tried results in i being the imaginary unit rather than used as a variable.

How do you bypass the "constant" functionality built into i in the program and use it as a variable? Also, is there a way to permanently re-assign j to be the imaginary unit within the program?


Imaginary 'i' is pretty universal.
Very many Smath advanced functions are coded on that basis.
They will certainly not recognize 'j' ... hits the wall.

URI.PNG
#8 Posted: 3/12/2023 7:33:26 PM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Wrote

Imaginary 'i' is pretty universal.
Very many Smath advanced functions are coded on that basis.
They will certainly not recognize 'j' ...


As well, 'i,j' are largely used by Smath original Designers
and the Smath Community as rows/cols indices.

ij Indices.PNG
#9 Posted: 3/12/2023 8:02:26 PM
overlord

overlord

554 likes in 1333 posts.

Group: Moderator

I wouldn't trust a man who once claimed √-1 doesn't mean anything mathematically.
And when proven wrong (as usual) he deleted his post without an excuse.

2023-03-12_23-23.png
Mathematical Methods in the Physical Sciences
Boas, Mary L. (Second Edition Page 46)
#10 Posted: 3/13/2023 10:28:26 AM
Jean Giraud

Jean Giraud

983 likes in 6866 posts.

Group: User

Manage wisely, ignoring Bible.

Pattern Complex.sm (31 KiB) downloaded 45 time(s).
#11 Posted: 3/13/2023 1:13:15 PM
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

74 likes in 164 posts.

Group: User

Greetings,

For the first part:
Wrote

...we use i to represent current...Thanks in advance!



To get 'I' to be your default unit for Amp, just modify the 「C:\Program Files (x86)\SMath Studio\entries\Units.xml」 as shown below:
NOTE: if you accidently corrupt this file (i.e., SMath will not even load), you can just re-install SMath as every new install will rewrite/replace the Units.xml file.SMath_DefaultUnitsOfAmp.jpg

Show Spoiler



As for the second part:
Wrote

... j to represent the imaginary unit...



As stated, you cannot replace 'i' as the Special Variable. However, there are some trick you can use (depending on your purposes):

First: define 'j as the imaginary unit; copy and paste the following:
Quote

'j:sqrt(-1)


Next: define a function, similiar to this:
Cn(_num):line(concat(var2str(Re(_num)),"\002B\",var2str(Im(_num)),"\002A\\0027\j",1,1)
With this defined at the top of your sheet, you can display your number (as a string) in the syntax you desire. To use it as a mathematical expression, just use the str2num() function to convert it into math. NOTE: for this to 'work,' you need to have the 'Custom Functions' plugin installed:
SMath_CustomImaginaryUnit.jpg


May this be of Good Help!
- Kenny Lemens, P.E. ᵂᴵ
"No matter where you go, there you are." -Buckaroo BanzaiHotkeys: https://en.smath.com/forum/resource.ashx?a=45771&b=2
  • New Posts New Posts
  • No New Posts No New Posts