how to assign two integral (romberg subroutine) inside loops in fortran - fortran

I'm trying to write a code for this formula
if I use romberg for each part, the result will be wrong (I'm checking the results with cosmology calculator)
zmin=0
zm=0.44 (any redshift in catalog)
zzm=0.5 (highest limit for each bin)
call Romberg (dis,dDistCa,zmin,zm)
call Romberg (dix,dDistCa,zmin,zzm)
Vnew=abs(((dix*(c/h0))**3.)-((dix*(c/h0))**3.))*s 
so I wrote it in this way :
do jm=zmin,zm,zstep
    zjm=jm+zstep
 call Romberg (dis,dDistCa,zbN,zjm)
fF=fF+((c/h0)**3.)*(dis**2.)*((omegam*(1+jm)**3+omegal)**(-0.5))*zstep  
end do
do jm=zmin,zzm,zstep
     zjm=jm+zstep
     call Romberg (dis,dDistCa,zbN,zjm)
     fF1=fF1+((c/h0)**3.)*(dis**2.)*((omegam*(1+jm)**3+omegal)**(-0.5))*zstep
end do
v=(ff-ff2)*s
it gives the right answer,so I have to choose the zsteps very small 0.00001 to have precise output ,but it has an other problem , inside the other loops it takes at least one day to run in larger numbers like zzm=3.2
I would be thankful if you help me I can modify it.

Related

Power BI :: create measure that remove the last 2 characters from column

I have a query that targets our resourceGroupName on Azure.
The resourceGroupName looks like this:
hello-world-customer-prod-rg
hello-world-customer-staging-rg
hello-world-customer-test-rg
hello-world-customer-dev-rg
I want to remove the last rg from each resourceGroupName
For now I tried this:
URL_test1 = Text.Start(SELECTEDVALUE('Usage details'[resourceGroupName]);Text.Lengh('Usage details'[resourceGroupName])-2)
but I receive 'Text.Start' is not a function and Unexpected expression Text.Length
or this:
URL_test2 = RIGHT(SELECTEDVALUE('Usage details'[resourceGroupName]);2)
and I receive Unexpected expression ;
Nothing really seems to work.
What am I doing wrong?
EDIT: this seems working but it returns me the number of characters (17) and not the text:
URL_test3 = LEN(SUBSTITUTE(SELECTEDVALUE('Usage details'[resourceGroupName]),"-rg",""))
I have actually found the solution.
I passed from:
URL_test3 = LEN(SUBSTITUTE(SELECTEDVALUE('Usage details'[resourceGroupName]),"-rg",""))
to:
URL_test3 = SUBSTITUTE(SELECTEDVALUE('Usage details'[resourceGroupName]),"-rg","")
That's why it was showing the number!
It was because of the LEN().

Google Sheets: IFS statement wont return date

I'm currently using the following formula:
=IFS(regexmatch(A2,"Malaysia"),
B2-dataset!B3,REGEXMATCH(A2,"Saudi Arabia"),
B2-dataset!B7,REGEXMATCH(A2,"Taiwan"),
B2-dataset!B11,REGEXMATCH(A2,"Russia"),
B2-dataset!B15,REGEXMATCH(A2,"Greece"),
B2-dataset!B19,REGEXMATCH(A2,"South Africa"),
B2-dataset!B23,REGEXMATCH(A2,"UAE"),
B2-dataset!B27,REGEXMATCH(A2,"Albania"),
B2-dataset!B31,REGEXMATCH(A2,"India"),
B2-dataset!B35,REGEXMATCH(A2,"South Korea"),
B2-dataset!B39,REGEXMATCH(A2,"Turkey"),
B2-dataset!B43)
The idea is that B2 (currently as =date(dd/mm/yyyy) has a deadline date. C2 (in which the formula houses) should show the date when everything should be delivered.
Currently the outcome is a number, not a date. I've tried IF statement, which delivers a date but I can only add 3 arguments. Can someone help me?
Kind regards
if your current output is number like 40000+ it's ok and it's just formatting issue. either you will format it internally or use a formula.
try:
=TEXT(IFS(regexmatch(A2,"Malaysia"),
B2-dataset!B3,REGEXMATCH(A2,"Saudi Arabia"),
B2-dataset!B7,REGEXMATCH(A2,"Taiwan"),
B2-dataset!B11,REGEXMATCH(A2,"Russia"),
B2-dataset!B15,REGEXMATCH(A2,"Greece"),
B2-dataset!B19,REGEXMATCH(A2,"South Africa"),
B2-dataset!B23,REGEXMATCH(A2,"UAE"),
B2-dataset!B27,REGEXMATCH(A2,"Albania"),
B2-dataset!B31,REGEXMATCH(A2,"India"),
B2-dataset!B35,REGEXMATCH(A2,"South Korea"),
B2-dataset!B39,REGEXMATCH(A2,"Turkey"),
B2-dataset!B43), "dd/mm/yyyy")

Using Javascript IF function to create Google Tag Manager Variable

I'm trying to create a custom variable in Google Tag Manager. I need it to show a 0 value when...
A customer purchases using a discount code which contains the words 'Gift Voucher'
AND
It generates negative revenue.
Else it should just appear standard revenue (there are times when negative revenue is needed, hence why it should only appear as 0 when a gift voucher is used)
Ive tried the following
function () { if ({{Discount Code Used}} = str.includes("Gift Voucher") && {{Revenue}}<0 ) {return 0; } else { return {{Revenue}}; }}
But this is returning a undefined value
Is anyone able to help?
The first half of your if condition is a bit off:
{{Discount Code Used}} = str.includes('Gift Voucher')
The right way to use the .includes() method of a string is like this:
{{Discount Code Used}}.includes('Gift Voucher')
I would recommend using .indexOf() instead of .includes(), since it is supported by more browsers.
{{Discount Code Used}}.indexOf('Gift Voucher') !== -1
If it is still returning undefined, double check that Discount Code Used and Revenue are set to the correct values.

Percent format in SAS

I am trying to understand the working of percent format in SAS.
data a;
a=put(1.1,percent4.);
run;
O/P:-
**%
I am expecting the output to return 110%.
I get the expected result when I use the following code:-
data a;
a=put(1.1,percent6.);
run;
Can anyone explain why I didn't get the expected result as the width of the o/p is 4 which shall be fulfilled by percent4. ?
From the documentation: The width of the output field must account for the percent sign (% )
and parentheses for negative numbers, whether the number is negative
or positive.
So for a percent value you always need 3 + w (the width) you would like displayed. In your case, you have 3, so 3+3 = minimum 6 to have it displayed correctly.
Try this way...
data a;
ab=put(1.100,percent6.2);
run;
Make sense Dragonthoughts...
I didn't read that the problem is return 110% with percent4.0
Reeza have aswered yet.

PowerBi - Weeknumber not in the correct order

I'm new to PowerBi and i'm running into the following problem:
Weeknum + year are not shown in the correct order. See the following screenshots:
I've concatenate weeknumber with year based on a column called "PublishDate"
This is my dax query for weeknum:
Weeknum = YEAR ( [PublishDate] ) & "" & WEEKNUM ( [PublishDate], 2 )
I do notice that 1 till 9 are not shown with a 0 infront of it. Could this be causing this?
I agree with getting the '0' in the right place. Once you change the data type from text to a number, if that '0' in't there, it will be out of order as well.
I prefer editing the query and changing the data type from the beginning:
Finding the column that needs a data type change and modifying it there:
[
You can change it from text to whole number.
The problem is that the values are being sorted in alphabetical order, because they are of datatype text. So yes, the fact that '9' does not have a '0' in front of it, does cause your problem. You can solve this by changing the format of the WEEKNUM function like this (also you do not need & "" &):
Weeknum = YEAR ( [PublishDate] ) & FORMAT(WEEKNUM ( [PublishDate], 2 ),"00")