Maple Integration of two variables - variables

Im trying to find out how to type fig. 1 into maple:
because when i do it myself i get fig. 2
This is about forced periodic vibrations.

It looks like you are integrating over "Tao" assuming everything else constant for integration. Why don't you redefine a new variable, say y = w*T and let maple evaluate?
If it is just for typing as a text, you can first type in Math format and comment it out with # sign.

Related

How to express union types in Kotlin?

Union types, also known as sum types are a powerful language feature that I find myself using often in TypeScript
something along the lines of:
let a: string | number = “hello”
a = 3
How would I achieve this type of behavior in kotlin?
I saw some people talking about using inheritance and sealed classes to accomplish this but it looks like if you want to use that approach with primitives (such as String and Int) then one would have to write wrappers around those types to access the underlying value.
Im wondering if there is a more pragmatic solution.
There is an issue in Kotlin issue tracker: Denotable union and intersection types (it also contains links to a few previous discussions). The last update from the team is
Roman Elizarov commented 19 Nov 2021 18:14
Short update on this issue. This is an interesting and important feature, but it is really hard to integrate into the language in a backward-compatible and pragmatic way. We'll start working on it fully when we release the new K2 compiler and the best compiler engineers from our team will be able to start looking into it.
As far as I know, there isn't really a "pretty" way to do it in kotlin
One way to achieve a variable that can hold strings and ints could look like that:
var x: Any = 5
x = "hello"
but as you can notice, X can hold any type not only strings and ints, but you could use the "Either" class, from Arrow library (If I'm not mistaken) which allows such behaviour:
var x = Either<Int, String>(5)
Either way, I'm not really sure why would you need such a variable

How to rename a list of variables

I generated a number of dummy variables from a variable indicating the the relevant quarter, labelled quarter, with the following command:
tabulate quarter, generate(timeq)
This generates a set of dummy variables that range from timeq1 to timeq68.
I am trying to think about a way to rename these variables to change the names in the following way
timeq1 into 1995q1
timeq2 into 1995q2
timeq3 into 1995q3
timeq4 into 1995q4
...
timeq68 into 2011q4
As has been pointed out, this question sorely lacks a good MCVE. but an answer is possible.
Note first that the ambition to create variable with names beginning with 1 and 2 is futile as it is a basic rule that such names are not legal. However, a beginning underscore is allowed.
The problem of renaming requires, I think, at least one loop. In fact, it seems easier to back up and create the variables from scratch.
The first part of the code just creates a sandbox for play.
clear
set obs 68
gen quarter = yq(1994, 4) + _n
format quarter %tq
The second part is ad hoc code for the problem. Note that variable labels can take the form desired.
forval y = 1995/2011 {
forval q = 1/4 {
gen _`y'q`q' = quarter == yq(`y', `q')
label var _`y'q`q' "`y'q`q'"
}
}

How to change the variable length in Progress?

I'm pretty new to progress and I want to ask a question.
How do I change variable (string) length in runtime?
ex.
define variable cname as char.
define variable clen as int.
cname= "".
DO cnts = 1 TO 5.
IF prc[cnts] <> "" THEN DO:
clen = clen + LENGTH(prc[cnts]).
cname = cname + prc[cnts].
END.
END.
Put cname format '???' at 1. /here change variable length/
Thanks for the reply
If the PUT statement is what you want to change, then
PUT UNFORMATTED cname.
will write the entire string out without having to worry about the length of the FORMAT phrase.
If you need something formatted, then
PUT UNFORMATTED STRING(cname, fill("X", clen)).
will do what you want. Look up the "STRING()" function in the ABL Ref docs.
In Progress 4GL all data is variable length.
This is one of the big differences between Progress and lots of other development environments. (And in my opinion a big advantage.)
Each datatype has a default format, which you can override, but that is only for display purposes.
Display format has no bearing on storage.
You can declare a field with a display format of 3 characters:
define variable x as character no-undo format "x(3)".
And then stuff 60 characters into the field. Progress will not complain.
x = "123456789012345678901234567890123456789012345678901234567890".
It is extremely common for 4gl application code to over-stuff variables and fields.
(If you then use SQL-92 to access the data you will hear much whining and gnashing of teeth from your SQL client. This is easily fixable with the "dbtool" utility.)
You change the display format when you define something:
define variable x as character no-undo format "x(30)".
or when you use it:
put x format "x(15)".
or
display x format "x(43)".
(And in many other ways -- these are just a couple of easy examples.)
Regardless of the display format the length() function will report the actual length of the data.

Strip first 2 characters and replace with another

This seems like quite a silly basic question but it seems something I have completely passed over in my knowledge.
Basically I have a string representing a phone number (0 being the area code): 0828889988
And would like to replace the first zero with a 27 (South African dialing code) as I am pretty sure it will always be so, my SMS api requires it in international format but I want the user to enter it in local format, so should be: 27828889988
Is there a line or two of code I can call to replace that first character with the two others?
As is - I can think around a workaround solution but as I am not sure of the direct syntax will be quite a few lines long.
Dim number as String = "0828889988"
number = "27" + number.SubString(1)
return number //returns "27828889988"

can a variable have multiple values

In algebra if I make the statement x + y = 3, the variables I used will hold the values either 2 and 1 or 1 and 2. I know that assignment in programming is not the same thing, but I got to wondering. If I wanted to represent the value of, say, a quantumly weird particle, I would want my variable to have two values at the same time and to have it resolve into one or the other later. Or maybe I'm just dreaming?
Is it possible to say something like i = 3 or 2;?
This is one of the features planned for Perl 6 (junctions), with syntax that should look like my $a = 1|2|3;
If ever implemented, it would work intuitively, like $a==1 being true at the same time as $a==2. Also, for example, $a+1 would give you a value of 2|3|4.
This feature is actually available in Perl5 as well through Perl6::Junction and Quantum::Superpositions modules, but without the syntax sugar (through 'functions' all and any).
At least for comparison (b < any(1,2,3)) it was also available in Microsoft Cω experimental language, however it was not documented anywhere (I just tried it when I was looking at Cω and it just worked).
You can't do this with native types, but there's nothing stopping you from creating a variable object (presuming you are using an OO language) which has a range of values or even a probability density function rather than an actual value.
You will also need to define all the mathematical operators between your variables and your variables and native scalars. Same goes for the equality and assignment operators.
numpy arrays do something similar for vectors and matrices.
That's also the kind of thing you can do in Prolog. You define rules that constraint your variables and then let Prolog resolve them ...
It takes some time to get used to it, but it is wonderful for certain problems once you know how to use it ...
Damien Conways Quantum::Superpositions might do what you want,
https://metacpan.org/pod/Quantum::Superpositions
You might need your crack-pipe however.
What you're asking seems to be how to implement a Fuzzy Logic system. These have been around for some time and you can undoubtedly pick up a library for the common programming languages quite easily.
You could use a struct and handle the operations manualy. Otherwise, no a variable only has 1 value at a time.
A variable is nothing more than an address into memory. That means a variable describes exactly one place in memory (length depending on the type). So as long as we have no "quantum memory" (and we dont have it, and it doesnt look like we will have it in near future), the answer is a NO.
If you want to program and to modell this behaviour, your way would be to use a an array (with length equal to the number of max. multiple values). With this comes the increased runtime, hence the computations must be done on each of the values (e.g. x+y, must compute with 2 different values x1+y1, x2+y2, x1+y2 and x2+y1).
In Perl , you can .
If you use Scalar::Util , you can have a var take 2 values . One if it's used in string context , and another if it's used in a numerical context .