Bypassing Default Values of Constants

Bypassing Default Values of Constants - Mensajes

#1 Publicado: 10/3/2023 12:14:44
ceakins

ceakins

0 me gusta en 2 mensajes.

Grupo: 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 Publicado: 10/3/2023 14:15:17
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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 Publicado: 10/3/2023 15:33:00
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: 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 Publicado: 10/3/2023 17:31:59
ceakins

ceakins

0 me gusta en 2 mensajes.

Grupo: 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 Publicado: 10/3/2023 19:34:36
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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 Publicado: 10/3/2023 19:39:56
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: 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 Publicado: 12/3/2023 13:00:06
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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 Publicado: 12/3/2023 19:33:26
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: 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 Publicado: 12/3/2023 20:02:26
overlord

overlord

600 me gusta en 1.381 mensajes.

Grupo: 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 Publicado: 13/3/2023 10:28:26
Jean Giraud

Jean Giraud

983 me gusta en 6.866 mensajes.

Grupo: User

Manage wisely, ignoring Bible.

Pattern Complex.sm (31,81 KiB) descargado 1353 vez(es).
#11 Publicado: 13/3/2023 13:13:15
⚜ Kenny Lemens, P.E. ᵂᴵ

⚜ Kenny Lemens, P.E. ᵂᴵ

85 me gusta en 181 mensajes.

Grupo: 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

Mostrar 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:
Citar

'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
  • Nuevos mensajes
  • Sin mensajes nuevos