Substitution in delayed evaluation function

I try to do the following: precompute an expression and then make a function of it. The evaluation must be delayed because some parameters are known only when the function is called. A simplified example (the real expression is much more complex) is:

expr=x^2+y^2
test(y_):=FindMinimum(expr,{x,1})

What we get:

test(3)
FindMinimum::nrlnum: The function value {1.41421,1.41421 y} is not a list of real numbers with dimensions {2} at {x} = {1.}.
FindMinimum(expression, {x, 1})

What I expected is

test(3)
{9,x->0}

When I remove the delayed evaluation, I try to execute it FindMinimum immediately and fails. Usually, Evaluate works, but not here. If I use both of them instant assignment = and Evaluatetry to minimize it before too y is ready.

There are many threads to this SE that almost work, but not for FindMinimum, I tried With. Block and other. If I missed the right answer, please point it out.

It seems that this way of converting expressions into functions should be easy. I usually resort to copying and pasting expressions into functions, which is cumbersome and can lead to many errors when expressions are recalculated and the change needs to be postponed.

Proofing – How to prove the function of a recursive big theta without using repeated substitution, mastering the sentence, or having the closed form?

I have defined a function: $ V (j, k) $ Where $ j, k in mathbb {N} $ and $ t> 0 in mathbb {N} $ and $ 1 leq q leq j – 1 $, Note $ mathbb {N} $ includes $ 0 $,

$ V (j, k) = begin {cases} tj & k leq 2 tk & j leq 2 tjk + V (q, k / 2) + T (j – q, k / 2) & j , k> 2 end {cases} $

I am not allowed to use repeated substitution and I want to prove this by induction. I can not use the main clause because the recursive part is not in that form. Any ideas how I can solve it with given limitations?

When I start induction: I fix $ j, q $ and introduce $ k $, Then the base case $ k = 0 $, Then $ V (j, 0) = tj $, The question indicated that the function may be $ Theta (jk) $ or maybe $ Theta (j ^ 2k ^ 2) $ (but it does not necessarily have to be either).

I choose $ Theta (j, k) $, In the base case, this would mean that I had to prove that $ tj = theta (j, k) $ when $ j = 0 $, But if I start with the big-oh, I have to show it $ km leq mn = m cdot0 = 0 $ which I currently do not think possible.

I am not sure if I did the basic case wrong or if there is another approach.

Proving techniques – How to prove the function of a recursive Big-Oh without using repeated substitution, master phrase or closed form?

I have a function as defined $ V (j, k) $ with two base cases with $ j, k $ and the recursive part has an additional variable $ q $ which it also uses. Also, $ 1 leq q leq j – 1 $, The recursive part has the form: $$ jk + V (q, k / 2) + V (j – q, k / 2) $$I am not allowed to use repeated substitution and I want to prove this by induction. I can not use the main clause because the recursive part is not in that form. Any ideas how I can solve it with given limitations?

Programming Languages ​​- Confused about the substitution in grammar in certain cases

To illustrate my confusion, let us say that I have received this unique grammar in BNF:

         S ::= T O x
         T ::= empty
         T ::= "if" E "then" T x "else" T
         O ::= empty
         O ::= "if" E "then" T O

Here is the corresponding derivation tree:

                                         S
                     ____________________|______________________
                    /                    |                      
                   T                     O                       x
                   |         ____________|_________________
                     / |  |             |           
                           if E then           T            O
                                       ________|_______     |
                                      / |  |   | |  |   
                                     if E then T x else T
                                               |        |
                                              

Why could not we have that?

                                         S
                     ____________________|______________________
                    /                    |                      
                   T                     O                       x
                   |         ____________|_________________
                     / |  |             |           
                           if E then           T            O
                                       ________|_______     |
                                      / |  |   | |  |   
                                     if E then T x else T
                                               |        |
                                       ________|_______ 
                                      / |  |   | |  |   
                                     if E then T x else T  

Why is the first T. Which rules determine how you replace the definitions in the chart.

java – Nested variable substitution in Spring Boot configuration files

I need to get a property with the following format:

${/a/env/mode}

However, this depends on where implemented. I already have all the required information in the configuration and try to use:

${/a/${env}/${mode}}

This does not work as expected in Spring Boot, but there is one exception. Is there anyway what I need?

Variable substitution as usual in math

So … I'm trying to simplify equations with my own variables, but the experiments I've made have not led to what I wanted.

The problem: I have defined 2 variables as:


x = (z(1, 2) z(3, 4))/(z(1, 3) z(2, 4))

k = (z(1, 3) z(2, 4))/(z(1, 2) z(2, 3) z(3, 4) z(4, 1))

From where


z(a_,b_) := z(a) - z(b)

And I try the result:


k = 1/(x z(2,3)z(4,1))


My experiments:


Simplify(Eliminate({k == (
    z(1, 3) z(2, 4))/(z(1, 2) z(2, 3) z(3, 4) z(4, 1)), 
   x == (z(1, 2) z(3, 4))/(z(1, 3) z(2, 4))}, {z(1, 2), z(2, 4), 
   z(3, 4), z(1, 3)}))

and


k /. (z(1, 2) z(3, 4))/(z(1, 3) z(2, 4)) -> x (* into this one I only defined k before*)

I searched and stuff, but either I got something that I've already tried, or something incredibly hard. So I do not know if I did something wrong or if it's really difficult to get substitutions.

18.04 – Diagnosis # sh: 1: Bad Substitution & # 39; from / bin / sh -exc

I've tried to compile some ocaml packages and continue to run on some bugs in the form sh: 1: Bad substitution (Exit code 2), z.

/bin/sh -exc echo | m4
/bin/sh: 1: Bad substitution

But, /bin/sh -ec echo | m4 has no mistake. It seems that every command with both -e and -x Flags went up /bin/sh (/ bin / sh: symbolic link to hyphen) leads to this error. Is this the expected behavior, because I can not see anything in the manual in this sense and I can not remember that this has ever happened before.

EDIT: actually I do not see the error at any one /bin/sh -xc Command, regardless of -e

Ubuntu 18.04

Hard disk – HFS + damaged partition recovery with file substitution

First of all, I would like to give some background information that may help to understand the situation better.

I used 1 TB external drive for data storage and then installed it in Optibay to use it as the second drive in the MacBook. It was formatted as 900GB NTFS and 100GB HFSJ + partition. It was easier to work with HFS on MacOS, and I used Paragon Hard Disk Manager to extend the HFS partition to a size of 900 GB and downsize NTFS to 100 GB. This was done through sequential 200 GB expansion / shrink operations, where data was moved from NTFS to HFS to get to final state. From now on, the hard disk worked perfectly with this partition table. SMART was fine.

But eventually the hard drive stopped spinning, but it was still identified as a zero-sized hard drive (so only the controller was identified, as is common for Seagate hard drives). A controller error has occurred (the ROM was corrupted). After repairing the ROM, an almost complete RAW image of the disk could be created. In addition, two heads did not work properly, so some areas could not be read. The status of the SMART C5 unstable sector had a BAD value, so these sectors are likely to be faulty software / hardware blocks.
From this point on I started the data recovery. Two partitions were damaged in a very strange way. I'm mainly interested in restoring HFS partitions because almost all data was stored here.

Of course, fsck-hfs / DiskWarrior could not recover data because the catalog file / B-tree was addressing incorrect locations of the files. Volume header was valid. I used HFS + Rescue to display the file list. After analyzing this spreadsheet, I noticed that all the file positions in that table were offset, but the offset varied from the beginning to the end of the hard disk. For example, file entries 53130-55315 are offset by 100153225216 bytes from the beginning of the HFS partition, and file entries 3719-4446 are offset by 100223311872 bytes. The offsets do not follow the ascending order from the beginning to the end of the partition. Some groups are moved more from the beginning, others less. The offset range I found was 97120280576 – 100148092928. More than 3 GB difference! So I can restore these files as long as I calculate the offset of the particular fileset. But eventually this offset shifts, so I can not restore the file because I need to look for the new offset.

I also found that although most file sizes and data are correct, a significant amount of .MOV files is not full, their sizes will be cut 16384 bytes before the end. Even then, with the valid header and footer, I could not open them as .MOV files. Other files are valid so far. And I also noticed that sometimes there is an offset shift after this damaged .MOV file (usually larger than 2GB).

Has anyone encountered the similar problem? Is there any software that can find and fix the problem? What software can you recommend to work with damaged HFS partitions. What could possibly cause this offset shift? What can damage both partitions if the header of the catalog file / volume is valid? And is there a tool that speeds up finding offsets and restoring files when it's not possible to restore the correct offsets?

Question about Trig substitution

I was asked to rate $ displaystyle int frac {1} {x ^ 2 sqrt {1-x ^ 2}} text {d} x $

Here is my attempt:

$ text {Let $ x = sin ( theta) $} $

$ text {Then} text {d} x = cos ( theta) text {d} theta $
$$ int frac {1} { sin ^ 2 ( theta) sin ( theta)} cos ( theta) text {d} theta $$
$$ int cos ( theta) sin ^ {- 3} ( theta) text {d} theta $$
$ text {Let $ u = sin ( theta) $} $

$ text {Then $ text {d} u / cos ( theta) = text {d} x $} $
$$ int u ^ {- 3} text {d} u $$
$$ – frac {1} {2} u ^ {- 2} $$
$$ – frac {1} {2 sin ^ 2 ( theta)} $$
$$ – frac {1} {2x ^ 2} + C $$

But the book says:

$$ – frac { sqrt {1-x ^ 2}} {x} $$

Where is the mistake in my reasoning? Many thanks.