calculus and analysis – Why so big difference between results of Integrate and NIntegrate?

Studying an interesting article of Daniel Lichtblau, I consider a variation of an example from it, calculating an improper integral

Integrate(RealAbs(Sin(x - y))^(-2/3), {x, 0, Pi}, {y, 0, Pi})

-((12 Sqrt((Pi)) Gamma(-(1/3)) HypergeometricPFQ({1/6, 1/2, 2/3}, {7/6, 7/6}, 1))/ Gamma(1/6))

This is not very useful analytic expression, so



Then I compare that result with the numeric one

NIntegrate(RealAbs(Sin(x - y))^(-2/3), {x, 0, Pi}, {y, 0, Pi}, 
Exclusions -> {y == x}, AccuracyGoal -> 3, PrecisionGoal -> 3)


The latest result is produced without any warning. How to explain so big difference between the numbers? Could this difference be decreased? Which result is more reliable?

wp query – Getting list of categories that have posts in search results

Looking for a solution for the following problem.

I am trying to create a list of categories that contain posts in a results page. Ideally this would also contain a post count.

Up to this point I would run a query using 'post_per_page'=>-1', 'fields'->'ids' only, then using a loop I would use the get_the_category(), get_ancestors() and populate an array along with counts. Up to recently this used to be working nicely, however, the website is growing a lot larger by the day, so this is not feasible any more since it takes a lot of time. I knew in the beginning that at some point this would come to a stall, however, this came earlier than I was expecting.

From what I realized, using the whole WP_Object for each post is too heavy for the server if the results exceed 2k in count, but on the other hand only using 'fields->'ids' forces me to use loops – which is also heavy.

One solution I ended up with, is limiting results to the first 1000, but obviously this would mean, that the counts in the categories will not be accurate, and some categories might be left out, if they exist in results that exist after the first thousand.

I am willing to sacrifice the counts as long as I am able to populate a complete category list.

Has anyone done anything similar? Looking forward to your replies.

logic – Intermediate results from SatisfiabilityInstances

I have a large logical expression, with roughly 100 boolean variables. I am interested in the solution with the smallest numbers of True. It seems there is no such option, thus I use SatisfiabilityInstances, searching for a large number of instances:

sf = SatisfiabilityInstances(FinalExpression, BooleanVariables(FinalExpression), 100000, Method -> "SAT");

Afterwards, I search manually for the instance with the smallest number of True.

Question1: Is there a way to obtain the solution with smallest number of True in a more efficient way?

Question2: Is there a way to monitor the intermediate results of SatisfiabilityInstances? For instance, that it periodically prints how many solutions its already found (and its truth values)

forms – PHP Code Not Generating Results

I wanted to create a calculator on my WordPress website.

But, my code is not generating results on the page after the form Submission.

Please help,
Thank you


<form method="post" >
<label for="fname">Value</label>
<input id="value" name="inp1" type="number" value="" />
<label for="lname">Result</label>
<input type="submit" name="button1" value="Calculate" />


            function fact($x)
                                for ($i=$x; $i>0; $i--)
                                echo "Factorial of the number is $fact";

            {echo "Enter the number";}

PHP issue passing results of variables from one function to another in same file but works on other pages

I am having an issue accessing my global variables inside the same file where the variables exist. However, they work just fine when I call the same variable in other files. To call the variable in another file I have used the required_once to call my file where the globals are located and then called each variable I need individually like global $example_vairable.

The issue is that when I use global $example_vairable later on in the same file where I defined global $example_vairable it does not work. Inside of another function on the same page I have called my variable global $example_vairable and then just tested with either an echo or a var_dump. echo shows no display and var_dump provides a bool(false) telling me I have an error but I have no idea where or why.

This is in wordpress so I am using my functions file where my variables are located. Here is my code:


function Total_Result(){
    global $total_result, $resultx;

     $resultxs = array($resultx);
     $total_result =  count($resultxs(0));
add_action( 'after_setup_theme', 'Total_Result' );

Then the function on the same file (functions.php) that I am trying to call the global from:

add_action("wp_ajax_getvendorresponsestatus", "getvendorresponsestatus");
add_action("wp_ajax_nopriv_getvendorresponsestatus", "getvendorresponsestatus");

function getvendorresponsestatus() {
    global $wpdb, $endResult,$total_result ;
    if(isset($_POST('action')) == 'getvendorresponsestatus'){

                    echo $total_result;
            echo $endResult->posted_by;


I have also tried to pass the variable in the function itself but it too doesnt work.

add_action("wp_ajax_getvendorresponsestatus", "getvendorresponsestatus");
add_action("wp_ajax_nopriv_getvendorresponsestatus", "getvendorresponsestatus");

function getvendorresponsestatus($endResult, $total_result) {
    global $wpdb;
    if(isset($_POST('action')) == 'getvendorresponsestatus'){

                    echo $total_result;
            echo $endResult->posted_by;


posts – Override search results sort order conditionally

I’m new to WordPress Development. I have a client I’m working with that uses a third-party plugin to curate search results (ElasticPress), however, they are looking for additional buttons on the search results page to sort everything by either name or date posted.

I’ve found a lot of answers on this topic that apply an action/filter to each query in functions.php… But I’m wondering how I can mimic that behavior without overriding all search queries. I just want that behavior if they press the sort button on the search results page, but everything else to use their custom search functionality.

How can I apply an action/filter conditionally on button press to do that? Any guidance is appreciated

How to output results of an AppleScript image resizing script and display in automator

I am currently using an automator flow that copies finder items, changes them to jpeg, reveals them, and then runs an applescript that presents a dialog for batch resizing by image width. Every now and then, the script misses a couple of files or I prematurely move them from the folder before they have finished. I added a couple of pieces to the automation to

  1. Set value of variable: output
  2. Ask for confirmation: output

This doesn’t really output anything useful, but it does notify me when the script has finished running. Is there some way to output whether or not there were any issues with the script or is this way too crazy of a question to be asking on stackexchange? In advance… No, I’m not very familiar with AppleScript.

Here’s the script – I appreciate any & all advice/help 🙂

tell application "System Events"
    set theWidth to display dialog "Enter the width" default answer "2000"
    set theWidth to the text returned of theWidth as real
end tell
global theWidth
tell application "Finder"
    set some_items to selection as list
    repeat with aItem in some_items
        set contents of aItem to aItem as alias
    end repeat
end tell
repeat with i in some_items
    end try
end repeat

to rescale_and_save(this_item)
    tell application "Image Events"
        set the target_width to theWidth
        -- open the image file
        set this_image to open this_item
        set typ to this_image's file type
        copy dimensions of this_image to {current_width, current_height}
        if current_width is greater than target_width then
            if current_width is greater than current_height then
                scale this_image to size target_width
                -- figure out new height
                -- y2 = (y1 * x2) / x1
                set the new_height to (current_height * target_width) / current_width
                scale this_image to size new_height
            end if
        end if
        tell application "Finder"
            set file_name to name of this_item
            set file_location to (container of this_item as string)
            set new_item to (file_location & file_name)
            save this_image in new_item as typ
        end tell
    end tell
end rescale_and_save

How to handle efficiently notifications for query searches results changes in elasticsearch?

Each user could save preferred queries. They want to be notified when one item that is the result of these queries is created or updated.
A naive solution would be to execute each queries and check if the updated or created item is contained in the result.
Is there a better way to perform this task ?

sharepoint online – How do I error handle a REST API call with no results?

I have a PowerQuery function o retrieve the contents of a SharePoint list.

    Source = (url as any) => 
        aSource = OData.Feed(url, null, (Implementation="2.0")),

But sometimes the list doesn’t exist, and OData REST API calls don’t seem to have a nice set of HTTP type response codes. The code bombs out with a msg

OData version 3 and 4 Error The server returned an error: (404) Not found. (List 'ABC' does not exist at site ......)

But if I paste the URL into a browser, I get a XML response, with no HTTP error codes.

Modern PnP Search Box Refreshes Search Results Page 2-4 times

I have a PnP Modern v4 Search Bar on the homepage. I’m using the Method = Query string parameter and Parameter name = q (and tried k).

When I search, it redirects to my custom search page with Modern Search Results web part. The results are filtered based on my search query from before.

The problem is it loads the page initially and then reloads the page 2-4 more times. If use the Search Box on the custom search page and do a search, it doesn’t reload the page like from the homepage. Seems like the only difference I see is that from the homepage, I send to a custom page whereas from the custom search page, I stay on the page.