plotting – Reaching Maximum Number of Steps Using ParametricNDSolveValue with a Conditional Function

I’m trying to create a manipulatable SIR model with variable infection rate in Mathematica. To (very roughly) imitate the effect of government policies, I want the infection rate to be a certain constant if dI/dt is less than a certain value and another constant if dI/dt is above a certain value. This is what I have currently:


g1(t_) =
 If(
  i(t) < 0.2, b0, b1
  )
p1(t_) = 1;
(Beta)1(t_) = g1(t)*p1(t);


simpleSirModel1 = {
  {
   s'(t) == -(Beta)1(t)*s(t)*i(t),
   i'(t) == (Beta)1(t)* s(t) *i(t) - (Gamma)*i(t),
   r'(t) == (Gamma)*i(t)
    },
  s(0) == 1, i(0) == 0.001, r(0) == 0}
simpleSirSolution1 = 
 ParametricNDSolveValue(
  simpleSirModel1, {s, i, r}, {t, 0, 300}, {(Gamma), b0, b1}, 
  Method -> {"DiscontinuityProcessing" -> False})

Manipulate(
 Plot(Evaluate@Through(simpleSirSolution1((Gamma), b0, b1)(t)), {t, 
   0, 100}, PlotLegends -> {"S", "I", "R"}, TicksStyle -> Medium, 
  AxesLabel -> {Style("Days After 3/2", Black, FontSize -> 10), 
    Style("Fraction of Population", Black, FontSize -> 10)}, 
  PlotStyle -> {{Darker(Green), Thickness(0.005)}, {Red, 
     Thickness(0.005)}, {Magenta, Thickness(0.005)}}, 
  ImageSize -> Large, PlotRange -> {{0, 100}, {0, 1}}),
 {{b0, 0.2}, 0, 0.5},
 {{b1, 0.1}, 0, 0.5},
 {{(Gamma), 0.07}, 0, 0.5}
 )


When I execute the manipulate, I receive an error message:

ParametricNDSolveValue::mxst: Maximum number of 97466 steps reached at the point t == 46.10884123355165`.

Is there a way to increase the maximum number of steps that ParametricNDSolveValue can handle? Is this the best way to approach my problem? I’m not sure how to otherwise approach it, since the function (Beta)1(t) changes value depending on the system it’s in.

plugins – Calling PHP function with AJAX

I am creating a plugin for wordpress for the backend.
I when the admin press a button a js function is being called. In this js function, I am calling an API, and then I want to call a PHP with the result and the order id as a parms.
so I have done this:
action.php

function openpopup($order_id)
{
  

    ?>  
    <button id="shipping360_create_delivery" data-id= "<?php echo $order_id?>" 
            style="background-color: #2e4453; color:#fff; border-radius: 5px;text-align: center;width:100px;height:auto;font-size:10px; line-height: 1.5em;  border: none;-webkit-appearance: none; outline: none; padding:10px;cursor: pointer;">create</button>
    <?php
            popup($order_id);

   
}


add_action('wp_ajax_update_order', 'update_order');


function update_order()
{    


    $order_id = isset($_POST('id')) ? $_POST('id') : 0;
    $shipping_number = isset($_POST('shipping_num')) ? $_POST('shipping_num') : "";
    $order = wc_get_order($order_id);

    update_post_meta($order_id, 'shipping_number', $shipping_number);
    $order->add_order_note($shipping_number);
    die();


}

the popup function opens a pop-up with the order details.
inside the popup function I have a button with the id “create_order” (this function has a lot of HTML and doesn’t really matter – the point is the button).
Now for the app.js file

(function ($) {
 $(document).ready(function () {
        $('#close').click(function () {
//this is closing the pop-up
            document.body.style = "overflow: scroll";

            $('#order-model').hide();
        });
        $("#createorder").click(function () {
/// this is the call for the main function 
            createDelivery();
        });

        $("#shipping360_create_delivery").click(function () {
// this is opening the pop-up
            $('#order-model').show();
            document.body.style = "overflow: hidden;margin: 0;";

        })
    })
}(jQuery)); 



function createDelivery() {
    // creates new delivery

    const URL = BASE + "/shipping";

    const distributor = document.getElementById("distributor").value;
    const token = document.getElementById("ordertoken").innerHTML;
    const companyid = document.getElementById("ordercompanyid").innerHTML;
    const direction = "1";
    const type = document.getElementById("ordertype").innerHTML;
    const order_id = document.getElementById("ordernumber").innerHTML;

    if (distributor == "") {
        alert("Please fill all fields")
    }

    else {
        senderinfo = "";//have data -- does not really matte
        receiverinfo = ""; // have data -- does not really matter
        const Data = {
            senderinfo: senderinfo,
            receiverinfo: receiverinfo,
            type: type,
            distributor: distributor,
            companyid: companyid,
            token: token,
            direction: direction
        }
        const otherPram = {
            headers: { "Content-Type": "application/json; charset=UTF-8" },
            body: JSON.stringify(Data),
            method: 'POST'
        };
        console.log(URL)
        fetch(URL, otherPram)
            .then(data => {
                return data.json()
            })
            .then(res => {
                body = res("body");
//////////////////-----------------------///////////////////////////////
up to this point everything is working fine
                (function ($) {
                    $.ajax({
                        type: "POST",
                        url: ajaxurl,
                        cache: false,
                        data: {
                            'action': 'update_order',
                            'id': order_id,
                            'shipping_num': body,
                        },
                        success: function (response) {
                            location.reload();
                            alert(response);

// not popping up
                        },
                        fail: function () {
                            alert("helllo");

// I have put this and the one below just for checking 
// not popping up
                        },
                        complete: function () {
                            alert("hiii")
// when I call my function this is that only on the pops up
                        }
                    });
                })(jQuery);


            }).catch(function (error) {
                alert("Got an error:", error);


            });


    }

}





Thanks for the help

c# – How to properly visualize Physics2D.CircleCast function in Unity?

I have a Physics2D.CircleCast() function in order to set true or false if the character is on the ground.

Based on this function, I want to draw a circle, mostly for debugging. I think this method could be quite useful to understand distances between different objects. such as between the character and the platform. The following image shows the variable set to true when the character is on the ground.

enter image description here

In order to draw the circle, my approach was to create an empty object with a Line Renderer component. Then, I created the following script (removing the section in which variables were declared):

public class DrawCircleCast : MonoBehaviour
{
    // Call Game Object
    public GameObject player;
    
    // Start is called before the first frame update
    void Start()
    {
        sizeValue = (2.0f * Mathf.PI) / 0.01f;
        size = (int)sizeValue;
        size++;

        lr = GetComponent<LineRenderer>();

        lr.material = new Material(Shader.Find("Standard"));
        lr.material.color = Color.cyan;
        lr.startWidth = 0.03f;
        lr.endWidth = 0.03f;
        lr.positionCount = size;
    }

    // Update is called once per frame
    void Update()
    {
        DrawCircle();
    }

    void DrawCircle()
    {
        playerPosition = player.transform.position;
        transform.position = playerPosition;
        radius = player.GetComponent<Player>().shapeRadius; // which is 1f

        theta = 0f;
        thetaScale = 0.01f;

        for (int i = 0; i < size; i++)
        {
            theta += (2.0f * Mathf.PI * thetaScale);
            x = radius * Mathf.Cos(theta);
            y = radius * Mathf.Sin(theta);
            
            x += gameObject.transform.position.x;
            y += gameObject.transform.position.y;

            pos = new Vector3(x, y, 0);
            lr.SetPosition(i, pos);
        }
    }
}

This piece of code creates a circle around the character, as follows:

enter image description here

So, my next approach consisted on change the circle’s position from the character to around the CircleCast measure, in order to have a better position. So I added new variables to the function and changed the circle’s position:

void DrawCircle()
{
    playerPosition = player.transform.position;
    platformPosition = platform.transform.position;

    X = playerPosition.x;
    Y = (playerPosition.y + (platformPosition.y)) / 2;
    
    transform.position = new Vector3(X, Y, 0);
    radius = player.GetComponent<Player>().shapeRadius;

    theta = 0f;
    thetaScale = 0.01f;

    for (int i = 0; i < size; i++)
    {
        theta += (2.0f * Mathf.PI * thetaScale);
        x = radius * Mathf.Cos(theta);
        y = radius * Mathf.Sin(theta);
        
        x += gameObject.transform.position.x;
        y += gameObject.transform.position.y;

        pos = new Vector3(x, y, 0);
        lr.SetPosition(i, pos);
    }
}

The result changed as follows:

enter image description here

Although the circle’s position is now located around the CircleCast measure, I am missing the distance value that I also added to the Physics2D.CircleCast() function.

So my question is how can I improve the circle’s position to have a better sense of how CircleCast is measuring the distance between two objects (i.e. character and platform). I couldn’t relate the distance, which is a parameter of the Physics2D.CircleCast() function, to the values I used to draw the circle. How the distance affects CircleCast() and how can I use this value to improve the circle’s position.

Any ideas would be appreciated. Thanks in advance for your support!

real analysis – Prove the existence of local minimum of a multi-variable absolute value function.

I have the following function
$$H(mathbf{x}) = a_{1}|x_{1}-A_{1}|+a_{2}|x_{2}-A_{2}|+cdots+a_{n}|x_{n}-A_{n}|
+b_{1}|x_{1}-B_{1}|+b_{2}|x_{2}-B_{2}|+cdots+a_{n}|x_{n}-B_{n}|
+c_{1}|x_{1}-x_{0}|+c_{2}|x_{2}-x_{1}|+cdots+c_{n}|x_{n}-x_{n-1}|+c_{n+1}|x_{n+1}-x_{n}|$$

where all coefficients are positive.

For two dimensional case, I can plot $$H(x_{1},x_{2}) = a_{1}|x_{1}-A_{1}|+a_{2}|x_{2}-A_{2}|
+b_{1}|x_{1}-B_{1}|+b_{2}|x_{2}-B_{2}|
+c_{1}|x_{1}-x_{0}|+c_{2}|x_{2}-x_{1}|+c_{3}|x_{3}-x_{2}|$$

and it indeed has only one minimum,

enter image description here

However, I cannot prove it in a more general case. Does anyone once had encountered such problems?

Viewing Old iOS App Function

I have an old photo editing 32-bit iOS app from around 2013/14. It no longer works on iOS since the transition to 64-bit but I wondered if there was a way to look into the apps code to discover some of the photo editing settings? There’s a few photo filters I would love to replicate in Photoshop.

research – Relationship between the prime counting function of some number and the sum of prime numbers less than the square root of that number

A little bit more than a year ago I was able to prove that the sum of the prime numbers less than the square root of some number was asymptotically equivalent to the number of primes up that number (see http://vixra.org/abs/1911.0316).

In this same pre-print, I studied the numbers for which the number of prime numbers up to some number was exactly equal to the sum of the prime numbers less than the square root of that number. As a result, I derived the set of prime numbers that you can see here (http://oeis.org/A329403) and conjectured that there existed infinitely many of such prime numbers. This would imply that the value of the prime counting function of a given number would be infinitely often equal to the sum of prime numbers up to the square root of that number, and in other cases the sum described would be a very good estimator of the prime counting function.

A little bit more than a year after, I am unable to prove or disprove this conjecture. Unfortunately, as an amateur mathematician I feel uncapable of bringing this interesting research further, but it would be great if someone were able to prove or disprove the conjecture.

I find the relationship exposed between sums of prime numbers and the prime counting function really appealling and misterious, and I feel that there might be some hidden and profound mathematics there that I am not able to grasp.

I would like to hear your thoughts and ideas (if any) of how to bring the research to a happy ending. Thanks in advance for your time and effort!

matrix – Function representing a forest fire after one time step

How can I create a function that would have as its argument an array mat of 0s, 1s, and 2s where the 2s are burning trees and the function would give an array that represents the forest after one time step?

I have tried using

mat=RandomChoice[{0,1,2},{10,10}]
nextstep[mat_]:=Sequence[mat2 + {1, 0}, mat2 + {0, 1}, mat2 + {-1, 0}, mat2 + {0,-1}]

but that doesn’t seem to work. After one time step, every tree, represented by 1s, that is in the von Neumann neighborhood of a burning tree would catch fire, but the 0s, which means there are no trees, would remain the same.

Problems in plotting a function of two variables

Clear("Global`*")

a = Re(Sqrt(x^2 - 2 x y + y^2 - 1^2));

You cannot take the derivative of a function which contains Re. Use ComplexExpand to avoid use of Re

mat = {{0, -a/Sqrt((x - y)^2 + Abs(a)^2)}, {(x - y)/
       Sqrt((x - y)^2 + Abs(a)^2), 0}} // 
    ComplexExpand(#, TargetFunctions -> {Re, Im}) & // Simplify;

d1 = D(mat, x);
d2 = Simplify(mat . d1, {x >= 0, y >= 0});
fun(x_, y_) = Simplify(
   Tr(d1 . d1) + (1/Det(mat)) Tr(d2 . d2),
   {x >= 0, y >= 0});

Plot3D(
  fun(x, y), {x, 0, 5}, {y, 0, 5},
  PlotPoints -> 75,
  MaxRecursion -> 5,
  ClippingStyle -> None) // Quiet

enter image description here