warning messages – Some of the functions have zero differential order

I am trying to solve the following system of differential equations, but Mathematica (11.3) complains that

NDSolveValue::pdord Some of the functions have zero differential order

I do not understand this message since all of the functions appear with their derivatives in the equations.

Here is the code:

ClearAll("Global`*")
(Rho)0 = 1;
M = 1;
eq1 = D(m(t, r), r) - 4 Pi (Rho)(t, r) R(t, r)^2 D(R(t, r), r);
eq2 = D(m(t, r), t) + (4 Pi)/3 (Rho)(t, r) R(t, r)^2 D(R(t, r), t);
eq3 = D(R(t, r), r, t) - D(R(t, r), t) D((Nu)(t, r), r) - 
   D(R(t, r), r) D((Lambda)(t, r), t);
eq4 = D((Rho)(t, r), r) + 1/4 (Rho)(t, r) D((Nu)(t, r), r);
eq5 = Exp(-2 (Nu)(t, r)) (D(R(t, r), {t, 2}) - 
      D((Nu)(t, r), t) D(R(t, r), t)) - 
   Exp(-2 (Lambda)(t, r)) D((Nu)(t, r), r) D(R(t, r), r) + m(t, r)/
   R(t, r)^2 + (4 Pi)/3 (Rho)(t, r) R(t, r);
{Ro, Ra, Ma, nu, la} = 
 NDSolveValue({eq1 == 0, eq2 == 0, eq3 == 0, eq4 == 0, 
   eq5 == 0, (Rho)(0, r) == (Rho)0, (Rho)(t, 0) == (Rho)0, 
   m(0, r) == M, 
   m(t, 0) == 
    M, (Nu)(0, r) == -(1/4) Log((Rho)0), (Nu)(t, 
     0) == -(1/4) Log((Rho)0), (Lambda)(0, r) == 
    0, (Lambda)(t, 0) == 0, R(0, r) == ((3 M)/(4 Pi (Rho)0))^(1/3), 
   R(t, 0) == ((3 M)/(4 Pi (Rho)0))^(1/3), 
   Derivative(1, 0)(R)(0, r) == 1}, {(Rho), R, 
   m, (Nu), (Lambda)}, {t, 0, 1}, {r, 0, 1})

Note: another message appears saying that the initial and boundary conditions are inconsistent, but that is another problem I have to solve later, I am more concerned with the other message at the moment.

Is putting general-use functions in a “helpers” file an anti-pattern or code smell?

Is it an anti-pattern or code smell to put “general use” functions (examples below) into a catch-all file named “helpers” or “utils”?

It’s a pattern I’ve seen quite a lot in the JavaScript world, which I’ve also seen with other languages.

By “general use” functions, I mean functions which abstract away some common, shared functionality used in an application/library and make them available for use in a general way. Some examples I’ve seen include returning a copy of an object with some keys omitted, transforming all null-ish values in a JavaScript object (eg. "", null, {}, ()) to undefined, constructing a URL from a struct of parameters, transforming strings in some fashion, etc, etc.

I often come across applications or libraries with one (or more!) util.js or helpers.ts files which just seem to be, in my opinion, a dumping ground for unrelated functions. In my opinion, code is more readable and discoverable if it’s named semantically.

If working with the examples above, I’d place them all in their own files (omit.js, null-to-undefined.js, url-builder.ts, etc), or if they are related functionality, group them (eg, deepClone, withoutKeys, shallowClone, in clone.js or similar).

I struggle to articulate why this seems like a code smell or anti-pattern to me. I think there are various things at play: creating the wrong abstraction or abstracting at the wrong time (YAGNI) meaning code is just dumped “somewhere”, lack of foresight for future maintainability.

On the other hand, I’ve seen proponents of this pattern argue that it’s a well-used pattern, and thus it has merit simply because it’s well-used. Does this argument stand?

Interesting in anyone’s thoughts on this, whether you think it’s good or bad, and if you can explain the pros/cons better than I can!

functions – wp_register_script() and wp_register_style() 4th parameter (version) not working for logged out users

I’m enqueuing scripts and styles from functions.php in my custom theme. The 4th parameter is the version number. It’s working only for logged in users.

wp_register_script( 'my-handle', get_stylesheet_directory_uri( __FILE__ ) . '/js/my-script.js', array( '' ), filemtime( get_stylesheet_directory( __FILE__ ) . '/js/my-script.js' ), true );
wp_enqueue_script( 'my-handle' );

Logged in:

<script src="https://mysite.com.local/path/to/my-script.js?ver=1614637944" type="text/javascript"></script>

Logged out:

<script src="https://mercury.photo/wp-content/plugins/instagram-feed/js/sbi-scripts.min.js" id="sb_instagram_scripts-js" type="text/javascript"></script>

Caching plugin on the live site is LiteSpeed Cache. The local dev site uses no caching. Same output on both sites.

plotting – How to make FindRoot work with PolyLog functions

I have the following code:

q = 1.6*10^-19;
hbar := 6.63/(2*(Pi))*10^-34;
m0 = 9.1*10^-31;
kb = 1.38*10^-23;
Cap := 4.5*10^-3;
W := 50*10^-6;
mu := 4.3*10^-4;
n := 20;
vth = ((3*kb*300)/m0)^0.5;
vt := -3.5;
Rex := 15 ;
vg = 0;
Plot(id /. 
  FindRoot((id - (Cap*W*mu*(n*vth)^2)/(
      7*10^-6)*(PolyLog(2, -Exp((vd - id - vg + vt)/(n*vth))) - 
        PolyLog(2, Exp((id - vg + vt)/(n*vth))))), {id, 
    10^-6}), {vd, -1, .872}, ImageSize -> Large, 
 AxesLabel -> {vd, id}, LabelStyle -> {15, Bold, Black})

It shows this error:

enter image description here

How can I specify the correct AccuracyGoal and PrecisionGoal for my problem. Also I want to plot the $id$ as a function of $vd$ for different $vg$, is there a way to automate it?

c# – Azure – Dynamically polling until certain conditions are met – using Azure Durable Functions

On waking up from the timer, JobGroupSchedulingOrchestrator kicks-off a Durable JobExecutionOrchestrator sub-orchestration for the actual execution of the jobs.

public class AzureDynamicTimerMonitoringOrchestrationFunctionApp
{
//
// Requirements:
// Use Azure Functions;
// Job – Code that executes and performs certain action
// JobGroup – One or more Jobs grouped to perform some work in a coordinated fashion
// Jobs within the group organized in a sequence
// CronSchedule – A crontab schedule – that determines the time at which the JobGroup needs to be executed
// on a recurring basis
// Implement a Job executor that executes the configured jobgroups based on corresponding crontab schedules
//
//
// Following is the implementation (for review)
//
// Reference: https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-monitor?tabs=csharp
// https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-monitor?tabs=csharp
//
// Implements a Timer Trigger Function that reads the JobGroup configuration and kicks-off a
// Durable JobGroupSchedulingOrchestrator for individual JobGroup.
// To keep unique instances of the orchestrator – the instance ID for the
// JobGroupSchedulingOrchestrator is set to be same as the name of the JobGroup
// The JobGroupSchedulingOrchestrator retrieves the crontab schedule for the specific JobGroup and
// uses a durableOrchestrationContext.CreateTimer() and monitors the ‘timer’
// On waking up from the timer, JobGroupSchedulingOrchestrator kicks-off a Durable
// JobExecutionOrchestrator sub-orchestration for the actual execution of the jobs.
// To keep unique instances of the orchestrator – the instance ID for the JobExecutionOrchestrator
// is set to be same as the name of the JobGroup with a suffix “_Execution_Orchestrator”
//

 public class OrchestratedJobGroup
 {
     public string Name { get; set; }
     public string CronSchedule { get; set; }

     public int Iterations { get; set; }
 }

 public class Job
 {
     public decimal Id { get; set; }
     public string JobGroupName { get; set; }
     public string JobName { get; set; }
     public decimal SequenceNumber { get; set; }
     public bool Enabled { get; set; }
 }
 public class JobGroup
 {
     public decimal Id { get; set; }
     public string JobGroupName { get; set; }
     public string CronSchedule { get; set; } // e.g., "0 1 * * *" - every day at 1AM
     public bool Enabled { get; set; }
 }

 public class JobGroupSchedule
 {
     public string CronSchedule { get; set; }
     public List<Job> JobsToRun { get; set; }
     /// <summary>
     /// Time to wait until the next run
     ///   -1 : No more runs - done with the JobGroup runs
     ///   0  : No wait - execute the jobs in the jobgroup
     ///   Value greater than 0 : Wait time in seconds until the next jobgroup run attempt
     /// </summary>
     public double WaitTime { get; set; }

     public string NextOccurences { get; set; }
 }
 public class JobResult
 {
     public Job Job { get; set; }
     public bool Success { get; set; }
 }

 private List<JobGroup> GetJobGroups()
 {
     // Returns a list of all Jobs for all jobs groups
     //   Individual jobgroups
     return new List<JobGroup>(); // mocking an empty for code review
 }

 (FunctionName(nameof(JobExecutor)))
 public Task<bool> JobExecutor((ActivityTrigger) Job job, ILogger logger)
 {
     //
     // The actual work of the job is performed here
     //
     return Task.FromResult(true);
 }

 (FunctionName(nameof(GetJobGroupSchedule)))
 public Task<JobGroupSchedule> GetJobGroupSchedule((ActivityTrigger) OrchestratedJobGroup orchestratedJob, ILogger logger)
 {       
     return Task.FromResult(new JobGroupSchedule 
     { 
         WaitTime = -1 // mocking an empty for code review
     });
 }

 (FunctionName(nameof(TimerOrchestrationLauncher)))
 public async Task TimerOrchestrationLauncher(
 (TimerTrigger("%TimerOrchestrationLauncherInterval%")) TimerInfo timer,
 (DurableClient) IDurableOrchestrationClient starter, ILogger log)
 {
     List<JobGroup> jobGroups;
     try
     {
         //
         // Get all enabled jobgroups' info
         //
         jobGroups = await GetJobGroups();
     }
     catch (Exception ex)
     {
         throw new Exception("Error retrieving JobGroup information", ex);
     }

     var success = true;
     foreach (var jobGroup in jobGroups)
     {
         try
         {
             if (configuration.GetValue<bool>($"Disable{jobGroup.JobGroupName}") == true)
             {
                 log.LogInformation("JobGroup has been disabled via the app settings.  Skipping JobGroup orchestrator {JobGroup}", jobGroup.JobGroupName);

                 continue;
             }

             //
             // Is the jobgroup orchestration already active?
             //
             var durableOrchestrationStatus = await starter.GetStatusAsync(jobGroup.JobGroupName);

             log.LogInformation("JobGroup Orchestration Job Group: {JobGroup} Current status: {OrchestrationStatus}",
                 jobGroup, durableOrchestrationStatus.RuntimeStatus);
             if (durableOrchestrationStatus.RuntimeStatus == OrchestrationRuntimeStatus.Canceled
                 || durableOrchestrationStatus.RuntimeStatus == OrchestrationRuntimeStatus.Completed
                 || durableOrchestrationStatus.RuntimeStatus == OrchestrationRuntimeStatus.Failed
                 || durableOrchestrationStatus.RuntimeStatus == OrchestrationRuntimeStatus.Terminated)
             {
                 log.LogInformation("JobGroup not active.  Kicking-off JobGroup Orchestration. Job Group: {JobGroup}", jobGroup);

                 //
                 // Launch orchestrator - pass in the cron-schedule and job-group name
                 //  Use the name of the JobGroup as the instanceid for the orchestrator.  This ensures
                 //    that no two instances of the same jobgroup are running at the same time
                 //    with the RuntimeStatus check in place
                 //
                 string instanceId = await starter.StartNewAsync(nameof(JobGroupSchedulingOrchestrator),
                     jobGroup.JobGroupName,
                     new OrchestratedJobGroup
                     {
                         Name = jobGroup.JobGroupName,
                         CronSchedule = jobGroup.CronSchedule
                     });

                 log.LogInformation("Started orchestration  Job Group: {JobGroup} with ID {JobInstanceId}", jobGroup, instanceId);
             }
             else
             {
                 log.LogInformation("JobGroup Orchestration already active, running or in an unknown status.  Doing nothing.  Job Group: {JobGroup}", jobGroup);
             }
         }
         catch (Exception ex)
         {
             log.LogError(ex, "Error kicking-off JobGroup Orchestration. Job Group: {JobGroup}", jobGroup);
             success = false;
         }
     }
     log.LogInformation("Started orchestration of {JobGroupCount}", jobGroups.Count());
     if (success == false)
     {
         throw new Exception("Errors found during JobGroup Orchestration orchestration");
     }
 }

 (FunctionName(nameof(JobSchedulingOrchestrator)))
 public async Task<bool> JobGroupSchedulingOrchestrator(
     (OrchestrationTrigger) IDurableOrchestrationContext context, ILogger logger)
 {
     //
     // Reference: https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-monitor?tabs=csharp
     //

     var orchestratedJobGroup = context.GetInput<OrchestratedJobGroup>();

     //
     // Initialize the schedule run info
     //
     var jobGroupSchedule = await context.CallActivityAsync<JobGroupSchedule>(nameof(GetJobGroupSchedule), orchestratedJobGroup);
     if (jobGroupSchedule.WaitTime < 0)
     {
         // Schedule info indicates to not run this jobgroup anymore - exit
         logger.LogError("Error getting next scheduled run info.  Exiting JobGroup orchestrator {JobGroup}", orchestratedJobGroup.Name);
         return await Task.FromResult(true);
     }

     while (true)
     {
         // Register any updates to wait time or cron schedule

         orchestratedJobGroup.CronSchedule = jobGroupSchedule.CronSchedule;

         DateTime nextCheckpoint = context.CurrentUtcDateTime;
         if (jobGroupSchedule.WaitTime > 0)
         {
             // Schedule info indicates for us to wait for the next checkpoint
             nextCheckpoint = context.CurrentUtcDateTime.AddSeconds(jobGroupSchedule.WaitTime);
             logger.LogInformation("Next check for JobGroup {JobGroup} at {nextCheckpoint}", orchestratedJobGroup.Name, nextCheckpoint);

             // Wait until the next check-point 
             await context.CreateTimer(nextCheckpoint, CancellationToken.None);

             if (configuration.GetValue<bool>($"Disable{orchestratedJobGroup.Name}") == true)
             {
                 logger.LogInformation("Function app has been disabled via the app settings.  Exiting JobGroup orchestrator {JobGroup}", orchestratedJobGroup.Name);
                 break;
             }

             //
             // Get the latest schedule run info
             //
             orchestratedJobGroup.Iterations++;
             jobGroupSchedule = await context.CallActivityAsync<JobGroupSchedule>(nameof(GetJobGroupSchedule), orchestratedJobGroup);
             if (jobGroupSchedule.WaitTime < 0)
             {
                 // Schedule info indicates to not run this jobgroup anymore - exit
                 logger.LogError("Exiting JobGroup orchestrator {JobGroup}", orchestratedJobGroup.Name);
                 break;
             }
         }

         logger.LogInformation("Executing JobGroup {JobGroup} at {nextCheckpoint}", orchestratedJobGroup.Name, nextCheckpoint);

         try
         {
             await context.CallSubOrchestratorAsync(
                     nameof(JobExecutionOrchestrator),
                     $"{orchestratedJobGroup.Name}_Execution_Orchestrator",
                     jobGroupSchedule.JobsToRun);
         }
         catch (Exception ex)
         {
             logger.LogError(ex, "Error Executing JobGroup {JobGroup} at {nextCheckpoint}", orchestratedJobGroup.Name, nextCheckpoint);
         }
     }

     return await Task.FromResult(true);
 }

 (FunctionName(nameof(JobExecutionOrchestrator)))
 public async Task<bool> JobExecutionOrchestrator(
 (OrchestrationTrigger) IDurableOrchestrationContext context, ILogger logger)
 {
     var jobs = context.GetInput<List<Job>>();

     // Get all jobs
     jobs = jobs.OrderBy(i => i.SequenceNumber).ToList();

     var tasks = new List<Task<JobResult>>();

     foreach (var job in jobs)
     {           
         // Add task function to task list
         var task = context.CallActivityAsync<JobResult>(nameof(JobExecutor), job);
         tasks.Add(task);            
     }

     //
     // Wait until all jobs are done
     //
     try
     {
         await Task.WhenAll(tasks);
         foreach (var task in tasks)
         {
             var result = await task;
             if (result.Success == false)
             {
                 logger.LogError($"Remaining jobs - Failed running job {result.Job?.JobName} in job group {context.InstanceId}");
                 if (result.Job.ContinueOnFailure == false)
                 {
                     return false;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         logger.LogError(ex, $"Failed running remaining jobs in group {context.InstanceId}");
         return false;
     }

     return true;
 }

}

google sheets – IF/AND functions from multiple cells

You need to use IFS() with AND.

See the reference here:

How to Correctly Use AND, OR Functions with IFS in Google Sheets

Hi This is my code currently i.ibb.co/HTz1L0T/qsdf.png – Lloyd 14 mins
ago

As outlined by OlegS you are still using multiple = signs in your code with the wrong syntax.

His comment that you should amend it to the following seems right in my view.

=IFERROR(IFS(AND(SEARCH("Paypal",D676)>0,C676=14),"Groceries", AND(SEARCH("Paypal",D676)>0,C676=45),"Internet", AND(SEARCH("Paypal",D676)>0,C676=21),"Telephone"),"-")

r – two way repeated measures anova won’t run, returns errors that do not make sense for all 3 functions tried

I am very new to R and am trying some tutorials for two way anova online that I think should work based on my data and the example data given, however I get error messages that do not make sense to me. Any help would be appreciated. data and code below. I tried using both anova_test function from the Rstatix package and the AOV function, and the ezanova function from EZ package. My understanding of the principals are pretty shaky so I may be unaware of some limitation? code structure and data below. What am I missing?? Thank you for any help. (I apologize for the messy code, I have been trying many things for days to get this…)

tibble (57 x 5) (S3: tbl_df/tbl/data.frame)
 $ Population: chr (1:57) "S1" "S2" "S3" "S4" ...
 $ Pop_1983  : num (1:57) 3.4 7.5 10.2 5.1 4.8 54.4 9.9 6.5 38.2 56.3 ...
 $ Pop_1986  : num (1:57) 3.6 7.6 9.9 5.1 4.9 55.4 10 6.5 38.8 56.6 ...
 $ Pop_1990  : num (1:57) 3.5 7.64 9.91 5.13 4.98 ...
 $ Fertilizer: chr (1:57) "A" "A" "A" "A" ..

Code:

####5
population<-read_excel("data.file")
dfpop<-data.frame(population)
str(population)
names(dfpop)
colnames(dfpop)<-c("pop","83pop","86pop","90pop","fertilizer")
summary(dfpop)
str(dfpopcomp)
str(pop)
#compile time variables into one column
dfpopcomp <- dfpop %>% gather(key = "time", value = "Pop_measure", `83pop`, `86pop`, `90pop`)
Pop=as.factor(dfpopcomp$pop)
Time=as.factor(dfpopcomp$time)
Fertilizer=as.factor(dfpopcomp$fertilizer)
str(dfpopcomp)
#plot
ggboxplot(dfpopcomp, x = "time", y = "Pop_measure",color = "fertilizer", palette = c("#ff0000", "#0000ff","#00ff00")) #boxplot
#very high outliers?
dfpopcomp%>%group_by(time, fertilizer)%>%identify_outliers(Pop_measure)#outliers present, pops:s23,s24,s40, they are consistent outliers in all years 
#check normality
dfpopcomp %>% group_by(time, fertilizer) %>% shapiro_test(Pop_measure)
#ggqqplot(dfpopcomp,"Pop_measure", facet.by = "time")
ggqqplot(dfpopcomp, "Pop_measure", ggtheme = theme_bw()) + facet_grid(time ~ fertilizer, labeller = "label_both")
#P value indicates normality, though plots indicate some deviation from normality
#repeated measure anova
dfpopcompadj<-dfpopcomp
dfpopcompadj$pop<-as.factor(dfpopcompadj$pop)
dfpopcompadj$fertilizer<-as.factor(dfpopcompadj$fertilizer)
dfpopcompadj$time<-as.factor(dfpopcompadj$time)
str(dfpopcompadj)
# trial 1 won't run
#works but ignores fertilizer as a variable #pop.anova<-anova_test(data=dfpopcomp,dv = Pop_measure, wid=pop,within = time)
pop.anova<- anova_test(data = dfpopcompadj, dv = Pop_measure, wid = pop, within = c(fertilizer,time)) #returns 0 (non-na) cases 

is.na(dfpopcomp)#returns all false

lm(Pop_measure~time:fertilizer,data = dfpopcompadj)

#Trial 2 won't run
pop.aov<-aov(Pop_measure~time*fertilizer+Error(Pop/(time+fertilizer)),data = dfpopcompadj)
#returns model is singular

#trial 3
q5t3model<-ezANOVA(data = dfpopcompadj,dv=Pop_measure,wid = pop,within = C(fertilizer,time),detailed = TRUE,type = 2)
#returns one or more cells missing data, but they all have data

c – Naming convention for functions that mutate arguments vs creating a new object

Take the following signature

BigInt* addBigInt(BigInt* arg1, BigInt* arg2);

Traditionally, the safest way to implement this function would be for it not mutate the arguments, and would necessarily need to create a new object to result for the operation. Alternatively, if the aim is to conserve on system memory, arg1 could be the object that the resulting operation would return having mutated that object.

The question is, is there an established naming convention the would delineate the nuance between the two implementation choices? Or is this something that would need to be clearly laid out in the documentation where the developer is establishing the convention?

Let’s assume this is in C where function overloading is not possible.

measure theory – Using Egorov’s Theorem when the sequence of functions converges pointwise to infinity

I need help with the following question:

Suppose $(X, mathcal{S}, mu)$ is a measure space with $mu(X) < infty$. Suppose $f_1,f_2,dots$ is sequence of $mathcal{S}$-measurable functions from $X$ to $mathbb{R}$ such that $limlimits_{k rightarrow infty} f_k(x) = infty$ for each $x in X$. Prove that for every $epsilon > 0$, there exists a set $E in mathcal{S}$ such that $mu(X setminus E) < epsilon$ and $f_1,f_2,dots$ converges uniformly to $infty$ on $E$ (meaning that for every $t>0$, there exists $n in mathbb{Z}^+$ such that $f_k(x) > t$ for all integers $k geq n$ and all $x in E$).

I also have access to Egorov’s Theorem which states the following:

Suppose $(X,mathcal{S},mu)$ is a measure space with $mu(X)<infty$. Suppose $f_1,f_2,dots$ is a sequence of $mathcal{S}$-measurable functions from $X$ to $mathbb{R}$ that converges pointwise on $X$ to a function $f: X rightarrow mathbb{R}$. Then for every $epsilon>0$, there exists a set $E in mathcal{S}$ such that $mu(X setminus E) < epsilon$ and $f_1,f_2,dots$ converges uniformly to $f$ on $E$.

I think that the above question is just a direct application of the theorem, but that convergence to infinity messes me up a little bit. Would someone be able to help, please?