C_R

3577 Reputation

21 Badges

6 years, 96 days

MaplePrimes Activity


These are replies submitted by C_R

I found a way with simplify which factors the units out of the inner integral and the warning disapears

with(Physics)

diff(x(t), `$`(t, 2)) = a(t)

diff(diff(x(t), t), t) = a(t)

(1)

dsolve(diff(diff(x(t), t), t) = a(t), arbitraryconstants = subscripted)

x(t) = Int(Int(a(t), t), t)+c__1*t+c__2

(2)

a(t) = 1.*Unit('m'/'s'^2), c__1 = 2*Unit('m'/'s'), c__2 = 3*Unit('m')

a(t) = 1.*Units:-Unit(m/s^2), c__1 = 2*Units:-Unit(m/s), c__2 = 3*Units:-Unit(m)

(3)

subs(a(t) = 1.*Units:-Unit(m/s^2), c__1 = 2*Units:-Unit(m/s), c__2 = 3*Units:-Unit(m), x(t) = Int(Int(a(t), t), t)+c__1*t+c__2)

x(t) = Int(Int(1.*Units:-Unit(m/s^2), t), t)+2*Units:-Unit(m/s)*t+3*Units:-Unit(m)

(4)

value(%)

x(t) = (1/2)*t^2*Units:-Unit(m/s^2)+2*Units:-Unit(m/s)*t+3*Units:-Unit(m)

(5)

simplify(x(t) = Int(Int(1.*Units:-Unit(m/s^2), t), t)+2*Units:-Unit(m/s)*t+3*Units:-Unit(m))

x(t) = Units:-Unit(m/s^2)*(Int(Int(1, t), t))+2*Units:-Unit(m/s)*t+3*Units:-Unit(m)

(6)

value(x(t) = Units:-Unit(m/s^2)*(Int(Int(1, t), t))+2*Units:-Unit(m/s)*t+3*Units:-Unit(m))

x(t) = (1/2)*t^2*Units:-Unit(m/s^2)+2*Units:-Unit(m/s)*t+3*Units:-Unit(m)

(7)

NULL

``


 

Download Unit_of_t-2.mw

@Jankel 

The one bellow is from a Windows installation version 2022.2 (on a 4K display at 250% scaling on a 15.6 display).

Java in combination with making Maple available on three operating systems could be a reason why rendering it not always the same in all possible combinations of hard and software. Other potential candidates to look at are, compatabilty settings (properties of Maple executable), graphics cards (type and settings) and font scaling in the operating system.

Under Windows I see other rendering issues which appear when changing displays while Maple is running (you see it bellow: + button are larger than in your screen shot and the question mark does not render well). Program restart is sometimes required and in some rare cases even a system restart. With newer Windows versions the situation has substantially improved.

On my machine it does not look like a font scaling issue (I testesd it also with 125% on a larger display) but I wanted to make you aware on other sublte changes in rendering that could give you a hint under which conditions changes in font rendering happens.

 

@zenterix 

If sinc(x)=sin(x)/x was transcendental you should have gotten at least one answer.

I have checked help(solve, detail) and I am not so sure any more about Maple retruning no Output. At least one solution should have been returned according to:

The solve command returns all solutions for polynomial equations. In general for transcendental equations, the solve command returns only one solution, but does not set _SolutionsMayBeLost to true. To force the solve command to return the entire set of solutions for all inverse transcendental functions, provide the solve option allsolutions = true or set the environment variable _EnvAllSolutions := true.

@zenterix 

I can only guess that allsolution is not needed in most cases (I don't use it by default). Take phi=arctan(y,x) as another expamle for a solution. Most users would probably prefer it instead of the general solution

There is allways room for improvement. The fact that Maple did not return anything in your example even though there are solutions is debatable. It would be nice to distinguish from a user perspective between no solution and too many when Maple produces no Output.

I have to admit: By convenience I did use the context panel (plus right click show command) to find the appropriate solve command for sin(x)/x.  This was pretty user friendly.

@Carl Love @acer

Sorry, I did not get a notification for your replies and only could check for answers today.

Physics:-Version() gives:

`The "Physics Updates" version in the MapleCloud is 1343 and is the same as the version installed in this computer, created 2022, November 2, 11:29 hours Pacific Time.`

Interestingly, a parameter set with units in a simliar example from @ecterrab on equation(6) worked

@WhiteNoise 

I thought converting your working Heaviside version to piecewise might give a clue what must be changed in the piecewise definition to make it work. As you can see it’s not working either. Converting this back to Heaviside gives an expression that does not evaluate at all because of the now appearing units in the Heaviside function.

Could you elaborate why Heaviside is not an option in the general case? I think this forum can help you with a solution that converts a general piecewise case to a Heaviside solution with dimensionless arguments.

You should contact support if no one else can help. Piecewise with units should work.  

restart

 

Definition of current functions with units

"`i__1`(t):=Heaviside(t/(⟦s⟧)-0.01)*3⟦A⟧*cos((2*Pi*t)/(T));"

proc (t) options operator, arrow, function_assign; 3*Heaviside(t/Unit('s')-0.1e-1)*Unit('A')*cos(2*Pi*t/T) end proc

(1)

convert(i__1(t), piecewise, t)

piecewise(t < 0.1e-1*Units:-Unit(s), 0, t = 0.1e-1*Units:-Unit(s), Float(undefined)*Units:-Unit(A), 0.1e-1*Units:-Unit(s) < t, 3*Units:-Unit(A)*cos(314.1592654*t/Units:-Unit(s)))

(2)

convert(piecewise(t < 0.1e-1*Units:-Unit(s), 0, t = 0.1e-1*Units:-Unit(s), Float(undefined)*Units:-Unit(A), 0.1e-1*Units:-Unit(s) < t, 3*Units:-Unit(A)*cos(314.1592654*t/Units:-Unit(s))), Heaviside)

Float(undefined)*Units:-Unit(A)*Dirac(t-0.1e-1*Units:-Unit(s))-3*Units:-Unit(A)*cos(314.1592654*t/Units:-Unit(s))*Heaviside(t-0.1e-1*Units:-Unit(s))*Dirac(t-0.1e-1*Units:-Unit(s))+3*Units:-Unit(A)*cos(314.1592654*t/Units:-Unit(s))*Heaviside(t-0.1e-1*Units:-Unit(s))

(3)

`i__11`(t):=piecewise(t < 0.01*Unit('s'), 0, t = 0.01*Unit('s'), 3*cos(314.1592654*t/Unit('s'))*Unit('A'), 0.01*Unit('s') < t, 3*cos(314.1592654*t/Unit('s'))*Unit('A'))

"i[`11`](t):={[[0,t<0.01 &lobrk;s&robrk;],[3 cos((314.1592654 t)/&lobrk;s&robrk;) &lobrk;A&robrk;,t=0.01 &lobrk;s&robrk;],[3 cos((314.1592654 t)/&lobrk;s&robrk;) &lobrk;A&robrk;,0.01 &lobrk;s&robrk;<t]]"

(4)

T := 0.2e-1*Unit('s')

RMS__11 := sqrt((int(i__11(t)^2, t = 0 .. T))/T)

Error, (in Tools:-IntegrateExpression) units problem, can't make expression piecewise(t < .1e-1*Units:-Unit(s),0,t = .1e-1*Units:-Unit(s),3*Units:-Unit(A)*cos(314.1592654*t/Units:-Unit(s)),.1e-1*Units:-Unit(s) < t,3*Units:-Unit(A)*cos(314.1592654*t/Units:-Unit(s)))^2 unit-free with units [t::Units:-Unit(s)]

 

RMS__1 := sqrt((int(i__1(t)^2, t = 0 .. T))/T)

1.500000000*(Units:-Unit(A^2*s)/Units:-Unit(s))^(1/2)

(5)

NULL


 

Download UnitProblemSecondVersion-_convert_piecewise.mw

@acer 

Best: better than a sequence of two commands (or your nested version). I was hoping for a single command.

Improve in the sense to include the case sqrt(m*something)/m^-1 when combine,radical,symbolic is called (altough I try to avoid the symbolic option).

Thumbs up for including the m>0 as a relation for solve instead of adding an assumption to the command (what I tried)! This makes totally sense. I will leave the question open why the assume facilty does not do it automatically. I assume that there will be too many exceptions to deal with in the R^n space.

Many thanks!

@ecterrab 

Very nice feature! Is it possible to make it work with ODESteps?

arbconst_with_ODESteps.mw

@Carl Love 

I wrote an addendum under my reply  "No ranges or assumptions".

I hope that fixes my hasty deletion.

@Carl Love 

Thank you for clarifiying. I overlooked the extra dot. I will delete my reply. There is nothing to investigate.

@jediknight 

I cannot fully reproduce the output of your code snippets (see attached). Consider the upload option (green arrow in the editor if you hit reply) if you want others reproduce what you observe.
Have you tried using maximize without ranges or appropriate assumptions? It might work with your version.

maximize seems to have troubles with the expression of GainQ1 in combination with the ranges you provided also in Maple 22

snippets_recap.mw

Update (after deletion of reply):

Maximize has no troubles. It correctly calculated Top_of_Q1 for degenrated ranges.
The deleted file with my wrong interpretation of the ranges from my side for completeness  maximize_wrong_maximum.mw
 

@jediknight
This assignment is causing the problem wx:=solve(GainQ1=Top_of_Q1);

Each time you execute this line

     Top_of_Q1:=eval(maximize(GainQ1),wx=0.1..2);wx:=solve(GainQ1=Top_of_Q1);

GainQ1 changes. This changes Top_of_Q1 which changes wx. And so on...

Here is an alternative way Maple offers without assignments (i.e. `:=`), where you get an equation for wx(Top_of_Q1). Using this way you will hardly run into errors related to unintened assignments.

 

GainQ1 = 8*wx^2*(m-1)/(Pi^2*sqrt((m*wx^2-1)^2+Q1^2*wx^2*(wx^2-1)^2*(m-1)^2))

GainQ1 = 8*wx^2*(m-1)/(Pi^2*((m*wx^2-1)^2+Q1^2*wx^2*(wx^2-1)^2*(m-1)^2)^(1/2))

(1)

params := m = 6.3, Q1 = 1

m = 6.3, Q1 = 1

(2)

subs(params, GainQ1 = 8*wx^2*(m-1)/(Pi^2*((m*wx^2-1)^2+Q1^2*wx^2*(wx^2-1)^2*(m-1)^2)^(1/2)))

GainQ1 = 4.296018185*wx^2/((6.3*wx^2-1)^2+28.09*wx^2*(wx^2-1)^2)^(1/2)

(3)

plot(rhs(GainQ1 = 4.296018185*wx^2/((6.3*wx^2-1)^2+28.09*wx^2*(wx^2-1)^2)^(1/2)), wx = .2 .. 2, axes = boxed, thickness = 5, axis[1] = [mode = log], title = `Gain (w, Q, m)`)

 

Top_of_Q1 = maximize(rhs(GainQ1 = 4.296018185*wx^2/((6.3*wx^2-1)^2+28.09*wx^2*(wx^2-1)^2)^(1/2)))

Top_of_Q1 = .8281966930

(4)

subs(GainQ1 = Top_of_Q1, Top_of_Q1 = .8281966930, GainQ1 = 4.296018185*wx^2/((6.3*wx^2-1)^2+28.09*wx^2*(wx^2-1)^2)^(1/2)); solve(%, {wx})

{wx = -.8945713660-0.1334178082e-4*I}, {wx = .8945713660+0.1334178082e-4*I}, {wx = -.8945713660+0.1334178082e-4*I}, {wx = .8945713660-0.1334178082e-4*I}

(5)

For numerical reasons, the solutions are complex. Alternatively you can use fsolve but an "error term" has to be added to get a real valued solution

subs(GainQ1 = Top_of_Q1, Top_of_Q1 = .8281966930, GainQ1 = 4.296018185*wx^2/((6.3*wx^2-1)^2+28.09*wx^2*(wx^2-1)^2)^(1/2)); fsolve((rhs-lhs)(%)+0.1e-5, {wx = .2 .. 2})

{wx = .8938364815}

(6)

Or use:

Optimization[Maximize](rhs(GainQ1 = 4.296018185*wx^2/((6.3*wx^2-1)^2+28.09*wx^2*(wx^2-1)^2)^(1/2)))

[.828196692670812418, [wx = HFloat(0.8945713660947568)]]

(7)

NULL

 

Download WO_assignment.mw

@Joe Riel 

Including a code optimization option in the custom component template (and making the intermediate variables disappear in the parameter pane) would be much more convenient than my separate Maple worksheet or inserting the commands into the template. Also, every user of a custom component could benefit from code optimization without having to learn the required Maple commands.

I would definitely use it!

@acer

If its by design, I will make the type specification my default. In my example the value of la is smaller than 0.5 which leads to errors of 50% and more (red C code vs Maple code in green).

By the way, codegen also has an undocumented design “feature”. When codegen is used in my original worksheet instead of CodeGeneration, the parameters defined as outputs appear as “passed by reference” in the C code. This works also with other names than outputs. Very handy. With CodeGeneration[C], “passed by referenced” must defined manually. (Since codegen is deprecated I will not ask, how codegen magically predicts what the outputs are.)

Thank you for the clarification!

@acer 

Sorry for the confusion.  

I found the type double as a synonym for float[8] here: help(type, float[8]). If the parser replaces it with float[8] I don't see a problem (if...).

The comment is more of a personal note. I meant: Type definition to double was added to get all parameters defined as double in the C code output of a subsequent call to CodeGeneration.

What is still not clear to me:

In the equation list there is one equation (t54 = 1 + 200 * la) that can be interpreted as integer relation. This could be the reason why CodeGeneration defines “t54” and “la” as int.

What I just tried: When this equation is inserted into an evalf call, "t54" and "la" are defined as double in the C code (without requiring your solution).

codegen neither requires your solution nor evalf workarounds (which make the code less clean).

With these observations I would ask now: Is this (assumed) interpretation of such equations a design feature or something unintended (i.e., something that should be reported)?

First 59 60 61 62 63 64 65 Last Page 61 of 70